The timeout values used in the lock system rely on the local system time with the resulting timestamp being written to the semaphore table to be shared amongst processors in a web farm. Clock drift of more than 30 milliseconds (the default value for expiry in the system) between systems will render it useless in a web farm environment since locks will not be honoured and the behaviour will be unpredictable.
| Comment | File | Size | Author |
|---|---|---|---|
| #60 | D7-808416-60.patch | 3.13 KB | gaurav.kapoor |
| #54 | interdiff-51-54.txt | 1.45 KB | gaurav.kapoor |
| #54 | document_that_clock-808416-54.patch | 3.38 KB | gaurav.kapoor |
| #51 | document_that_clock-808416-51.patch | 3.41 KB | pushpinderchauhan |
| #51 | interdiff_808416_49-51.txt | 808 bytes | pushpinderchauhan |
Comments
Comment #1
lostchord commentedOoops - 30 seconds. Less likely but still an issue.
Comment #2
damien tournoud commentedThat's a documentation issue.
Comment #3
jhodgdonOK... Any suggestions on what text should be added to this page?
Comment #4
lostchord commentedWell that's a little tricky and I'm not sure that it's all down to documentation.
There are some assumptions in the code that the time-slop is in the order of milliseconds. Adjustments made by NTP can result in sudden jerks in time several orders of magnitude greater than that. If you are in a hosted environment you have little or no control over time...it's down to the admins at the hosting site I guess.
Given all that I would suggest some words to the effect that time adjustments and lack of close synchronisation between systems will impact the reliability of the locking sub-system in single and multi-server environments. It will not be 100% reliable even if the applications/modules are well coded. Don't try and launch rockets or run pacemakers using it :-)
Comment #5
jhodgdonWould you care to make a patch? Nothing will be changed until someone does that (that's how things work around here -- Drupal is a community-based open-source project, and filing issues is only part of the process). I personally don't think I understand the issues well enough to attempt it.
Comment #6
lostchord commentedSee if this works...based on drupal-7.0-alpha4 which is what I have downloaded at present. Patch created in NetBeans, I hope I got the files the right way around :-)
If it all goes pear shaped here is the text of the revised comments at the start of the module:
Comment #7
jhodgdonLaunching the test bot on this one.
Note to lostchord: When you attach a patch, you need to set the status to "needs review", which launches the test bot to test your patch, and also alerts humans that there's something here to look at. Thanks.
EDIT/ADDED: Also, it is not necessary to paste anything from your patch into the text of your comment -- we can read the patch. The only exception would be if you are making a patch that affects a page Drupal generates -- in that case it is helpful to attach before and after screen shots.
Comment #8
jhodgdonPlease read http://drupal.org/patch/create to find out how to create patches that will work. Needs to be in unified diff format. Thanks.
Comment #9
jhodgdonAlso, you need to read
http://drupal.org/node/1354
which explains our documentation standards. Thanks.
Comment #10
lostchord commentedI will dig a bit deeper. I had assumed, based on this extensive documentation in the patch creation documentation, that NetBeans produced the right format.
Comment #11
lostchord commentedTrying again.....
Comment #13
jhodgdonUmmm... We don't generally put headers in all caps into our documentation blocks. In fact, I don't know of a single instance where we have ever done that.
Patch also needs some punctuation and grammar editing. I can do this later (no time today).
Wrapping is also an issue. Lines within a paragraph should wrap as close to 80 chars as possible without going over.
I'm not sure you need to mention the global array really... why is it important to mention in this doc?
Comment #14
lostchord commentedRe global array: What happens if it gets stomped on? This is a warning that if you use the locks API then you'd better not use a global array called locks in your own code. This should be a standard part of the documentation, if the API implementation leaves things hanging around that the user can trip over then document it. If the API also uses particular resources and hangs onto them, document it, etc etc. This avoids nasty surprises.
Regards to wrapping. Is this because the output from the API module doesn't just glob all the lines into a single para or because it looks ugly for those reading the raw code?
I will have one more go and try and fix the end-of-line issue, if that doesn't do it then I'm not going to waste any more time on it.
Comment #15
lostchord commentedReplaced CRLF with LF
Comment #17
lostchord commentedComment #19
jhodgdonlostchord: We don't need to document every side effect of every function. That is what the code is for.
Not sure why your patches are failing.
Comment #20
lostchord commentedI think I know why the patch is failing, I don't know if there will be any further obstacles once I get past this one, I'm not going to find out.
If you rely on the code for glossing over deficiencies in the documentation, and cultivate the attitude that it's OK to leave things out because it's all in the code, then your API documentation is not going to get any better.
Comment #21
jhodgdonHere's a new patch. I've cleaned up the documentation, made it conform to our standards, etc.
Comment #23
jhodgdon#21: 808416-fixup.patch queued for re-testing.
Comment #24
jhodgdon#21: 808416-fixup.patch queued for re-testing.
Comment #25
jhodgdon#21: 808416-fixup.patch queued for re-testing.
Comment #26
daniels220 commentedLooks reasonable to me.
Comment #27
daniels220 commentedComment #28
dries commentedThis looks good. One small detail:
The clock is maintained by the operating system / BIOS, not the processor. I'd change 'processor' to 'machine'.
Comment #29
lostchord commentedIf you factor virtualisation into the picture it can become even more confusing....and BIOS is very much a PC thing. There will be a hardware clock that the O/S will initially take its time from at boot, it does not have to rely on this clock beyond that point although it does need an interrupt source to maintain its own notion of time. Applications may also maintain an independent view of time that is distinct from the other views of time around them. So it is not simple.
If you want a rewrite I would therefore suggest:
"Timestamps are derived from the local system clock of the environment the code is executing in"
Comment #30
daniels220 commentedRerolled with that change.
Comment #31
damien tournoud commented"is is"
This sounds too verbose to me. This is really nothing more then a cornercase. I would drop that completely.
Comment #32
daniels220 commentedI'll let others discuss your second point, but here's a patch that fixes the typo.
Comment #33
lostchord commentedFundamental flaw = Corner case.
Nice.
===== Edit =====
From the D6 settings.php:
This is a documented supported configuration option...but not supported by the lock routine. Feature????? Next you'll be saying that a 'memory leak' isn't a bug ;-)
Comment #34
jhodgdonCleaning up old docs bugs. I guess this one needs to be d8 now... and needs a retest. and a review.
Comment #35
jhodgdon#32: lock_system_D7_new_808416.patch queued for re-testing.
Comment #37
jhodgdonApparently this needs a reroll as well as a review.
Comment #38
oriol_e9gReroll
Comment #39
jhodgdonThanks! This still needs a review.
Comment #40
jhodgdon#38: lock_system_docu-808416-38.patch queued for re-testing.
Comment #41
jhodgdonComment #46
jp.stacey commentedThe last patch pre-dates a lot of work rearchitecting D8 core, and hence is always going to fail (
includes/lock.incdoesn't exist any more!) However, the relevant code was moved tocore/lib/Drupal/Core/Lock/LockBackendInterface.php, fortunately without much change to the docblocks.I've therefore manually rerolled the patch for 8.3.x, and attach both the patch and an interdiff.
Comment #47
kiwimind commenteds/evironment/environment
Otherwise looks good to go.
Comment #49
jacobsanfordEnclosed is a patch correcting the typo as outlined in #47.
Comment #50
kiwimind commentedSorry, another one.
Either "To avoid this type of conflict" or "To avoid these types of conflicts"
Comment #51
pushpinderchauhan commented"To avoid these types of conflicts" looks good to me.
Comment #52
kiwimind commentedThis reads well and applies correctly to 8.4.x.
Comment #53
gábor hojtsyI see this issue has a very long history. Would have been happy to score a win for y'all given the issue is exactly 7 years old today, but stumbled into some stuff:
What does the last sentence mean? Denial of service does not sound like a best case in and of itself(?)
Does this try to convey that whatever is the process acquiring the lock is working on should be shared among processes too that could potentially acquire the lock? I am not sure "managed resources" makes this very clear, it does not say who manages said resources, is this confined to the process asking for the lock or more general?
Comment #54
gaurav.kapoor commentedRemoved DDoS example as it wasn't providing any useful information. Edited the "Sharing" point accordingly.
Comment #55
gaurav.kapoor commentedComment #56
kiwimind commentedPersonally I like how you're rewritten the shared resources point. I had a look into that too and think that yours reads well.
Patch looks good, so I'm happy to mark as RTBC again in the hope that this old ticket can move forwards.
Thanks.
Comment #59
gábor hojtsySuperb, thanks! Comitted and pushed to 8.4.x and 8.3.x.
As per the issue tags, it needs to be ported to 7.x too.
Comment #60
gaurav.kapoor commentedDid respective changes for D7.
Comment #61
gaurav.kapoor commented..
Comment #62
poker10 commentedI think the D7 backport looks good, thanks! Compared the changes with the current D10 code and the text is the same, see: https://git.drupalcode.org/project/drupal/-/blob/11.x/core/lib/Drupal/Co... . RTBC.
Comment #64
mcdruid commentedThank you everybody that worked on this!