{"record":{"id":"6e6dcddfddf19490","repo":"MyCATApache/Mycat-Server","slug":"e-6e6dcd","errorCode":null,"errorMessage":"${e}","messagePattern":"\\$\\{e\\}","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"critical","filePath":"src/main/java/io/mycat/migrate/MigrateDumpRunner.java","lineNumber":220,"sourceCode":"            } else {\n                whereList.add(\"(_slot >=\" + slotRange.start + \" and _slot <=\" + slotRange.end + \")\");\n            }\n        }\n\n        return Joiner.on(\" or  \").join(whereList);\n    }\n\n    private static String querySecurePath(DBHostConfig config) {\n        List<Map<String, Object>> list = null;\n        String path = null;\n        Connection con = null;\n        try {\n            con = DriverManager.getConnection(\"jdbc:mysql://\" + config.getUrl(), config.getUser(), config.getPassword());\n            list = executeQuery(con, \"show variables like 'secure_file_priv'\");\n            if (list != null && list.size() == 1)\n                path = (String) list.get(0).get(\"Value\");\n        } catch (SQLException e) {\n            throw new RuntimeException(e);\n        } finally {\n            JdbcUtils.close(con);\n        }\n        return path;\n    }\n\n    public static void main(String[] args) {\n        String result = \"\\n\" + \"--\\n\" + \"-- Position to start replication or point-in-time recovery from\\n\" + \"--\\n\"\n                + \"\\n\" + \"CHANGE MASTER TO MASTER_LOG_FILE='NANGE-PC-bin.000021', MASTER_LOG_POS=154;\\n\";\n        int logIndex = result.indexOf(\"MASTER_LOG_FILE='\");\n        int logPosIndex = result.indexOf(\"MASTER_LOG_POS=\");\n        String logFile = result.substring(logIndex + 17, logIndex + 17 + result.substring(logIndex + 17).indexOf(\"'\"));\n        String logPos = result.substring(logPosIndex + 15, logPosIndex + 15 + result.substring(logPosIndex + 15).indexOf(\";\"));\n        System.out.println(logFile + logPos);\n    }\n}\n","sourceCodeStart":202,"sourceCodeEnd":237,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/migrate/MigrateDumpRunner.java#L202-L237","documentation":"querySecurePath runs 'show variables like secure_file_priv' to discover where MySQL permits LOAD DATA/SELECT INTO OUTFILE files. A SQLException during the connection or query is rethrown as a RuntimeException, failing the dump runner before migration can proceed.","triggerScenarios":"DriverManager.getConnection(config.getUrl()) fails (bad URL, auth, network); 'show variables like secure_file_priv' is rejected or the connection drops; the result set lacks the expected 'Value' row.","commonSituations":"MySQL 5.6- and MariaDB without the secure_file_priv variable (list is empty, path stays null and later file operations fail); wrong JDBC URL in config; the migration user cannot execute SHOW VARIABLES.","solutions":["Check config.getUrl(), user and password resolve to a reachable MySQL server.","Confirm the server supports secure_file_priv (MySQL >= 5.7.6); check with SHOW VARIABLES LIKE 'secure_file_priv'.","Inspect the wrapped SQLException in the stack trace for the root cause (timeout, access denied, unknown host).","If the variable is absent on your server, set a path manually or upgrade MySQL so OUTFILE-based transfer works."],"exampleFix":"// before\ncon = DriverManager.getConnection(\"jdbc:mysql://\" + config.getUrl(), config.getUser(), config.getPassword());\n// after\ntry (Connection con = DriverManager.getConnection(\"jdbc:mysql://\" + config.getUrl(), config.getUser(), config.getPassword())) {\n    // wrap the RuntimeException with context\n} catch (SQLException e) {\n    throw new RuntimeException(\"Failed to query secure_file_priv from \" + config.getUrl(), e);\n}","handlingStrategy":"validation","validationCode":"// before running dump\nClass.forName(\"com.mysql.jdbc.Driver\");\ntry (Connection c = DriverManager.getConnection(\"jdbc:mysql://\" + config.getUrl(), config.getUser(), config.getPassword())) {\n    ResultSet rs = c.createStatement().executeQuery(\"SHOW VARIABLES LIKE 'secure_file_priv'\");\n    if (!rs.next()) throw new IllegalStateException(\"secure_file_priv unsupported/absent\");\n}","typeGuard":null,"tryCatchPattern":"try { spath(); } catch (RuntimeException e) {\n    if (e.getCause() instanceof java.sql.SQLException sql) {\n        // log sql.getErrorCode()/getSQLState(), decide retry vs abort\n    }\n    throw e;\n}","preventionTips":["Test the JDBC URL with a plain mysql client before migration","Require MySQL >= 5.7.6 so secure_file_priv exists","Run SHOW VARIABLES check as a preflight in CI","Keep migration user privileges minimal but sufficient (SHOW VARIABLES, file ops)"],"tags":["jdbc","mysql","sql-exception","migration"],"backgroundTag":"database-query-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"}