Page MenuHomePhabricator

FSFileBackend doPrepareInternal() should recover from mkdir failure when directory exists (race)
Closed, ResolvedPublic

Description

Browsers doing multiple http requests at once for items linked to (thumbs) in a file description page are going to set off the race condition from time to time in FSFBackend:

if ( !wfMkdirParents( $dir ) ) { // make directory and its parents

$status->fatal( 'directorycreateerror', $params['dir'] ); // fails on races

Why not check if the error was 'File exists' and proceed in that case? The debug log entry looks like this:
[FSFileBackend] mkdir() [<a href='function.mkdir'>function.mkdir</a>]: File exists
If the status object doesn't have a good representation of the type of error condition, you could always double check if the dir is suddenly there before giving up.


Version: 1.22.0
Severity: normal

Details

Reference
bz49391

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 2:05 AM
bzimport set Reference to bz49391.
bzimport added a subscriber: Unknown Object (MLST).
Ejegg added a comment.Sep 12 2013, 2:04 AM

Sounds like a good idea, but maybe wfMkdirParents should be the one to check again for the directory's existence if mkdir fails, since it initially checks and returns true if the dir already exists.

Just submitted https://gerrit.wikimedia.org/r/84100 to have wfMkdirParents return true if another request causes the directory to be created. Reviewers are most welcome!

Change 84100 had a related patch set uploaded by Parent5446:
wfMkdirParents: recover from mkdir race condition

https://gerrit.wikimedia.org/r/84100

Change 84100 merged by jenkins-bot:
wfMkdirParents: recover from mkdir race condition

https://gerrit.wikimedia.org/r/84100

Was successfully merged

Gilles raised the priority of this task from Medium to Unbreak Now!.Dec 4 2014, 10:25 AM
Gilles moved this task from Untriaged to Done on the Multimedia board.
Gilles lowered the priority of this task from Unbreak Now! to Medium.Dec 4 2014, 11:21 AM