CI validation only: Bug#102586 multi-table DELETE FK cascade (do not merge) - #1
Closed
matanbaruch wants to merge 3 commits into
Closed
CI validation only: Bug#102586 multi-table DELETE FK cascade (do not merge)#1matanbaruch wants to merge 3 commits into
matanbaruch wants to merge 3 commits into
Conversation
A multi-table DELETE that names both a foreign key parent table and a child table with a cascading delete rule breaks row-based replication. The replica applier stops with ER_KEY_NOT_FOUND. The parent row is deleted while the join is still scanning, so the cascade removes the child rows and logs row events for them. The statement logs row events for the child rows it deletes itself as well. On the replica the parent delete is applied first, its own cascade removes the child rows, and the logged child events then cannot find them. Exclude a delete target from immediate deletion when deleting from it cascades to another table in the same query, which defers the delete until the join has finished. The check is added to both the classic optimizer (GetImmediateDeleteTables) and the hypergraph optimizer (IsImmediateDeleteCandidate). Only ON DELETE CASCADE is considered. ON DELETE SET NULL updates the child rows rather than deleting them, so they stay findable for the logged events and replicate correctly. Deferring those deletes as well would change which rows the statement removes. This is the approach Zsolt Parragi contributed on Bug#80821 in 2019, adapted to the current code: get_cascade_foreign_key_table_list() no longer exists, so the cascade dependency is resolved from TABLE_SHARE::foreign_key_parent instead.
… change Format Check runs clang-format-18 over whole changed files. These three are not clean under 18 on trunk, so the gate fails for any PR touching them. Cosmetic only: a label space in sql_base.cc, one DBUG_LOG argument wrap in sql_delete.cc, and two string literal joins in join_optimizer.cc.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Not for merge. This exists only to run the upstream CI workflows against the branch, because they cannot run on the real PR (mysql#719): every
pull_request_targetworkflow refuses to check out fork code.Same commit as mysql#719.