You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been hacking at the code a fair bit lately and have encountered what appears to be a bug that results in one specific log entry getting written back to the database multiple times.
At first run after a cache clear, a new key is created and initialised to 0 at APC_CACHE_LOG_INDEX and $logindex is initialised to 0. Immediately afterwards we have
which doesn't increment the key or the value of $logindex because it has only just been added.
A key is then created based on $logindex, ie cachelogindex-0 and the first log entry stored there.
When the logentries are written back to the database the value stored at APC_CACHE_LOG_INDEX is reset to 0. However, when the code above is hit $added is false (because we haven't just created the key), so the value at APC_CACHE_LOG_INDEX and the value of $logindex is immediately raised to 1. Consequently, the entry at cachelogindex-0 is not overwritten, and the same, old entry is written back to the database at the next write out.
With default values, the same value will be written out every two minutes until its TTL is reached after 24 hours, ie 720 times. It's not so noticeable because the time recorded is the time of the write to the DB, not the time of the hit, so each entry is different. When I changed this behaviour to record the time of the original hit it jumped out!
The text was updated successfully, but these errors were encountered:
I've been hacking at the code a fair bit lately and have encountered what appears to be a bug that results in one specific log entry getting written back to the database multiple times.
At first run after a cache clear, a new key is created and initialised to 0 at APC_CACHE_LOG_INDEX and $logindex is initialised to 0. Immediately afterwards we have
which doesn't increment the key or the value of $logindex because it has only just been added.
A key is then created based on $logindex, ie cachelogindex-0 and the first log entry stored there.
When the logentries are written back to the database the value stored at APC_CACHE_LOG_INDEX is reset to 0. However, when the code above is hit $added is false (because we haven't just created the key), so the value at APC_CACHE_LOG_INDEX and the value of $logindex is immediately raised to 1. Consequently, the entry at cachelogindex-0 is not overwritten, and the same, old entry is written back to the database at the next write out.
With default values, the same value will be written out every two minutes until its TTL is reached after 24 hours, ie 720 times. It's not so noticeable because the time recorded is the time of the write to the DB, not the time of the hit, so each entry is different. When I changed this behaviour to record the time of the original hit it jumped out!
The text was updated successfully, but these errors were encountered: