Commit 044347a 1 parent 99577b7 commit 044347a Copy full SHA for 044347a
File tree 2 files changed +7
-0
lines changed
src/main/kotlin/uk/gov/justice/digital/hmpps/hmppstier/service
2 files changed +7
-0
lines changed Original file line number Diff line number Diff line change 1
1
package uk.gov.justice.digital.hmpps.hmppstier.service
2
2
3
3
import org.slf4j.LoggerFactory
4
+ import org.springframework.dao.DataIntegrityViolationException
4
5
import org.springframework.stereotype.Service
5
6
import uk.gov.justice.digital.hmpps.hmppstier.client.AssessmentForTier
6
7
import uk.gov.justice.digital.hmpps.hmppstier.client.NeedSection
@@ -58,6 +59,10 @@ class TierCalculationService(
58
59
)
59
60
}
60
61
} catch (e: Exception ) {
62
+ if (e is DataIntegrityViolationException ) {
63
+ log.error(" Multiple concurrent attempts to calculate tier for $crn => $recalculationSource " )
64
+ return
65
+ }
61
66
val eventType = if (allowUpdates) TIER_CALCULATION_FAILED else TIER_RECALCULATION_DRY_RUN_FAILURE
62
67
telemetryService.trackEvent(
63
68
eventType,
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package uk.gov.justice.digital.hmpps.hmppstier.service
2
2
3
3
import org.springframework.data.repository.findByIdOrNull
4
4
import org.springframework.stereotype.Service
5
+ import org.springframework.transaction.annotation.Propagation
5
6
import org.springframework.transaction.annotation.Transactional
6
7
import uk.gov.justice.digital.hmpps.hmppstier.jpa.entity.TierCalculationEntity
7
8
import uk.gov.justice.digital.hmpps.hmppstier.jpa.entity.TierSummary
@@ -14,6 +15,7 @@ class TierUpdater(
14
15
private val tierSummaryRepository : TierSummaryRepository ,
15
16
) {
16
17
18
+ @Transactional(propagation = Propagation .REQUIRES_NEW )
17
19
fun removeTierCalculationsFor (crn : String ) {
18
20
tierCalculationRepository.deleteAllByCrn(crn)
19
21
tierSummaryRepository.deleteById(crn)
You can’t perform that action at this time.
0 commit comments