{"record":{"id":"b5235e4416b2aba3","repo":"phacility/phabricator","slug":"failed-to-close-file-s-b5235e","errorCode":null,"errorMessage":"Failed to close file \"%s\".","messagePattern":"Failed to close file \"(.+?)\"\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/infrastructure/storage/management/workflow/PhabricatorStorageManagementRenamespaceWorkflow.php","lineNumber":189,"sourceCode":"        }\n\n        if ($bytes !== strlen($data)) {\n          throw new Exception(\n            pht(\n              'Failed to write %d byte(s) to \"%s\".',\n              new PhutilNumber(strlen($data)),\n              $output_name));\n        }\n      }\n\n      if ($is_compress) {\n        $ok = gzclose($file);\n      } else {\n        $ok = fclose($file);\n      }\n\n      if ($ok !== true) {\n        throw new Exception(\n          pht(\n            'Failed to close file \"%s\".',\n            $output_file));\n      }\n    } catch (Exception $ex) {\n      try {\n        if ($output_file !== null) {\n          Filesystem::remove($output_file);\n        }\n      } catch (Exception $ex) {\n        // Ignore any exception.\n      }\n\n      throw $ex;\n    }\n\n    // Give the user a chance to catch things if the results are crazy.\n    $console->writeErr(","sourceCodeStart":171,"sourceCodeEnd":207,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/infrastructure/storage/management/workflow/PhabricatorStorageManagementRenamespaceWorkflow.php#L171-L207","documentation":"Closing the output failed: fclose/gzclose did not return true. With buffered writes, the close is where an out-of-space condition or I/O error often surfaces, after individual writes appeared to succeed. The workflow throws, and its exception handler removes the incomplete output file, so no truncated dump survives.","triggerScenarios":"Disk or quota exhausted exactly at flush time; NFS or FUSE filesystems failing the final flush; a medium or filesystem error on close.","commonSituations":"Output on NFS with quotas; small tmpfs targets; per-user quotas enforced at flush; marginal or failing disks.","solutions":["Free space on the target filesystem and re-run the whole command — the partial file was removed automatically.","Write --output to reliable local disk, then copy the finished file to network storage.","If it recurs on the same device, suspect the medium or filesystem (check dmesg, consider fsck)."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  // run the renamespace workflow\n} catch (Exception $ex) {\n  // close failed; partial output was removed — free space before retrying\n  fwrite(STDERR, $ex->getMessage().\"\\n\");\n  exit(1);\n}","preventionTips":["Avoid NFS/tmpfs destinations for dump-sized outputs.","Keep headroom of at least the expected dump size on the output volume.","After every run, verify the output file exists and has the expected size."],"tags":["phabricator","bin-storage","renamespace","file-io","disk-full","nfs"],"backgroundTag":"close-flush-failure","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}