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
We have noticed that our application occasionally times out. When this happens, logs nearly always indicate that the script stopped execution at "promphp/prometheus_client_php/src/Prometheus/Storage/APC.php on line 72" (sometimes line 71).
This is the following block inside \Prometheus\Storage\APC::updateHistogram
// Atomically increment the sum// Taken from https://github.com/prometheus/client_golang/blob/66058aac3a83021948e5fb12f1f408ff556b9037/prometheus/value.go#L91$done = false;
while (!$done) {
$old = apcu_fetch($sumKey);
if ($old !== false) {
$done = apcu_cas($sumKey, $old, $this->toBinaryRepresentationAsInteger($this->fromBinaryRepresentationAsInteger($old) + $data['value']));
}
}
My very superficial understanding leads me to believe that apcu_cas may be unlikely to return true if another process (or many processes) are also continuously updating the value stored at $sumKey, since $old may no longer match the persisted value.
Do you see any cause for concern or is my analysis incorrect?
The text was updated successfully, but these errors were encountered:
skyellin
changed the title
Possible Race Condition in updateHistogram
Possible Race Condition in APC::updateHistogram
Dec 12, 2023
We have noticed that our application occasionally times out. When this happens, logs nearly always indicate that the script stopped execution at "promphp/prometheus_client_php/src/Prometheus/Storage/APC.php on line 72" (sometimes line 71).
This is the following block inside \Prometheus\Storage\APC::updateHistogram
My very superficial understanding leads me to believe that
apcu_cas
may be unlikely to return true if another process (or many processes) are also continuously updating the value stored at$sumKey
, since$old
may no longer match the persisted value.Do you see any cause for concern or is my analysis incorrect?
The text was updated successfully, but these errors were encountered: