osheroff / mysql-binlog-connector-java

MySQL Binary Log connector
678 stars 166 forks source link

BinaryLogClient auto detects wrongly MariaDB instead of MySQL #81

Open bdeneuter opened 2 years ago

bdeneuter commented 2 years ago

Hi,

With version 0.27.1, the BinaryLogClient tries to detect if the GtidSet is a MariaDB GtidSet or not. It uses the pattern ^\d+-\d+-\d+ to detect this. We are using MySQL 8.0 and have a GtidSet that matches this pattern. So the client thinks it is a MariaDb GtidSet and crashes when it connects because it is not MariaDb but MySQL 8.0. Our MySQL GtidSet is the following: 07212070-4330-3bc8-8a3a-01e34be47bc3:1-141692942,a0c4a949-fae8-30f3-a4d2-fee56a1a9307:1-1427643460,a16ef643-1d4a-3fd9-a86e-1adeb836eb2d:1-1411988930,b0d822f4-5a84-30d3-a929-61f64740d7ac:1-59364

As we know that we are connecting to MySQL, can we avoid auto detection and specify to the BinaryLogClient that it needs to use MySQL and not MariaDB? I don't see the need for auto detection as the user from the library knows to which database he/she connects.

The exception we see in the logs:

java.lang.NumberFormatException: For input string: "3bc8" at java.base/java.lang.NumberFormatException.forInputString(Unknown Source) at java.base/java.lang.Long.parseLong(Unknown Source) at java.base/java.lang.Long.parseLong(Unknown Source) at com.github.shyiko.mysql.binlog.MariadbGtidSet$MariaGtid.(MariadbGtidSet.java:185) at com.github.shyiko.mysql.binlog.MariadbGtidSet$MariaGtid.parse(MariadbGtidSet.java:189) at com.github.shyiko.mysql.binlog.MariadbGtidSet.(MariadbGtidSet.java:39) at com.github.shyiko.mysql.binlog.BinaryLogClient.setGtidSet(BinaryLogClient.java:355)

osheroff commented 2 years ago

lemme fix the regex.

bdeneuter commented 2 years ago

@osheroff I created also a PR with a fix: https://github.com/osheroff/mysql-binlog-connector-java/pull/84 My fix verifies that there is no :. I think MySQL Gtid has always a :. https://dev.mysql.com/doc/refman/8.0/en/replication-gtids-concepts.html

megatron10 commented 2 months ago

I think @osheroff has already fixed this: https://github.com/osheroff/mysql-binlog-connector-java/pull/84#issuecomment-1397213270

Perhaps can be closed.