{"record":{"id":"12bd37474755f1a8","repo":"apache/hadoop","slug":"rename-unsuccessful-s-to-s","errorCode":null,"errorMessage":"Rename unsuccessful : '%s' to '%s'","messagePattern":"Rename unsuccessful : '(.+?)' to '(.+?)'","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/key/JavaKeyStoreProvider.java","lineNumber":643,"sourceCode":"      renameOrFail(path, oldPath);\n      return true;\n    } catch (FileNotFoundException e) {\n      return false;\n    }\n  }\n\n  private void revertFromOld(Path oldPath, boolean fileExisted)\n      throws IOException {\n    if (fileExisted) {\n      renameOrFail(oldPath, path);\n    }\n  }\n\n\n  private void renameOrFail(Path src, Path dest)\n      throws IOException {\n    if (!fs.rename(src, dest)) {\n      throw new IOException(\"Rename unsuccessful : \"\n          + String.format(\"'%s' to '%s'\", src, dest));\n    }\n  }\n\n  @Override\n  public String toString() {\n    return uri.toString();\n  }\n\n  /**\n   * The factory to create JksProviders, which is used by the ServiceLoader.\n   */\n  public static class Factory extends KeyProviderFactory {\n    @Override\n    public KeyProvider createProvider(URI providerName,\n                                      Configuration conf) throws IOException {\n      if (SCHEME_NAME.equals(providerName.getScheme())) {\n        return new JavaKeyStoreProvider(providerName, conf);","sourceCodeStart":625,"sourceCodeEnd":661,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/key/JavaKeyStoreProvider.java#L625-L661","documentation":"flush() commits by renaming files: the new store is written to <path>_NEW, the current file is renamed to <path>_OLD, and renameOrFail promotes _NEW onto the live path. fs.rename returned false and the provider converts that into an IOException naming both paths. This is a filesystem-level refusal - typically an existing destination, missing permissions, or non-atomic rename semantics - not an HDFS exception.","triggerScenarios":"A leftover *_NEW or destination file from a crashed flush blocks the rename; no write permission on the keystore's parent directory; two processes flushing the same keystore concurrently; a filesystem (NFS, object-store mount) without POSIX rename guarantees.","commonSituations":"Two daemons sharing one keystore file; keystore directory made read-only; keystore stored on a mount with unusual rename semantics; interrupted process leaving side files behind.","solutions":["Delete stale <keystore>_NEW and <keystore>_OLD files left by an interrupted flush, then retry","Verify write permission on the keystore's parent directory for the running user","Ensure exactly one writer per keystore file; serialize flush across processes","Keep keystores on filesystems with proper rename support (HDFS or local POSIX FS)"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// before flush: clear stale side files from an interrupted run and check dir writability\norg.apache.hadoop.fs.Path p = new org.apache.hadoop.fs.Path(providerUri);\nFileSystem fs = p.getFileSystem(conf);\nfs.delete(new Path(p + \"_NEW\"), false);\nfs.delete(new Path(p + \"_OLD\"), false);","typeGuard":null,"tryCatchPattern":"try { provider.flush(); } catch (IOException e) { if (String.valueOf(e.getMessage()).startsWith(\"Rename unsuccessful\")) { // remove stale _NEW/_OLD, verify parent dir permissions, retry flush once } else { throw e; } }","preventionTips":["One writer per keystore file; serialize flush across processes","After crashes, clean *_NEW/_OLD before next use","Monitor write permissions on the keystore directory","Keep keystores on filesystems with atomic rename support"],"tags":["java","hadoop","filesystem","key-provider","flush","rename"],"backgroundTag":"filesystem-rename-failed","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}