mysql-binlog-connector-java icon indicating copy to clipboard operation
mysql-binlog-connector-java copied to clipboard

BinaryLogClient auto detects wrongly MariaDB instead of MySQL

Open bdeneuter opened this issue 3 years ago • 3 comments

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)

bdeneuter avatar Sep 15 '22 09:09 bdeneuter

lemme fix the regex.

osheroff avatar Sep 16 '22 12:09 osheroff

@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

bdeneuter avatar Sep 16 '22 13:09 bdeneuter

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

Perhaps can be closed.

megatron10 avatar Sep 02 '24 15:09 megatron10