Closed jaymecd closed 8 years ago
/cc @schmittjoh
Did you consider first writing a temporary file and then renaming that?
@schmittjoh nope, but you're right, as LOCK_EX
locks file with blocking I/O and all requests have to wait. Will update PR
@schmittjoh, PR is updated
Can we verify the written file before renaming instead of each time it is used?
updated, smth like this https://github.com/schmittjoh/JMSSecurityExtraBundle/pull/206/files#diff-4794a4cf6e3b7bf956a2df6fbffbc014R154 you've meant?
@schmittjoh, build fixed, anything to be corrected?
ping @schmittjoh
@schmittjoh, would be good to have ur feedback or merge. tnx
@schmittjoh, btw, what d'u think on off-load cache file creation into cache warmup process?
I've made small updates:
error
to warning
log level in case of broken cachereason
into log messagesApart from the comment above, looks good otherwise.
@schmittjoh, any updates/ETA regarding this PR? tnx
@schmittjoh please, could we make a new release with this fix ?
Severity: critical
Within massive traffic and concurrent requests (nginx + php5-fpm), cache file is created with 0 size. Next requests load empty file, what causes ACCESS_DENIED.
This PR checks if exact amount of bytes were written to cache file to avoid being locked by empty file during race condition. Non-blocking I/O is done by
writing tmpfile
+rename()
afterwards. If failed, fallbacks gracefully toeval($source)
.Benchmark, why to
eval($source)
instead ofrequire $file
after cache has been written.Affected versions ^1.2 Tested version: ^1.5 Required to fix versions: at least ^1.5