-
Notifications
You must be signed in to change notification settings - Fork 289
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
MySQL reports Deadlock when TiCDC replicating data #3589
Comments
|
maybe we can follow MySQL's implementation |
Mysql suffers from delicate but complicate lock rules, ref partial to : I will discuss https://asktug.com/t/topic/272906/7 here, which is slight different from this issue. In that situation, we meet "pk(auto_increment) + uk + replace into + rr(/rc)". It will cause deadlock on specified situation, which may be normal in production. And deadlock will not disappear even we change the isolation level to rc, because rc needs gap lock to check for uniqueness on uk, ref to:
This deadlock pattern is as follow:
What xinyu discuss above is not exactly precise in this situation, because our "delete" always hit some records and add record locks on uk or pk but not gap lock. So, this deadlock is raised purely by "replace into", which has very complicate lock rules. I will make a simple explanation below, ref to: http://blog.itpub.net/7728585/viewspace-2141409/ .
Lock wait sequence:
Much more details in "replace into" lock process, including gap locks in pk, lock inherit/split in pk&uk. I will make more deep investigation if free.
|
…safe mode (pingcap#6278) close pingcap#3589, close pingcap#5611 Signed-off-by: Neil Shen <overvenus@gmail.com>
What did you do?
In 1 TiDB, 1 TiKV, 1 TiCDC cluster, set up a changefeed that replicates all tables to downstream MySQL.
MySQL may reports deadlock error.
Reproduce:
cfa
whose start-ts = TiDB gc safepoint, and replicates data to MySQL.cfa
and create a changefeedcfb
use the same config ascfa
.We can find deadlock errors in TiCDC log.
MySQL deadlock log: deadlock.log
Deadlock table schema
What did you expect to see?
No deadlock error.
What did you see instead?
MySQL Deadlock error.
Versions of the cluster
Upstream TiDB cluster version (execute
SELECT tidb_version();
in a MySQL client):v5.2.1
TiCDC version (execute
cdc version
):v5.2.1
MySQL version
The text was updated successfully, but these errors were encountered: