busy('storage_replica_tick'); try { $worked = $worker->tick(); $errors = $worker->observationErrors(); } catch (\Throwable $error) { $errors[] = 'storage_replica_failed'; $heartbeat->error('storage_replica_failed'); fwrite( STDERR, 'storage replica worker temporarily unavailable: ' . get_class($error) . PHP_EOL ); if ($once) { return 1; } $worked = false; } if ($errors === []) { // An idle poll proves only that the process is alive. It // must not erase a prior copy/reconciliation warning; a // later item has to complete cleanly before the worker is // projected healthy again. if ($worked) { $unresolved = false; $heartbeat->success(); } elseif (!$unresolved) { $heartbeat->success(); } } else { // Error details remain in durable operation records. The // public heartbeat exposes only this bounded category. $unresolved = true; $heartbeat->error('storage_replica_failed'); } if (!$once && !$worked) { usleep(1000000); } } while (!$once); } catch (\Throwable $error) { $heartbeat->error('storage_replica_failed'); throw $error; } finally { $heartbeat->stopped(); } return 0; } }