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

binlog_syncer: reduce the times of Clone of MySQLGTIDSet to speed up #746

Merged
merged 3 commits into from
Nov 30, 2022

Conversation

GMHDBJD
Copy link
Contributor

@GMHDBJD GMHDBJD commented Nov 29, 2022

  • add DiscardGTIDSet to allow user not to maintain Gset for QueryEvent/XIDEvent
  • add prevMySQLGTIDEvent to calculate prevGSet instead of clone currGSet

case *MariadbGTIDEvent:
if b.prevGset == nil {
break
}
GTID := event.GTID
err := advanceCurrentGtidSet(uuid.Nil, 0, GTID.DomainID, GTID.ServerID, GTID.SequenceNumber)
prev := b.currGset.Clone()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why we don't do it for MariaDB?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK seems MariaDB has a simpler representation of GTID, we can leave this improvement to future when we found a bottleneck

@@ -120,6 +120,8 @@ type BinlogSyncerConfig struct {
Dialer client.Dialer

RowsEventDecodeFunc func(*RowsEvent, []byte) error

DiscardGTIDSet bool
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the DiscardGTIDSet should also skip maintaining prevGset and currGset, only skipping output is no benefit to performance

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prevGset and currGset need to maintain for reconnect. Skip output reduce the clone operation

b.currGset.(*MysqlGTIDSet).AddGTID(u, event.GNO)
if b.prevMySQLGTIDEvent != nil {
u, _ = uuid.FromBytes(b.prevMySQLGTIDEvent.SID)
b.prevGset.(*MysqlGTIDSet).AddGTID(u, b.prevMySQLGTIDEvent.GNO)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we also consider the case "right after reconnect we will see same gtid as we saw before, thus currGset will not get changed"? (but I don't know when it will happen)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That won't happen, because we will leave the currSet empty when we retry, and the mariadb comment will just stay as it is.

b.currGset = nil

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

Successfully merging this pull request may close these issues.

2 participants