Maprunner / rg2

Updated user interface for Routegadget
MIT License
36 stars 20 forks source link

Lock file race condition #515

Closed Maprunner closed 2 years ago

Maprunner commented 2 years ago

There are very infrequent examples of this for big events (implying multiple concurrent users or just genera;ly more save attempts):

PHP Warning: mkdir(): File exists in /home/customer/www/scottish6days.routegadget.co.uk/public_html/rg2/app/utils.php on line 56

    if (is_dir(LOCK_DIRECTORY)) {
        // locked already by someone else
        //self::rg2log("Directory exists ".date("D M j G:i:s T Y", filemtime(LOCK_DIRECTORY)));
    } else {
        // try to lock it ourselves
        //self::rg2log("Trying to lock ".LOCK_DIRECTORY);
        $locked = mkdir(LOCK_DIRECTORY, 0777);
    }

So it looks like the lock directory got created by somone else between the call to is_dir and the call to mkdir. Or maybe it is a bug in php: https://stackoverflow.com/questions/44322783/is-is-dir-unreliable-or-are-there-race-conditions-that-can-be-mitigated-here