Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.2] Add shared locks to Filesystem and Cache/FileStore #12796

Merged
merged 6 commits into from
Mar 21, 2016
Merged

[5.2] Add shared locks to Filesystem and Cache/FileStore #12796

merged 6 commits into from
Mar 21, 2016

Conversation

deadem
Copy link
Contributor

@deadem deadem commented Mar 19, 2016

Have a problem with Cache/FileStore on a production server. It periodically fails with unserialize error:

exception 'ErrorException' with message 'unserialize(): Error at offset 282612 of 282614 bytes' in /home/user/xxx/vendor/laravel/framework/src/Illuminate/Cache/FileStore.php:80
Stack trace:
#0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(8, 'unserialize(): ...', '/home/user/xxx...', 80, Array)
#1 /home/user/xxx/vendor/laravel/framework/src/Illuminate/Cache/FileStore.php(80): unserialize('O:39:"Illuminat...')
#2 /home/user/xxx/vendor/laravel/framework/src/Illuminate/Cache/FileStore.php(49): Illuminate\Cache\FileStore->getPayload('todayEvents')
#3 /home/user/xxx/vendor/laravel/framework/src/Illuminate/Cache/Repository.php(129): Illuminate\Cache\FileStore->get('todayEvents')
#4 /home/user/xxx/vendor/laravel/framework/src/Illuminate/Cache/Repository.php(288): Illuminate\Cache\Repository->get('todayEvents')
#5 [internal function]: Illuminate\Cache\Repository->remember('todayEvents', 1, Object(Closure))
#6 /home/user/xxx/vendor/laravel/framework/src/Illuminate/Cache/CacheManager.php(296): call_user_func_array(Array, Array)
#7 /home/user/xxx/bootstrap/cache/compiled.php(6222): Illuminate\Cache\CacheManager->__call('remember', Array)
#8 /home/user/xxx/bootstrap/cache/compiled.php(6222): Illuminate\Cache\CacheManager->remember('todayEvents', 1, Object(Closure))
#9 /home/user/xxx/app/Http/Controllers/Controller.php(101): Illuminate\Support\Facades\Facade::__callStatic('remember', Array)
#10 /home/user/xxx/app/Http/Controllers/Controller.php(101): Illuminate\Support\Facades\Cache::remember('todayEvents', 1, Object(Closure))

Cache/FileStore read file from cache when another instance of php script write same file into cache. I've added some locks to read/write from cache.

@GrahamCampbell GrahamCampbell changed the title Add shared locks to Filesystem and Cache/FileStore [5.2] Add shared locks to Filesystem and Cache/FileStore Mar 19, 2016
$contents .= fread($handle, 1048576);
}
}
fclose($handle);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be wrapped in a try finally to make sure this gets closed

@deadem
Copy link
Contributor Author

deadem commented Mar 19, 2016

@GrahamCampbell There is a bug in hhvm 3.6.6. file_put_constnts(..., LOCK_EX) truncates file immediately and then set the lock. facebook/hhvm#5657

Should I replace Filesystem::put with custom code or skip this test on hhvm versions before HHVM-3.10.0?

@GrahamCampbell
Copy link
Member

Just skip HHVM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants