Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Only check for semi-sync ack request if semi-sync is enabled for this…
… connection I think this is correct, since the docs[1] for enabling semi-sync indicate that not all slaves need to support it, even if the msater does. This does resolve the problem I sort-of-reported in #13, which appears to be two bytes missing from the beginning of the packet at the time the event is parsed. [1]: https://dev.mysql.com/doc/refman/5.5/en/replication-semisync-installation.html
  • Loading branch information
blalor committed Jun 28, 2015
commit 16508dad129285d12a84e7b617ee394d13bc7971
11 changes: 9 additions & 2 deletions replication/binlogsyncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ type BinlogSyncer struct {
nextPos Position

running bool
semiSyncEnabled bool
}

func NewBinlogSyncer(serverID uint32, flavor string) *BinlogSyncer {
Expand All @@ -52,6 +53,7 @@ func NewBinlogSyncer(serverID uint32, flavor string) *BinlogSyncer {
b.parser = NewBinlogParser()

b.running = false
b.semiSyncEnabled = false

return b
}
Expand Down Expand Up @@ -211,6 +213,11 @@ func (b *BinlogSyncer) EnableSemiSync() error {
}

_, err := b.c.Execute(`SET @rpl_semi_sync_slave = 1;`)

if err != nil {
b.semiSyncEnabled = true
}

return err
}

Expand Down Expand Up @@ -479,11 +486,11 @@ func (b *BinlogSyncer) onStream(s *BinlogStreamer) {
}

func (b *BinlogSyncer) parseEvent(s *BinlogStreamer, data []byte) error {
//skip 0x00
//skip OK byte, 0x00
data = data[1:]

needACK := false
if data[0] == SemiSyncIndicator {
if b.semiSyncEnabled && (data[0] == SemiSyncIndicator) {
needACK = (data[1] == 0x01)
//skip semi sync header
data = data[2:]
Expand Down