Skip to content

Commit 9e4208c

Browse files
authored
Merge pull request osheroff#23 from morozov/DBZ-2499
DBZ-2499: Debezium Connectors are failing while reading binlog: Unknown event type 100
2 parents 8204086 + 9e2fb39 commit 9e4208c

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

src/main/java/com/github/shyiko/mysql/binlog/event/deserialization/EventHeaderV4Deserializer.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ public EventHeaderV4 deserialize(ByteArrayInputStream inputStream) throws IOExce
4040
return header;
4141
}
4242

43-
private static EventType getEventType(int ordinal) throws IOException {
43+
private static EventType getEventType(int ordinal) {
4444
if (ordinal >= EVENT_TYPES.length) {
45-
throw new IOException("Unknown event type " + ordinal);
45+
return EventType.UNKNOWN;
4646
}
4747
return EVENT_TYPES[ordinal];
4848
}

src/test/java/com/github/shyiko/mysql/binlog/BinaryLogFileReaderIntegrationTest.java

+31
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
import static org.testng.Assert.assertEquals;
3232
import static org.testng.Assert.assertFalse;
33+
import static org.testng.Assert.assertNotNull;
3334
import static org.testng.Assert.assertNull;
3435
import static org.testng.Assert.assertTrue;
3536

@@ -70,6 +71,36 @@ public void testChecksumCRC32WithCustomEventDataDeserializer() throws Exception
7071
readAll(reader, 303);
7172
}
7273

74+
@Test
75+
public void testUnsupportedEventType() throws Exception {
76+
EventDeserializer eventDeserializer = new EventDeserializer();
77+
78+
// mysql> SHOW BINLOG EVENTS IN 'mysql-bin.aurora-padding';
79+
// +--------------------------+------+----------------+-------------+---------------------------------------+
80+
// | Log_name | Pos | Event_type | End_log_pos | Info |
81+
// +--------------------------+------+----------------+-------------+---------------------------------------+
82+
// | mysql-bin.aurora-padding | 4 | Format_desc | 185 | Server ver: 5.7.12-log, Binlog ver: 4 |
83+
// | mysql-bin.aurora-padding | 185 | Previous_gtids | 216 | |
84+
// | mysql-bin.aurora-padding | 216 | Anonymous_Gtid | 281 | SET @@SESSION.GTID_NEXT= 'ANONYMOUS' |
85+
// | mysql-bin.aurora-padding | 281 | Aurora_padding | 1209 | Ignorable |
86+
// | mysql-bin.aurora-padding | 1209 | Query | 1294 | BEGIN |
87+
BinaryLogFileReader reader = new BinaryLogFileReader(
88+
new FileInputStream("src/test/resources/mysql-bin.aurora-padding"), eventDeserializer);
89+
try {
90+
for (int i = 0; i < 3; i++) {
91+
assertNotNull(reader.readEvent());
92+
}
93+
try {
94+
reader.readEvent();
95+
} catch (IOException e) {
96+
// this simulates the Debezium's event.processing.failure.handling.mode = warn
97+
}
98+
assertEquals(reader.readEvent().getHeader().getEventType(), EventType.QUERY);
99+
} finally {
100+
reader.close();
101+
}
102+
}
103+
73104
private void readAll(BinaryLogFileReader reader, int expect) throws IOException {
74105
try {
75106
int numberOfEvents = 0;
1.26 KB
Binary file not shown.

0 commit comments

Comments
 (0)