phacility/phabricator · critical · Exception

An previous write to this repository was interrupted; refusi

Error message

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.

What it means

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).

Source

Thrown at src/applications/diffusion/protocol/DiffusionRepositoryClusterEngine.php:398

      }
    } catch (PhutilLockException $ex) {
      throw new PhutilProxyException(
        pht(
          'Failed to acquire write lock after waiting %s second(s). You '.
          'may be able to retry later. (%s)',
          new PhutilNumber($lock_wait),
          $ex->getHint()),
        $ex);
    }

    $versions = PhabricatorRepositoryWorkingCopyVersion::loadVersions(
      $repository_phid);
    foreach ($versions as $version) {
      if (!$version->getIsWriting()) {
        continue;
      }

      throw new Exception(
        pht(
          '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.'));
    }

    $read_wait_start = microtime(true);
    try {
      $max_version = $this->synchronizeWorkingCopyBeforeRead();
    } catch (Exception $ex) {
      $write_lock->unlock();
      throw $ex;
    }
    $read_wait_end = microtime(true);

    $pid = getmypid();
    $hash = Filesystem::readRandomCharacters(12);

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. Identify the frozen device: query phabricator_repository_workingcopyversion for the repository and isWriting = 1
  2. Verify that device's working copy integrity (git fsck / hg verify) and compare its heads against the other cluster devices
  3. Follow 'Write Interruptions' in the Cluster: Repositories documentation to clear the flag, promoting a known-good device and rebuilding the damaged copy if necessary
  4. Prevent recurrence by stopping daemons gracefully (bin/phd stop) instead of killing them during push windows
Defensive patterns

Strategy: try-catch

Validate before calling

// pre-flight: refuse writes if any device reports an interrupted write
$versions = PhabricatorRepositoryWorkingCopyVersion::loadVersions($repository->getPHID());
foreach ($versions as $version) {
  if ($version->getIsWriting()) {
    // fail fast with operator instructions instead of attempting the push
  }
}

Type guard

function repositoryHasInterruptedWrite(array $versions) {
  foreach ($versions as $version) {
    if ($version->getIsWriting()) { return true; }
  }
  return false;
}

Try / catch

try {
  $engine->synchronizeWorkingCopyBeforeWrite();
} catch (Exception $ex) {
  // mark the push permanently failed (not retryable), notify the pusher that operator action is required, alert on-call
}

Prevention

When it happens

Trigger: 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.

Common situations: Aggressive daemon restarts during active push windows; OOM or power loss on a repository node; database flapping while a write is in progress.

Related errors


AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21). Data as JSON: /api/errors/ff0b78f302d2a643. Report an issue: GitHub.