FOR UPDATE not working

Issue #173 invalid
TDJdev
created an issue

I want to report a bug. SELECT FOR UPDATE statement is not blocking until the end of transaction, as it should.

10.times {
    Thread.new {
        x = db.value 'SELECT val FROM users WHERE id = 2 FOR UPDATE'
        sleep 5
        db.raw 'UPDATE users SET val = ? WHERE id = 2', x+1
    }
}

Expected result: script finishing in 50 seconds users.val is greater by 10 when script stops

Actual result: script finishes in 5 seconds users.val is greater by 1 at the end

Comments (3)

  1. Log in to comment