Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
salonishah11 committed Jan 14, 2025
1 parent 720f207 commit 3be908c
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ trait GroupMetricsSlickDatabase extends GroupMetricsSqlDatabase {
.quotaExhaustionForGroupId(groupMetricsEntry.groupId)
.update(groupMetricsEntry.quotaExhaustionDetected)
} yield ()

// The transaction level is set to 'ReadCommitted' to avoid Postgres returning error `could not serialize
// access due to concurrent update` which happens in 'RepeatableRead' or higher isolation levels.
// See https://stackoverflow.com/questions/50797097/postgres-could-not-serialize-access-due-to-concurrent-update
runTransaction(updateAction, TransactionIsolation.ReadCommitted)
}

Expand All @@ -43,7 +47,7 @@ trait GroupMetricsSlickDatabase extends GroupMetricsSqlDatabase {
_ <- dataAccess.groupMetricsEntryIdsAutoInc += groupMetricsEntry
} yield ()

runTransaction(insertAction, TransactionIsolation.ReadCommitted)
runTransaction(insertAction)
.recoverWith {
case ex
if ex.isInstanceOf[SQLIntegrityConstraintViolationException] || (ex
Expand Down

0 comments on commit 3be908c

Please sign in to comment.