MDEV-40861 Table-rebuilding DDL on a not-up-to-date temp table resets the binlog state #6291
All Vouch review confidence checks passed
Residual risk 0.23 = Change Risk (0.43) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 383 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.356
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #6291"
general
weight: 0.35
gkodinov
Also fixes MDEV-38770.
Description
Since MDEV-36099, a temporary table whose CREATE was logged, but some of whose changes were not, is marked as not up to date (
table_creation_was_logged= 2), because the slave's copy is stale.mysql_alter_table()ignored this when an ALTER (or OPTIMIZE) rebuilt the table:ADD PRIMARY KEYwith a duplicate key error (MDEV-38770).Fix. When the table is not up to date and the statement is logged, log
DROP TEMPORARY TABLE IF EXISTSfor the old table instead of the ALTER, and leave the new table as not logged. The slave drops its stale copy, and statements that read the table are logged in row format. When the statement is not logged (OPTIMIZE,sql_log_bin=0), the table keeps its state. Tables that are up to date are not affected.Not changed: in a session with
binlog_format=ROW, an ALTER of a logged temporary table still leaves the slave's copy open. This also happens for tables that are up to date.Release Notes
Fixed replication of
ALTER TABLEandOPTIMIZE TABLEon a temporary table that is not up to date in the binary log, withbinlog_format=STATEMENT, or MIXED whencreate_tmp_table_binlog_formatsincludes MIXED. The slave could stop with an error, or silently get different data.How can this PR be tested?
New test
rpl.rpl_temp_table_alter. It covers an up-to-date table (the ALTER is logged as before), a not-up-to-date table withALTER ... FORCE, the MDEV-38770 case,ALTER ... ADD COLUMN, RENAME, and OPTIMIZE. Without the fix, it fails at the firstdiff_tables, and the MDEV-38770 case stops the slave with error 1062. With the fix, it passes, also with--ps-protocol,--cursor-protocoland parallel replication. The test case from MDEV-40861 passes too.Full default test run: 5 tests fail (
main.opt_trace_store_ddls,main.sp-security,sys_vars.path_basic,unit.pfs_instr-oom,unit.waiting_threads). All 5 fail the same way on this macOS machine without this change.Basing the PR against the correct MariaDB version
mainbranch.The code comes from MDEV-36099 (first in 12.0.1), so 12.3 is the earliest maintained branch with the bug.
PR quality check
This contribution is made under the MariaDB Contributor Agreement (MCA).