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
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