Skip to content
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

DM-47543: Reduce likelihood of collection deadlocks #1116

Merged
merged 1 commit into from
Nov 14, 2024
Merged

Conversation

dhirving
Copy link
Contributor

@dhirving dhirving commented Nov 13, 2024

Fix an issue where concurrent calls to transfer_from() in Prompt Processing were causing Postgres to abort with a deadlock error.

We now register collection names in alphabetical order when multiple collections are registered inside a transaction in transfer_from(). Because ButlerCollections.register() inserts rows into a table with a unique index, Postgres takes a lock when the row is inserted and holds it until the end of the transaction. If there are two processes with concurrent transactions attempting to create the same collections, it is possible for the locks to be acquired in different orders, causing a deadlock.

Checklist

  • ran Jenkins
  • added a release note for user-visible changes to doc/changes
  • (if changing dimensions.yaml) make a copy of dimensions.yaml in configs/old_dimensions

Copy link

codecov bot commented Nov 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.42%. Comparing base (615b2ba) to head (477fdf6).
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1116   +/-   ##
=======================================
  Coverage   89.41%   89.42%           
=======================================
  Files         363      363           
  Lines       48440    48444    +4     
  Branches     5879     5879           
=======================================
+ Hits        43315    43319    +4     
  Misses       3716     3716           
  Partials     1409     1409           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

`Butler.transfer_from`.
"""

dataset_type: DatasetType
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a somewhat expensive equality key, and I think the str dataset type name would work as well.

Fix an issue where concurrent calls to transfer_from() in Prompt Processing were causing Postgres to abort with a deadlock error.

We now register collection names in alphabetical order when multiple collections are registered in a single transaction.  Because `ButlerCollections.register()` inserts rows into a table with a unique index, Postgres takes a lock when the row is inserted and holds it until the end of the transaction.  If there are two processes with concurrent transactions attempting to create the same collections, it is possible for the locks to be acquired in different orders, causing a deadlock.
@dhirving dhirving merged commit 3672820 into main Nov 14, 2024
19 checks passed
@dhirving dhirving deleted the tickets/DM-47543 branch November 14, 2024 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants