Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] NullPointerException when parsing the table_map event #2001

Closed
2 tasks done
ruanhang1993 opened this issue Mar 15, 2023 · 7 comments · Fixed by #2004
Closed
2 tasks done

[Bug] NullPointerException when parsing the table_map event #2001

ruanhang1993 opened this issue Mar 15, 2023 · 7 comments · Fixed by #2004
Labels
bug Something isn't working

Comments

@ruanhang1993
Copy link
Contributor

Search before asking

  • I searched in the issues and found nothing similar.

Flink version

1.15.2

Flink CDC version

2.3.0

Database and its version

mysql 8.0.18

Minimal reproduce step

This error occurs when parsing the binlog.

What did you expect to see?

The job runs normally.

What did you see instead?

Caused by: com.ververica.cdc.connectors.shaded.org.apache.kafka.connect.errors.ConnectException: An exception occurred in the change event producer. This connector will be stopped.
    at io.debezium.pipeline.ErrorHandler.setProducerThrowable(ErrorHandler.java:42)
    at com.ververica.cdc.connectors.mysql.debezium.task.context.MySqlErrorHandler.setProducerThrowable(MySqlErrorHandler.java:89)
    at io.debezium.connector.mysql.MySqlStreamingChangeEventSource$ReaderThreadLifecycleListener.onEventDeserializationFailure(MySqlStreamingChangeEventSource.java:1452)
    at com.github.shyiko.mysql.binlog.BinaryLogClient.listenForEventPackets(BinaryLogClient.java:965)
    at com.github.shyiko.mysql.binlog.BinaryLogClient.connect(BinaryLogClient.java:599)
    at com.github.shyiko.mysql.binlog.BinaryLogClient$7.run(BinaryLogClient.java:857)
    ... 1 more
Caused by: io.debezium.DebeziumException
    at io.debezium.connector.mysql.MySqlStreamingChangeEventSource.wrap(MySqlStreamingChangeEventSource.java:1387)
    ... 5 more
Caused by: java.lang.NullPointerException
    at com.github.shyiko.mysql.binlog.event.deserialization.TableMapEventDataDeserializer.readMetadata(TableMapEventDataDeserializer.java:81)
    at com.github.shyiko.mysql.binlog.event.deserialization.TableMapEventDataDeserializer.deserialize(TableMapEventDataDeserializer.java:42)
    at com.github.shyiko.mysql.binlog.event.deserialization.TableMapEventDataDeserializer.deserialize(TableMapEventDataDeserializer.java:27)
    at com.github.shyiko.mysql.binlog.event.deserialization.EventDeserializer.deserializeEventData(EventDeserializer.java:303)
    at com.github.shyiko.mysql.binlog.event.deserialization.EventDeserializer.deserializeTableMapEventData(EventDeserializer.java:281)
    at com.github.shyiko.mysql.binlog.event.deserialization.EventDeserializer.nextEvent(EventDeserializer.java:228)
    at io.debezium.connector.mysql.MySqlStreamingChangeEventSource$1.nextEvent(MySqlStreamingChangeEventSource.java:259)
    at com.github.shyiko.mysql.binlog.BinaryLogClient.listenForEventPackets(BinaryLogClient.java:952)
    ... 3 more

Anything else?

No response

Are you willing to submit a PR?

  • I'm willing to submit a PR!
@ruanhang1993 ruanhang1993 added the bug Something isn't working label Mar 15, 2023
@ruanhang1993
Copy link
Contributor Author

The binlog client can not find the column type 20 in its ColumnType class, which is MYSQL_TYPE_TYPED_ARRAY.
MySQL 8.0.18+ change the MYSQL_TYPE_TYPED_ARRAY to 20, see mysql/mysql-server@9082b6a.

@ruanhang1993
Copy link
Contributor Author

