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

Connect failed on GTID mode enabled. #156

Closed
PhantomThief opened this issue Mar 2, 2017 · 3 comments
Closed

Connect failed on GTID mode enabled. #156

PhantomThief opened this issue Mar 2, 2017 · 3 comments

Comments

@PhantomThief
Copy link

When calling:
binaryLogClient.setGtidSet(""); // enable gtid mode
binaryLogClient.connect();

the following exception.

com.github.shyiko.mysql.binlog.network.ServerException: The slave is connecting using CHANGE MASTER TO MASTER_AUTO_POSITION = 1, but the master has purged binary logs containing GTIDs that the slave requires.
at com.github.shyiko.mysql.binlog.BinaryLogClient.listenForEventPackets(BinaryLogClient.java:734)
at com.github.shyiko.mysql.binlog.BinaryLogClient.connect(BinaryLogClient.java:472)

actually I found when I setGtidSet, it wrongly set binlogFilename to "" and after connect it leads a wrong position.
so I have to setBinlogfilename(null) after setGtidSet, it works.

binlog-connector ver is 0.9.2.

@shyiko
Copy link
Owner

shyiko commented Mar 3, 2017

Hi @PhantomThief.

binlogFilename "" and null yield different results. The behavior is specified in javadocs. In a nutshell (for simplicity let's assume binlogPosition is 4 (the beginning)):

  • "" gtid set + "" binary log filename = request binary logs from the very beginning. If gtid_purged is anything but empty connection will fail (because in this case server is missing some of records (purged range(s))).
  • "" gtid set + null binary log filename = listen for binary logs events starting from the current (at the moment of connect) binary log filename and position.

I'm gonna update the javadocs to make it clear.

I understand that there are valid cases when you are not really interested whether gtid_purged is empty or not and so I will also add BinaryLogClient::gtidSetFallbackToPurged (just make sure you read https://dev.mysql.com/doc/refman/5.7/en/replication-options-gtids.html#sysvar_gtid_purged so that the consequences of setting this parameter to true are clear).

@shyiko
Copy link
Owner

shyiko commented Mar 3, 2017

0.11.0 deployed to Maven Central 🎉

@shyiko shyiko closed this as completed Mar 3, 2017
@PhantomThief
Copy link
Author

Thanks a lot. I'll have a test next week:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants