-
Notifications
You must be signed in to change notification settings - Fork 211
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
fix: DB write of upsert pins in run as group #1598
Conversation
Signed-off-by: Enrique Lacal <[email protected]>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1598 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 337 337
Lines 29498 29502 +4
=========================================
+ Hits 29498 29502 +4 ☔ View full report in Codecov by Sentry. |
Tested locally and you can see that the insert fails but then the upset is fine
|
for _, pin := range pins { | ||
if err := em.database.UpsertPin(ctx, pin); err != nil { | ||
if err := em.database.UpsertPin(upsertCtx, pin); err != nil { |
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.
Seems like a very bad idea to intentionally do this outside the database transaction.
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.
The batch insert above should be non-fatal (should be configured to return an empty result on conflict)
No longer need as was already fixed by b26fa27 |
In the case where FireFly is restarted and the listener for BatchPin events is recreated in the blockchain connector, FireFly will re-index all the events into the system. The Pins table has an index for uniqueness of
batch_id+hash+namespace
so it will not allow inserting a duplicate record. In this case, the code falls back to upsetting the batch which is correct but this code is run in the context of DB TX which will never succeed as the previous insert fails.You get the error
current transaction is aborted, commands ignored until end of transaction block
, explanation athttps://stackoverflow.com/questions/10399727/psqlexception-current-transaction-is-aborted-commands-ignored-until-end-of-tra why you get this error.
So there are two options: