Replies: 1 comment 1 reply
-
I've experienced similar deadlocks in Postgres, and the solution was to do the updates in a deterministic order (e.g. by ID). Because you're essentially doing multiple updates in a single (implicit) transaction, so this could deadlock if simultaneous but in different order. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am working on fixing the broken rack tests on the techempower benchmarks. I decided to use sequel instead of the raw pg driver for the tests because I want to be able to run the tests with jruby and jdbc as well as mri. The tests say that when you do the updates portion of the test you must select N number records separately (not in the same transaction), put those in an array and then change the value to a random number and then persist the data back into the database. When you do the updates you don't have to update each record separately you can batch the update calls into the same call.
I do a simple string concatenation for the updates like this.
This sometimes causes a deadlock error in postgres
This makes no sense to me as the selects are done already and each update statement updates a unique id.
I am using puma in this case puma does have
The problem is worse when I am using falcon and I use the :fiber_concurrency
Any ideas on how I can prevent these deadlocks?
Beta Was this translation helpful? Give feedback.
All reactions