{"record":{"id":"ff0b78f302d2a643","repo":"phacility/phabricator","slug":"an-previous-write-to-this-repository-was-interrupt","errorCode":null,"errorMessage":"An previous write to this repository was interrupted; refusing new writes. This issue requires operator intervention to resolve, see \"Write Interruptions\" in the \"Cluster: Repositories\" in the documentation for instructions.","messagePattern":"An previous write to this repository was interrupted; refusing new writes\\. This issue requires operator intervention to resolve, see \"Write Interruptions\" in the \"Cluster: Repositories\" in the documentation for instructions\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"critical","filePath":"src/applications/diffusion/protocol/DiffusionRepositoryClusterEngine.php","lineNumber":398,"sourceCode":"      }\n    } catch (PhutilLockException $ex) {\n      throw new PhutilProxyException(\n        pht(\n          'Failed to acquire write lock after waiting %s second(s). You '.\n          'may be able to retry later. (%s)',\n          new PhutilNumber($lock_wait),\n          $ex->getHint()),\n        $ex);\n    }\n\n    $versions = PhabricatorRepositoryWorkingCopyVersion::loadVersions(\n      $repository_phid);\n    foreach ($versions as $version) {\n      if (!$version->getIsWriting()) {\n        continue;\n      }\n\n      throw new Exception(\n        pht(\n          'An previous write to this repository was interrupted; refusing '.\n          'new writes. This issue requires operator intervention to resolve, '.\n          'see \"Write Interruptions\" in the \"Cluster: Repositories\" in the '.\n          'documentation for instructions.'));\n    }\n\n    $read_wait_start = microtime(true);\n    try {\n      $max_version = $this->synchronizeWorkingCopyBeforeRead();\n    } catch (Exception $ex) {\n      $write_lock->unlock();\n      throw $ex;\n    }\n    $read_wait_end = microtime(true);\n\n    $pid = getmypid();\n    $hash = Filesystem::readRandomCharacters(12);","sourceCodeStart":380,"sourceCodeEnd":416,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/protocol/DiffusionRepositoryClusterEngine.php#L380-L416","documentation":"Every clustered device's working-copy version row carries an isWriting flag set for the duration of a write. Finding it still set means a previous write was interrupted mid-flight (daemon crash, kill, power loss, DB hiccup), so the on-disk copy may be incomplete. All new writes are refused until an operator verifies and repairs the state ('Write Interruptions' in the Cluster: Repositories documentation).","triggerScenarios":"A push or synchronization was killed between setting the isWriting flag and clearing it (kill -9 on daemons, host crash, master DB flap mid-write); the very next write attempt on the repository throws this.","commonSituations":"Aggressive daemon restarts during active push windows; OOM or power loss on a repository node; database flapping while a write is in progress.","solutions":["Identify the frozen device: query phabricator_repository_workingcopyversion for the repository and isWriting = 1","Verify that device's working copy integrity (git fsck / hg verify) and compare its heads against the other cluster devices","Follow 'Write Interruptions' in the Cluster: Repositories documentation to clear the flag, promoting a known-good device and rebuilding the damaged copy if necessary","Prevent recurrence by stopping daemons gracefully (bin/phd stop) instead of killing them during push windows"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// pre-flight: refuse writes if any device reports an interrupted write\n$versions = PhabricatorRepositoryWorkingCopyVersion::loadVersions($repository->getPHID());\nforeach ($versions as $version) {\n  if ($version->getIsWriting()) {\n    // fail fast with operator instructions instead of attempting the push\n  }\n}","typeGuard":"function repositoryHasInterruptedWrite(array $versions) {\n  foreach ($versions as $version) {\n    if ($version->getIsWriting()) { return true; }\n  }\n  return false;\n}","tryCatchPattern":"try {\n  $engine->synchronizeWorkingCopyBeforeWrite();\n} catch (Exception $ex) {\n  // mark the push permanently failed (not retryable), notify the pusher that operator action is required, alert on-call\n}","preventionTips":["Stop daemons gracefully (bin/phd stop); avoid kill -9 during push windows","Alert when any isWriting flag stays set for more than a few minutes","Keep hosts and the master DB stable during write windows"],"tags":["cluster","write-interruption","recovery","data-integrity","phabricator"],"backgroundTag":"interrupted-write-recovery","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}