Skip to content

Commit

Permalink
Explicit check that it's a GTID_EVENT from the header.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tang8330 committed Dec 18, 2024
1 parent 8f63863 commit 4d43247
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions sources/mysql/streaming/offset.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,12 @@ func (p *Position) UpdatePosition(ts time.Time, evt *replication.BinlogEvent) er
p.Pos = evt.Header.LogPos
p.UnixTs = ts.Unix()

// If the event is a [*replication.GTIDEvent], then let's parse it and grab the next GTID set
if gtidEvent, ok := evt.Event.(*replication.GTIDEvent); ok {
if evt.Header.EventType == replication.GTID_EVENT {
gtidEvent, err := typing.AssertType[*replication.GTIDEvent](evt.Event)
if err != nil {
return err
}

set, err := gtidEvent.GTIDNext()
if err != nil {
return fmt.Errorf("failed to retrieve next GTID set: %w", err)
Expand Down

0 comments on commit 4d43247

Please sign in to comment.