{"record":{"id":"4a6aeeee071f1293","repo":"MyCATApache/Mycat-Server","slug":"txisolation-txisolation-4a6aee","errorCode":null,"errorMessage":"txIsolation:${txIsolation}","messagePattern":"txIsolation:(.+?)","errorType":"exception","errorClass":"UnknownTxIsolationException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/backend/postgresql/PostgreSQLBackendConnection.java","lineNumber":125,"sourceCode":"\t * @param\n\t * @param txIsolation\n\t */\n\tprivate static void getTxIsolationCommand(StringBuilder sb, int txIsolation) {\n\t\tswitch (txIsolation) {\n\t\tcase Isolations.READ_UNCOMMITTED:\n\t\t\tsb.append(\"SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;\");\n\t\t\treturn;\n\t\tcase Isolations.READ_COMMITTED:\n\t\t\tsb.append(\"SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;\");\n\t\t\treturn;\n\t\tcase Isolations.REPEATED_READ:\n\t\t\tsb.append(\"SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;\");\n\t\t\treturn;\n\t\tcase Isolations.SERIALIZABLE:\n\t\t\tsb.append(\"SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;\");\n\t\t\treturn;\n\t\tdefault:\n\t\t\tthrow new UnknownTxIsolationException(\"txIsolation:\" + txIsolation);\n\t\t}\n\t}\n\n\tprivate Object attachment;\n\n\tprivate volatile boolean autocommit=true;\n\n\tprivate volatile boolean txReadonly=false;\n\n\tprivate volatile boolean borrowed;\n\n\tprotected volatile String charset = \"utf8\";\n\n\n\t/***\n\t * 当前事物ID\n\t */\n\tprivate volatile String currentXaTxId;","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/backend/postgresql/PostgreSQLBackendConnection.java#L107-L143","documentation":"PostgreSQLBackendConnection.getTxIsolationCommand() builds a 'SET SESSION TRANSACTION ISOLATION LEVEL ...' command from the configured txIsolation value. Only READ_UNCOMMITTED/READ_COMMITTED/REPEATABLE_READ/SERIALIZABLE are mapped; any other integer (including PG-specific constants outside the Isolations table) hits the default branch and throws UnknownTxIsolationException(\"txIsolation:\" + txIsolation).","triggerScenarios":"A backend connection is created/used with a txIsolation value that is not one of the four supported Isolations constants — typically a bad value in the transactionIsolation config, or a caller passing a JDBC constant MyCat's Isolations table does not recognize.","commonSituations":"Typo'd or out-of-range isolation level in the dataHost/schema config; frontend session isolation mapped incorrectly to the backend; code that passes e.g. TRANSACTION_NONE or a driver-specific constant into the PG backend connection.","solutions":["Set transactionIsolation to a supported value (1=READ_UNCOMMITTED, 2=READ_COMMITTED, 4=REPEATABLE_READ, 8=SERIALIZABLE) in the dataHost config","Log/capture the offending txIsolation value from the exception message and correct the caller that set it","Upgrade/patch MyCat to map PostgreSQL's own isolation constants in getTxIsolationCommand","If you need READ COMMITTED behavior, use isolation 2 rather than driver-specific values"],"exampleFix":"// before\n<dataHost ... transactionIsolation=\"3\">\n// after\n<dataHost ... transactionIsolation=\"2\">","handlingStrategy":"validation","validationCode":"int tx = getTxIsolation();\nif (tx != 1 && tx != 2 && tx != 4 && tx != 8) {\n    throw new IllegalArgumentException(\"txIsolation \" + tx + \" unsupported by PG backend; use 1/2/4/8\");\n}","typeGuard":null,"tryCatchPattern":"try { conn.execute(sql); } catch (UnknownTxIsolationException e) { /* correct transactionIsolation config from e.getMessage() and retry */ }","preventionTips":["Set transactionIsolation only to 1/2/4/8 in dataHost config","Map driver-specific isolation constants before passing them to MyCat","Validate isolation config at startup, not first query"],"tags":["postgresql","isolation","config","transaction"],"backgroundTag":"invalid-enum-value","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"}