SA Bugzilla – Bug 1635
safe_lock() doesn't check return status when unlinking temp lock file
Last modified: 2003-03-15 01:20:33 UTC
unlink $lock_tmp; should actually be something like: unlink $lock_tmp || dbg("lock: $$ cannot remove temp lock file $lock_tmp: $!");
assigning to myself
Created attachment 745 [details] suggested patch
attached patch, added backport keyword. any comments? :)
ISSUE: you don't want to warn on the first unlink. There's a race condition. Two or more processes could try to delete the stale lock at the same time which is okay because they have yet to get the lock and that's still safe. You can warn on the second unlink if you want.
Subject: Re: safe_lock() doesn't check return status when unlinking temp lock file On Fri, Mar 14, 2003 at 10:37:01AM -0800, bugzilla-daemon@hughes-family.org wrote: > ISSUE: you don't want to warn on the first unlink. There's a race > condition. Two or more processes could try to delete the stale lock > at the same time which is okay because they have yet to get the lock > and that's still safe. Ok, but what's the issue? It's a warn, not a die. There is a race condition, but putting up a warning is still the correct behavior. At that point in the code, we've already announced that we're breaking the lock. If the break doesn't happen (as the other process has already broken it), we want to say "we didn't break the lock". If that process then grabs the lock, it'll look wierd in the debug output ("trying to break lock", "failed to break lock", "got lock"), but no more than the other version (no warn there) where the process says it'll break the lock and the other process grabs it, then the debug output says "trying to break lock", "waiting for lock" ... The only two race conditions here is: process A says it'll break the lock, and process B can get the lock between the break and lock, and process A says it'll break the lock but can't because process B either already broke it or gave up its lock. A "warn" just properly gives the state that "we tried to break the lock, but failed for some reason", followed by the reason (file not found, permissions, etc.)
I just don't want to warn for anything that's not an error condition or something to worry about. Why open ourselves up for having to explain that a warning can be ignored because it's harmless. Just don't print a warning if it's harmless!
Subject: Re: safe_lock() doesn't check return status when unlinking temp lock file On Fri, Mar 14, 2003 at 11:08:44AM -0800, bugzilla-daemon@hughes-family.org wrote: > Just don't print a warning if it's harmless! Well ... What's the purpose of a "warning" if you really mean "error"? The whole point of a warning is that something happened that you probably should be aware of (like "I can't remove this file"). Just because the program doesn't abort because of it doesn't mean you shouldn't tell people that something that should of worked failed.
OKAY (I'd be happier if we exempted ENOENT since that's not an error. Your call. Even with ENOENT, I could go either way: leave it out or put it in.)
applied to STABLE