{"record":{"id":"a31d067a599cd3ed","repo":"MyCATApache/Mycat-Server","slug":"write-file-err-e","errorCode":null,"errorMessage":"write file err \" + e","messagePattern":"write file err \" \\+ e","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/manager/handler/ConfFileHandler.java","lineNumber":207,"sourceCode":"\t\tLOGGER.info(\"Upload Daas Config file \" + fileName + \" ,content:\"\n\t\t\t\t+ content);\n\t\tString tempFileName = System.currentTimeMillis() + \"_\" + fileName;\n\t\tFile tempFile = new File(SystemConfig.getHomePath(), \"conf\"\n\t\t\t\t+ File.separator + tempFileName);\n\t\tBufferedOutputStream buff = null;\n\t\tboolean suc = false;\n\t\ttry {\n\t\t\tbyte[] fileData = content.getBytes(\"UTF-8\");\n\t\t\tif (fileName.endsWith(\".xml\")) {\n\t\t\t\tcheckXMLFile(fileName, fileData);\n\t\t\t}\n\t\t\tbuff = new BufferedOutputStream(new FileOutputStream(tempFile));\n\t\t\tbuff.write(fileData);\n\t\t\tbuff.flush();\n\n\t\t} catch (Exception e) {\n\t\t\tLOGGER.warn(\"write file err \" + e);\n\t\t\treturn showInfo(c, buffer, packetId, \"write file err \" + e);\n\n\t\t} finally {\n\t\t\tif (buff != null) {\n\t\t\t\ttry {\n\t\t\t\t\tbuff.close();\n\t\t\t\t\tsuc = true;\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\tLOGGER.warn(\"save config file err \" + e);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (suc) {\n\t\t\t// if succcess\n\t\t\tFile oldFile = new File(SystemConfig.getHomePath(), \"conf\"\n\t\t\t\t\t+ File.separator + fileName);\n\t\t\tif (oldFile.exists()) {\n\t\t\t\tFile backUP = new File(SystemConfig.getHomePath(), \"conf\"\n\t\t\t\t\t\t+ File.separator + fileName + \"_\"","sourceCodeStart":189,"sourceCodeEnd":225,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/manager/handler/ConfFileHandler.java#L189-L225","documentation":"ConfFileHandler.upLoadConfigFile writes an uploaded config file's bytes to a temp file in the MyCat conf directory. If any exception occurs while opening or writing the file, it logs a warning and replies to the manager client with a 'write file err <exception>' error message instead of applying the config. The exception text is passed straight through to the client.","triggerScenarios":"Uploading a config file via the manager port when the target directory is not writable, the disk is full, the temp file cannot be created, or the upload payload is bad.","commonSituations":"MyCat process lacks write permission on the conf directory, running in a read-only container filesystem, disk quota exceeded, or uploading to a wrong/unwritable configured file path.","solutions":["Read the exception detail in the manager response; fix that cause first (usually permissions on the conf directory).","chown/chmod the MyCat conf directory so the running user can write (e.g. chown -R mycat:mycat conf).","Check free disk space and quota on the partition holding conf.","Retry the upload after fixing; verify the file content is valid before applying."],"exampleFix":"// shell fix\n// before: drwxr-x--- root root /opt/mycat/conf\n// after:\n// chown mycat:mycat /opt/mycat/conf && chmod u+rwx /opt/mycat/conf","handlingStrategy":"try-catch","validationCode":"File dir = new File(confPath).getParentFile();\nif (!dir.isDirectory() || !dir.canWrite()) return \"conf dir not writable: \" + dir;\nif (fileData == null || fileData.length == 0) return \"empty upload payload\";","typeGuard":null,"tryCatchPattern":"// manager client side: parse the OK/ERR packet\nif (resp.startsWith(\"write file err\")) {\n  logger.error(\"config upload failed: {}\", resp.substring(\"write file err\".length()));\n}","preventionTips":["Ensure the MyCat process user owns the conf directory.","Monitor disk space on the conf partition.","Validate file content before uploading config changes."],"tags":["manager","file-upload","file-write","configuration"],"backgroundTag":"file-write-failed","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"}