MDEV-10436 non-deterministic vcol does not force rbr #6208
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.40) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 281 lines diff across 3 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
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.338
Real PR Conversation Timeline
1 comments
"Review active on #6208"
general
weight: 0.35
gkodinov
Description
In MIXED binlog format, statements reading a table with a
non-deterministic virtual column (e.g. RAND()) were logged in
statement format, so a slave recomputes the column and may end up
with different data. RAND() written directly in a statement is
already marked unsafe at parse time, but virtual column expressions
are parsed separately and never marked the statement unsafe.
Fix: collect the flags of all virtual columns into a new
TABLE_SHARE::vcol_flags in parse_vcol_defs(), and in
THD::decide_logging_format() mark the statement unsafe
(BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION) when a table with a
VCOL_NON_DETERMINISTIC or VCOL_SESSION_FUNC virtual column is read,
or is the target of UPDATE/DELETE.
Design notes
uint vcol_flags(OR of vcol_info->flags) stored once in TABLE_SHARE and checked per
table in decide_logging_format(), instead of iterating fields per
statement.
when decide_logging_format() runs from lock_tables(). This may
over-approximate (e.g. INSERT ... SELECT a FROM t2 not reading the
vcol), which only costs binlog size.
reading them is deterministic.
matching the existing non_determinstic_insert check; time functions
are safe as TIMESTAMP is replicated.
used directly) to avoid adding a new error message in a GA branch.
How can this PR be tested?
Added to binlog.binlog_unsafe: four statements reading a RAND() vcol
now produce the unsafe warning in STATEMENT mode, three that don't read
it (or read only a NOW() vcol) do not, and in MIXED mode the
INSERT ... SELECT is logged as Write_rows. Also ran the binlog, vcol and
rpl suites locally; rpl.rpl_parallel_sbm,
binlog.binlog_expire_logs_seconds and
binlog.binlog_show_binlog_events_invalid_offset_silent failed under
parallel load and look timing-related/unrelated, but I have not
confirmed them against an unpatched build.
Licensing
I am contributing this under the 3-clause BSD license.