delayed_job_active_record icon indicating copy to clipboard operation
delayed_job_active_record copied to clipboard

Add transaction scope around postgres ‘find_by_sql’ statement

Open nimast opened this issue 12 years ago • 3 comments

This is in order to prevent multiple instances of DJ from picking up the same task (as the current locking of FOR UPDATE will suffice for a single connection, when scaled out our workers seemed to have been picking up the same job on different machines)

nimast avatar Jan 07 '14 16:01 nimast

Coverage Status

Changes Unknown when pulling 723ff09039b310a76f66364866750523309f25c2 on nimast:feature/postgres-reserve-transaction into * on collectiveidea:master*.

coveralls avatar Jan 07 '14 16:01 coveralls

this shouldn't actually be the source of a concurrency problem: http://dba.stackexchange.com/questions/158706/is-a-postgresql-subquery-in-autocommit-mode-part-of-the-same-transaction-or-a-di?noredirect=1#comment304489_158706

http://stackoverflow.com/questions/11532550/atomic-update-select-in-postgres#comment69692209_11568880

ericcj avatar Jan 10 '17 19:01 ericcj

@ericcj See the part regarding multiple users in the second post you mentioned. Perhaps serializable isolation level would also fix this issue, but adding a transaction scope solved it too.

nimast avatar Jan 14 '17 22:01 nimast