{"record":{"id":"560e8325a93f40bc","repo":"MyCATApache/Mycat-Server","slug":"rehashnodedir-must-be-a-directory","errorCode":null,"errorMessage":"rehashNodeDir must be a directory","messagePattern":"rehashNodeDir must be a directory","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/util/rehasher/RehashLauncher.java","lineNumber":137,"sourceCode":"\t\tdataSource.setDefaultAutoCommit(true);\n\t\tdataSource.setDefaultReadOnly(true);\n\t\tdataSource.setDriverClassName(args.getJdbcDriver());\n\t\tdataSource.setEnable(true);\n\t\tdataSource.setPassword(args.getPassword());\n\t\tdataSource.setTestOnBorrow(true);\n\t\tdataSource.setTestOnReturn(true);\n\t\tdataSource.setTestWhileIdle(true);\n\t\tdataSource.setUrl(args.getJdbcUrl());\n\t\tdataSource.setUsername(args.getUser());\n\t}\n\t\n\tprivate RehashLauncher execute() throws IOException{\n\t\tfinal String[] tables=args.getTables();\n\t\tfinal File outputDir=new File(args.getRehashNodeDir());\n\t\tif(!outputDir.exists()){\n\t\t\toutputDir.mkdirs();\n\t\t}else if(outputDir.isFile()){\n\t\t\tthrow new IllegalArgumentException(\"rehashNodeDir must be a directory\");\n\t\t}else if(outputDir.canWrite()){\n\t\t\tthrow new IllegalArgumentException(\"rehashNodeDir must be writable\");\n\t\t}\n\t\tlatch=new CountDownLatch(tables.length);\n\t\tfor(int i=0,l=tables.length;i<l;i++){\n\t\t\tfinal int tableIdx=i;\n\t\t\tfinal String table=tables[tableIdx];\n\t\t\tfinal File output=new File(outputDir,table);\n\t\t\tif(output.exists()){\n\t\t\t\toutput.delete();\n\t\t\t}\n\t\t\toutput.createNewFile();\n\t\t\texecutor.execute(new RehashRunner(output, table));\n\t\t}\n\t\treturn this;\n\t}\n\t\n\tprivate void shutdown(){","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/util/rehasher/RehashLauncher.java#L119-L155","documentation":"RehashLauncher.execute() validates the configured rehashNodeDir before starting the rehash workers. If the path already exists but is a regular file rather than a directory, it throws IllegalArgumentException. This is an upfront configuration sanity check so worker output files are never written into an invalid path.","triggerScenarios":"Launching rehash with a rehashNodeDir property pointing at an existing file (e.g. a previously created tarball, log file, or an accidentally created plain file at that path).","commonSituations":"A previous failed run created rehashNodeDir as a file, the user pointed the config at a file path by typo, or the path was reused for a different artifact.","solutions":["Delete or rename the file at the configured rehashNodeDir path so the launcher can create a directory there.","Correct the rehashNodeDir value in the rehash config to point to a directory (or a nonexistent path that can be created).","Re-run the rehash launch after fixing the path."],"exampleFix":"// before\nrehashNodeDir=/opt/mycat/rehash-output.zip\n// after\nrehashNodeDir=/opt/mycat/rehash-output\n# and on the shell:\n# rm /opt/mycat/rehash-output.zip","handlingStrategy":"validation","validationCode":"File dir = new File(args.getRehashNodeDir());\nif (dir.isFile()) throw new IllegalStateException(\"rehashNodeDir is a file: \" + dir);\nif (!dir.exists() && !dir.mkdirs()) throw new IllegalStateException(\"cannot create \" + dir);","typeGuard":null,"tryCatchPattern":"try {\n  RehashLauncher.launch(args);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"must be a directory\")) {\n    new File(args.getRehashNodeDir()).delete(); // remove offending file, then retry\n  }\n}","preventionTips":["Check the rehashNodeDir path with ls before launching rehash.","Never reuse the rehashNodeDir path for archives or logs.","Validate the rehash config file as part of deployment."],"tags":["configuration","filesystem","rehash","illegal-argument"],"backgroundTag":"path-is-not-a-directory","analyzedSha":"65f8d8beb752f935752f2a0eec0ab017facab9ef","analyzedAt":"2026-09-11T00:12:21.696Z","contentChangedAt":"2026-09-11T00:12:21.696Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}