I have raised a PR to fix this in the mysql-binlog-connector-java(osheroff/mysql-binlog-connector-java#104).

@racoon945
Copy link

I have raised a PR to fix this in the mysql-binlog-connector-java(osheroff/mysql-binlog-connector-java#104).

@ruanhang1993
Hi , I have added the code you PR into the project. The NPE issue has been resolved, but a new error has emerged now.

mysql version = 8.0.18

Caused by: io.debezium.DebeziumException: Failed to deserialize data of EventHeaderV4{timestamp=1679640836000, eventType=TABLE_MAP, serverId=1704062425, headerLength=19, dataLength=89, nextPosition=359034816, flags=0}
	at io.debezium.connector.mysql.MySqlStreamingChangeEventSource.wrap(MySqlStreamingChangeEventSource.java:1154)
	... 5 more
Caused by: com.github.shyiko.mysql.binlog.event.deserialization.EventDataDeserializationException: Failed to deserialize data of EventHeaderV4{timestamp=1679640836000, eventType=TABLE_MAP, serverId=1704062425, headerLength=19, dataLength=89, nextPosition=359034816, flags=0}
	at com.github.shyiko.mysql.binlog.event.deserialization.EventDeserializer.deserializeEventData(EventDeserializer.java:309)
	at com.github.shyiko.mysql.binlog.event.deserialization.EventDeserializer.deserializeTableMapEventData(EventDeserializer.java:281)
	at com.github.shyiko.mysql.binlog.event.deserialization.EventDeserializer.nextEvent(EventDeserializer.java:228)
	at io.debezium.connector.mysql.MySqlStreamingChangeEventSource$1.nextEvent(MySqlStreamingChangeEventSource.java:230)
	at com.github.shyiko.mysql.binlog.BinaryLogClient.listenForEventPackets(BinaryLogClient.java:952)
	... 3 more
Caused by: java.io.IOException: Unsupported table metadata field type 216
	at com.github.shyiko.mysql.binlog.event.deserialization.TableMapEventMetadataDeserializer.deserialize(TableMapEventMetadataDeserializer.java:52)
	at com.github.shyiko.mysql.binlog.event.deserialization.TableMapEventDataDeserializer.deserialize(TableMapEventDataDeserializer.java:59)
	at com.github.shyiko.mysql.binlog.event.deserialization.TableMapEventDataDeserializer.deserialize(TableMapEventDataDeserializer.java:37)
	at com.github.shyiko.mysql.binlog.event.deserialization.EventDeserializer.deserializeEventData(EventDeserializer.java:303)
	... 7 more

@racoon945
Copy link

I found that the problematic table statement appears here.

ALTER TABLE `my_table`
    ADD INDEX `k_source` ((CAST(`source` -> '$[*].code' AS char(10) ARRAY)));

We have used a new index type introduced in MySQL 8.0: multi-value index.
My current approach is to ignore the binlog of the problematic table.

@leonardBang
Copy link
Contributor

@ruanhang1993 Could you take a look @racoon945 's case ?

@leonardBang
Copy link
Contributor

I think we need consider @racoon945 's input, but we can create a new issue to track and fix it.
CC: @ruanhang1993

@ruanhang1993
Copy link
Contributor Author

@racoon945 I add a test but cannot reproduce the error #2192 . Would you mind taking a look at the test?

fuyun2024 added a commit to fuyun2024/flink-cdc-connectors that referenced this issue Jun 8, 2023
commit 7ced72b6426e9723f91933ef0144fdda4b9c072d
Author: Hang Ruan <ruanhang1993@hotmail.com>
Date:   Thu Jun 8 17:01:39 2023 +0800

    [mysql-cdc] Supports MYSQL_TYPE_TYPED_ARRAY column type when parsing the table map event

    This closes apache#2001

commit a847655ed68c4d5874ced69006686362f23140e7
Author: Leonard Xu <leonard@apache.org>
Date:   Thu Jun 8 15:33:54 2023 +0800

    [mysql-cdc][hotfix] Optimize the error msg when binlog expire in source

commit 32f77ef0075dfd2b522df07809ab2aea8ae6de54
Author: Leonard Xu <leonard@apache.org>
Date:   Wed Jun 7 17:49:41 2023 +0800

    [mysql-cdc] Optimize the error msg when binlog expire or server id conflict
     This closes apache#2010.

commit da5cbf54e6b219956088bb99cec44d93f1011ff7
Author: He Wang <wanghechn@qq.com>
Date:   Thu Jun 8 13:50:24 2023 +0800

    [oceanbase] add jdbc options and support oracle mode (apache#1854)

commit 0e221382601e352215091d9cd1cb59fa2175063b
Author: Leonard Xu <leonard@apache.org>
Date:   Wed Jun 7 17:34:57 2023 +0800

    [mysql-cdc] Add handler for catching async exceptions in snapshot reading executor
    This closes apache#2016.

commit 15e5e4d34dc05edcbdcfe15ff906213352a2cd02
Author: Hang Ruan <ruanhang1993@hotmail.com>
Date:   Wed Jun 7 17:26:59 2023 +0800

    [hotfix][mysql-cdc] Use session timezone instead of local time zone as the default server time zone

    This closes apache#2015.

commit 13235e2f2dca73320988a430b765f1fafa8e8f26
Author: Hang Ruan <ruanhang1993@hotmail.com>
Date:   Wed Jun 7 17:22:07 2023 +0800

    [mysql] Fix NullPointerException when database name or table name contains dot

    This closes apache#2006.

commit 6aa0fc4de353473cb7cda844a432e3dd5ddf4fea
Author: Hang Ruan <ruanhang1993@hotmail.com>
Date:   Thu Jan 12 02:18:52 2023 +0000

    [mysql] Fix NullPointerException caused by mysql ignores the capitalization when splitting chunks

commit e9fed740f55f7f1e675e5fe83f7e04efb5e3f866
Author: ehui <374488688@qq.com>
Date:   Tue Jun 6 13:06:03 2023 +0800

    [sqlserver] Fix old change data that will be captured when the latest mode starts (apache#2176)

commit d2ffa0902038e9aec0e2b92fa4e82a066d1b123f
Author: Tyrantlucifer <tyrantlucifer@apache.org>
Date:   Mon Jun 5 23:15:33 2023 +0800

    [core] support print configuration options for connectors (apache#2099)

commit a00abf88178feb6a2c699129e1f6aefb005960c7
Author: He Wang <wanghechn@qq.com>
Date:   Mon Jun 5 16:40:54 2023 +0800

    [oceanbase] support libobcdc 4.x and fix restore timestamp config (apache#2161)

commit 061602d
Author: ehui <374488688@qq.com>
Date:   Mon Jun 5 23:49:15 2023 +0800

    oralce

commit 8dc46cc
Author: ehui <374488688@qq.com>
Date:   Mon Jun 5 00:18:50 2023 +0800

    [oracle]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants