Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Thread-safe problem with transactions #981

Closed
lighthouse-import opened this Issue May 16, 2011 · 1 comment

Comments

Projects
None yet
1 participant

Imported from Lighthouse. Original ticket at: http://rails.lighthouseapp.com/projects/8994/tickets/6651
Created by Michael Villar - 2011-03-30 11:01:31 UTC

I made a simple script to illustrate the problem.
http://sht.tl/8A8kC

The problem is the script blocks just before "project.save" after a while.
I found out (after a fucking time) that the problem occured because of the BEGIN COMMIT stuff around a UPDATE sql query.
I think, that two projects want to be saved at the same time, and the first query is not commited yet, so there are two BEGIN started.
http://sht.tl/unV

We should synchronize the transactions through the threads.
I made a terrible fix that I don't like but which works. I don't know ActiveRecord code so I wanted something simple.
http://sht.tl/6rMD

Thanks for reading. Hope I'm not wrong.

Config:
ActiveRecord 3.0.5
Postgresql
EventMachine

Imported from Lighthouse.
Comment by Michael Villar - 2011-03-30 11:32:09 UTC

MMh, my fix doesn't work when transaction's yield is making transactions too of course.. deadlock.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment