--resume with --gtid can skip the rest of a large transaction (checkpoint written mid-transaction): silent data loss
Les mainteneurs répondent en général sous 10 jours
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 42/100
Piste de recherche
Read go/binlog/gomysql_reader.go around GTIDEvent and go/logic/migrator.go around Migrator.Checkpoint() and onApplyEventStruct. Trace when coordinates advance during a multi-batch transaction, then reproduce with --gtid --checkpoint and a large transaction. Done means a checkpoint and --resume cannot skip unapplied rows when a crash occurs mid-transaction.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Summary
With --gtid --checkpoint, a checkpoint can be written while a multi-row transaction is only partly applied to the
ghost table. --resume then starts the binlog stream from a GTID set that already contains that transaction, so the
server never sends it again and the rest of its rows are silently lost. The migration completes normally (exit code
0, Done migrating) and the cut-over puts the stale ghost table live.
How it happens (v1.1.11)
GoMySQLReaderadvances its coordinates on theGTIDEvent, i.e. before the transaction's row events
(go/binlog/gomysql_reader.go,case *replication.GTIDEvent): the running GTID set already includes the
transaction being streamed.Migrator.Checkpoint()takeseventsStreamer.GetCurrentBinlogCoordinates()asLastTrxCoordsand writes the
checkpoint as soon ascoords.SmallerThanOrEquals(applier.CurrentCoordinates)(go/logic/migrator.go, around
line 1815).- The applier sets
CurrentCoordinates = eventStruct.coordsafter every DML batch (onApplyEventStruct, around line
1797) — after the first batch of a large transaction its coordinates already equal the streamer's. - So a checkpoint taken during a large transaction records its GTID after only
--dml-batch-sizerows were applied.
On--resume,InitialStreamerCoords = lastCheckpoint.LastTrxCoordsand the replica stream starts with that set:
the transaction is considered executed and is skipped entirely.
Reproduction
MySQL 9.7 (Percona Server 9.7.1-1; nothing version specific is involved), single node, GTID on, a table t of
250,000 rows (id PK, chat_id, v), gh-ost v1.1.11 built from the tag:
gh-ost ... --database=vt --table=t --alter="ADD INDEX chat_v (chat_id, v)" \
--allow-on-master --assume-rbr --gtid --checkpoint --checkpoint-seconds=10 --dml-batch-size=10 \
--cut-over=atomic --postpone-cut-over-flag-file=/tmp/postpone --execute
- Let the row copy complete (cut-over postponed).
- Run one big transaction:
UPDATE vt.t SET v = v + 1000;(271,299 rows, GTID…:999999). - Wait until the newest row of
_t_ghkhasgh_ost_chk_coordscontaining that GTID while_t_ghohas only part of
the update (here: checkpoint…:1-53495:999999written when 14,360 of 271,299 rows were updated in_t_gho). kill -9gh-ost.- Restart the same command with
--resume:
Resuming from checkpoint coords=…:1-53495:999999 range_min=262190 range_max=262190 iteration=249. - Compare: 256,889 rows of
_t_ghostill have the oldvwhilethas the new one; no rows are missing. - Remove the postpone flag: cut-over succeeds, exit code 0 — the live table now has 256,889 rows with the update
lost (the old table_t_<ts>_delhas them right).
Before the kill, during the copy with concurrent inserts/updates/deletes, t and _t_gho matched by checksum, so
the loss comes from the resume only.
Impact
Silent data loss on resume after any crash or kill that happens while a large transaction is being applied: bulk
UPDATE/DELETE, backfills, archival jobs. A lost DELETE brings deleted rows back.
Possible fix
Checkpoint only on a transaction boundary: record the coordinates of the last transaction applied completely (e.g.
advance the applier's checkpointable coordinates on the transaction's XID/commit event rather than per batch), or
make Checkpoint() use the coordinates of the previous transaction while one is in progress. Until then, a note in
doc/resume.md that --resume is unsafe after a crash in the middle of a large transaction would help.
Related: #1780 (a different cut-over issue found while testing the same setup).
- Langage dominant
- Go
- Étoiles
- 13.6k
- Forks
- 1.4k
- Merge moyen
- 9 j 19 h
- PR mergées (30 j)
- 1
Préparer son environnement
- Fournit un Dockerfile ou un fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de github/gh-ost
-
`--resume` without `--execute` drops the ghost table it correctly skipped alteringPeut-être pris @ajm188 l’a pris il y a 56 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 86/100
Les mainteneurs répondent en général sous 10 jours
-
[Suggestion] Apply simple validation to alter commandPeut-être pris @drkemp187 l’a pris il y a 106 jours. Ouverteenhancement good first issue
Difficulté 2/5 1-3 heures Accessibilité débutants 64/100
github/gh-ost#1431 · 4 commentaires ·
Les mainteneurs répondent en général sous 10 jours
-
Migration hangs when --attempt-instant-ddl succeedsPeut-être pris Une pull request liée à cette issue est ouverte ou déjà fusionnée. Ouverte
Difficulté 4/5 3-5 jours Accessibilité débutants 30/100
Les mainteneurs répondent en général sous 10 jours
-
Atomic cut-over always fails on MySQL 9.1+: information_schema.processlist errors out (3854) while another session runs a non-BMP utf8mb4 statementPeut-être pris Une pull request liée à cette issue est ouverte ou déjà fusionnée. Ouverte
Difficulté 4/5 3-5 jours Accessibilité débutants 52/100
github/gh-ost#1780 · 1 commentaire ·
Les mainteneurs répondent en général sous 10 jours
-
Difficulté 4/5 3-5 jours Accessibilité débutants 68/100
Les mainteneurs répondent en général sous 10 jours
Toutes les issues de github/gh-ost
Issues similaires
-
[Docs] Four internal links return 404 (Models concept, Contributing to Docs, Providers reference)Peut-être pris Une pull request liée à cette issue est ouverte ou déjà fusionnée. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
meshery/meshery#23520 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
flaky: execenv TestRelayControlledCancelAndDirectParentDeath reads an empty pid file under loadOuverte
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
SocialGouv/iterion#3263 ·
Les mainteneurs répondent en général sous 1 jour
-
Container registry refuses image names with "__" or "--" (NAME_INVALID), which the OCI distribution spec allows since v1.1.0Peut-être pris @lazerg l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Les mainteneurs répondent en général sous 1 jour
-
Unsupported language versionOuverte
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
itadori26/trisse-home#226 ·
Les mainteneurs répondent en général sous 1 jour