lock_acquire() adds 0.001 (1 ms) to the timeout “in order to avoid errors with float to string conversion”. This was mentioned in #251792-155: Implement a locking framework for long operations comment #155, but without any explanation of why 1 ms is necessary and sufficient to avoid the rounding errors. Why not 0.001 ms or 0.5 second?
It seems that in D7 1 ms is enough, but in D6 it is not. It seems that the difference is due to how floating point numbers are handled inside the PDO driver (?!).
On D6, try inserting the following row:
INSERT INTO semaphore VALUES ('foo','20235236224d7df493403f85.14852477',1300100273.2631);
Notice that lock_may_be_available('foo') returns FALSE, even though the timeout is in the past, so the function is supposed to delete that row. The semaphore gets stuck forever.
This patch changes the code to use the current time rather than the looked up timeout when deleting expired semaphores. This should be just as correct, and it makes the code more robust (so we don't need to research if 1 ms really is enough to avoid the rounding error).
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | lock-expire-3.patch | 1.64 KB | c960657 |
| #4 | lock-expire-2.patch | 3.03 KB | c960657 |
| #1 | lock-expire-1.patch | 1.61 KB | c960657 |
| lock-expire-1-D7.patch | 1.61 KB | c960657 | |
| lock-expire-1-D6.patch | 1.38 KB | c960657 |
Comments
Comment #1
c960657 commentedRename the D7 patch to force the test bot to pick it up.
Comment #2
eule commentedHi guys
since yesterday i can´t join my site..i am not a pro..just want to help..i dont know is it releated but i have issue with the lock.inc
here is the error thats i have since yesterday.
PDOException: SQLSTATE[HY000]: General error: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NAMES utf8' at line 1 in lock_may_be_available() (line 165 of ./includes/lock.inc)
Drupal 7
error is now gone since i have consulatet my hostingcompany..but il post it maybe it helps
Comment #3
c960657 commentedComment #4
c960657 commentedReroll.
Comment #5
c960657 commentedSorry, please ignore lock-expire-2.patch.
Comment #6
kscheirer#5: lock-expire-3.patch queued for re-testing.
Comment #8
leeotzu commentedCan we close this issue? The architecture of Lock mechanism has changed a lot.
Comment #9
Nephele commentedFYI, this is still a problem in Drupal 8. However, another queue has an active discussion, namely #2077827: Lock system is broken in many regards (was: needs a precision of at least 14 for timestamp comparison).