Skip to content

Canal error: "invalid sequence 6 != 1" on first authentication #535

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

Closed
tcd93 opened this issue Dec 31, 2020 · 0 comments · Fixed by #652
Closed

Canal error: "invalid sequence 6 != 1" on first authentication #535

tcd93 opened this issue Dec 31, 2020 · 0 comments · Fixed by #652

Comments

@tcd93
Copy link

tcd93 commented Dec 31, 2020

System:

  • MySQL 8.0 (authentication plugin: caching_sha2_password)

How to reproduce:

  • Stop any running Canal instance
  • Restart MySQL instance, or execute FLUSH PRIVILEGES;
  • Restart Canal
    • The error will appear
    • After seeing first error, if we start the Canal again, Canal would work normally

Investigation:
After checking I found the method packet.WritePublicKeyAuthPacket leaves dirty buffer after writing, causing sequence mismatch in the next read op
https://github.com/siddontang/go-mysql/blob/0c5789dd0bd378b4b84f99b320a2d35a80d8858f/packet/conn.go#L250
I added an blank read op to clear the buffer and it works properly:

	// return errors.Wrap(c.WritePacket(data), "WritePacket failed")
	err = c.WritePacket(data)
	if err != nil {
		return errors.Wrap(err, "WritePacket failed")
	}
	_, err = c.reader.Read(data) // clear dirty buffer
	return err

I think the same would happen to packet.WriteClearAuthPacket too, but I have not tested it yet

I'm not sure this is the correct way to fix this as I'm not very experienced with Go, so I just open an issue here

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 a pull request may close this issue.

1 participant