-
Notifications
You must be signed in to change notification settings - Fork 360
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[AN-286] Fixes deadlock issue in GROUP_METRICS_ENTRY table #7677
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very cool! 👍
Walkthrough worthy IMO, I would love to hear your process.
if ex.isInstanceOf[SQLIntegrityConstraintViolationException] || (ex | ||
.isInstanceOf[PSQLException] && ex.getMessage.contains( | ||
"duplicate key value violates unique constraint \"UC_GROUP_METRICS_ENTRY_GI\"" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are different cases for various DBs? I assume PSQL... is Postgres.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that is correct. Postgres throws general PSQLException
when duplicate values are inserted and hence I added the text checking as well here.
} | ||
|
||
/* | ||
The approach here is to try and insert the record into the table and if that fails because a record with that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Crystal clear explanation, thanks a lot for adding that 😻
} yield () | ||
runTransaction(action) | ||
|
||
runTransaction(insertAction, TransactionIsolation.ReadCommitted) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want to add the link to the doc stating that postgress recommends ReaCommitted?
@@ -109,6 +109,34 @@ class GroupMetricsSlickDatabaseSpec extends AnyFlatSpec with Matchers with Scala | |||
} yield ()).futureValue | |||
} | |||
|
|||
it should "handle parallel upserts to database" taggedAs DbmsTest in { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice test!
Description
Fixes the deadlock issue in GROUP_METRICS_ENTRY table.
Jira ticket: https://broadworkbench.atlassian.net/browse/AN-286
Release Notes Confirmation
CHANGELOG.md
CHANGELOG.md
in this PRCHANGELOG.md
because it doesn't impact community usersTerra Release Notes