Skip to content

on reconnect in the middle of transaction make sure to reread interrupted transaction #420

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

Merged

Conversation

gleonid
Copy link
Contributor

@gleonid gleonid commented Sep 2, 2019

this is another stab at issues #414 and #416

on reconnect in the middle of transaction make sure to read interrupted transaction from the beginning

summary of proposed solution:

  1. separately maintain prevGset, currGset on BinlogSyncer
  2. for reconnect always use prevGset
  3. on GTIDEvent/MariadbGTIDEvent
    advance prevGset (assign currGset value)
    advance currGset to value extracted from binlog
  4. on XIDEvent/QueryEvent always use currGset

…ed transaction from the beginning

this is another stab at issues go-mysql-org#414 and go-mysql-org#416
}

advanceCurrentGtidSet := func(gtid string) error {
if b.currGset == nil {
Copy link
Contributor Author

@gleonid gleonid Sep 2, 2019

Choose a reason for hiding this comment

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

initially currGset is nil, while prevGset is set
purpose of b.currGset = b.prevGset.Clone() to once allocate memory for currGset so b.currGset.Update call on line 749 can be made

case *QueryEvent:
event.GSet = b.getGtidSet()
event.GSet = getCurrentGtidSet()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

getCurrentGtidSet is a replacement for BinlogSyncer.getGtidSet()
a. getCurrentGtidSet returns currGset if set
b. it became local function to emphasize scope of usage

@ianzapolsky
Copy link

I have reviewed this and it is a better version of what I initially submitted in #414. Let's merge this ASAP

@siddontang
Copy link
Collaborator

PTAL @GregoryIan

@gleonid gleonid changed the title on reconnect in the middle of transaction make sure to read interrupt… on reconnect in the middle of transaction make sure to read interrupted transaction from the beginning Sep 4, 2019
@gleonid gleonid changed the title on reconnect in the middle of transaction make sure to read interrupted transaction from the beginning on reconnect in the middle of transaction make sure to reread interrupted transaction Sep 4, 2019
@@ -733,33 +733,61 @@ func (b *BinlogSyncer) parseEvent(s *BinlogStreamer, data []byte) error {
// Some events like FormatDescriptionEvent return 0, ignore.
b.nextPos.Pos = e.Header.LogPos
}

getCurrentGtidSet := func() GTIDSet {
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we move these two functions to outside?

Copy link
Contributor Author

@gleonid gleonid Sep 9, 2019

Choose a reason for hiding this comment

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

we can, however having those functions local emphasizes that they are used/called only in scope of parseEvent.

@gleonid gleonid force-pushed the reconnect_in_middle_of_transaction branch from 0be9111 to 697f001 Compare September 9, 2019 13:43
@siddontang siddontang merged commit 376753e into go-mysql-org:master Sep 9, 2019
@gleonid gleonid deleted the reconnect_in_middle_of_transaction branch October 17, 2019 13:06
ghost pushed a commit to actiontech/go-mysql that referenced this pull request Nov 26, 2020
…pted transaction (go-mysql-org#420)

* on reconnect in the middle of transaction make sure to read interrupted transaction from the beginning
this is another stab at issues go-mysql-org#414 and go-mysql-org#416
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.

3 participants