{"record":{"id":"9adb245f84e964a5","repo":"MyCATApache/Mycat-Server","slug":"unknown-packet-9adb24","errorCode":null,"errorMessage":"Unknown packet","messagePattern":"Unknown packet","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/backend/postgresql/utils/PacketUtils.java","lineNumber":75,"sourceCode":"\t\t\tcase 'D':\n\t\t\t\tpg = DataRow.parse(bytes, offset);\n\t\t\t\tbreak;\n\n\t\t\tcase 'I':\n\t\t\t\tpg = EmptyQueryResponse.parse(bytes, offset);\n\t\t\t\tbreak;\n\n\t\t\tcase 'G':\n\t\t\t\tpg = CopyInResponse.parse(bytes, offset);\n\t\t\t\tbreak;\n\t\t\tcase 'H':\n\t\t\t\tpg = CopyOutResponse.parse(bytes, offset);\n\t\t\t\tbreak;\n\t\t\tcase '1':\n\t\t\t\tpg = ParseComplete.parse(bytes, offset);\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new RuntimeException(\"Unknown packet\");\n\t\t\t}\n\t\t\tif (pg != null) {\n\t\t\t\toffset = offset + pg.getLength() + 1;\n\t\t\t\tpgs.add(pg);\n\t\t\t}\n\t\t\t\n\t\t}\n\t\treturn pgs;\n\t}\n\t\n\t@Deprecated\n\tprivate static List<PostgreSQLPacket> parsePacket(byte[] bytes, int offset,\n\t\t\tint readLength) throws IOException {\n\t\tList<PostgreSQLPacket> pgs = new ArrayList<>();\n\t\twhile (offset < readLength) {\n\t\t\tchar MAKE = (char) bytes[offset];\n\t\t\tPostgreSQLPacket pg = null;\n\t\t\tswitch (MAKE) {","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/backend/postgresql/utils/PacketUtils.java#L57-L93","documentation":"PacketUtils.parsePacket(byte[], int) parses a stream of PostgreSQL backend messages by their leading type byte, dispatching to parsers like AuthenticationRequest, DataRow, CopyOutResponse, ParseComplete. A type byte with no case in the switch hits default and throws RuntimeException(\"Unknown packet\").","triggerScenarios":"The PostgreSQL server sends a message type (e.g. 'N' NOTICE, 'S' ParameterStatus, 'K' BackendKeyData, 'A' NotificationResponse, 'G' CopyInResponse, extended-protocol frames) that this byte[]-based switch does not handle.","commonSituations":"PG servers emitting frequent notices/parameter-status updates; applications using LISTEN/NOTIFY; extended query protocol (Parse/Bind) sessions; mismatched PG server version emitting messages the old MyCat parser lacks.","solutions":["Add a case for the unknown type byte (from the MyCat log / PG protocol docs) parsing the corresponding packet class","Upgrade MyCat to a version with a more complete PG packet parser","Patch parsePacket to skip unknown message types gracefully using pg.getLength() instead of throwing","Avoid triggering paths that emit unhandled messages (e.g. disable client-side notices, avoid LISTEN/NOTIFY through MyCat)"],"exampleFix":"// before\ndefault:\n    throw new RuntimeException(\"Unknown packet\");\n// after\ncase 'S':\n    pg = ParameterStatus.parse(bytes, offset);\n    break;\ndefault:\n    LOGGER.warn(\"Unknown packet type: \" + (char) bytes[offset]);\n    break;","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { packets = PacketUtils.parsePacket(bytes, offset); } catch (RuntimeException e) { if (\"Unknown packet\".equals(e.getMessage())) { /* log first type byte, skip or upgrade parser */ } else { throw e; } }","preventionTips":["Route only message types the parser knows through MyCat PG backend","Suppress server notices and avoid LISTEN/NOTIFY via MyCat","Log the unknown type byte to extend the parser quickly"],"tags":["postgresql","protocol","packet","parser"],"backgroundTag":"unexpected-response-shape","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"}