fix(advisor/tidb): reinstate DML count-cap with multi-table gate (Cod… · bytebase/bytebase@bf9e239 · GitHub
Skip to content

Commit bf9e239

Browse files
vsai12claude
andcommitted
fix(advisor/tidb): reinstate DML count-cap with multi-table gate (Codex P1, cumulative #30 Codex-fix-1g)
Codex caught: my reshape removed the pre-omni >5 DML feasibility gate, but the backup transformer at parser/tidb/backup.go:96-110 still has that constraint. Inputs like 6 UPDATEs across different tables now pass the advisor but fail at runtime backup generation with "prior backup cannot handle statements on different tables more than 5". The reshape framing ("pre-omni count-cap is stale legacy logic") was wrong here. The count-cap matches the transformer's CURRENT behavior: generateSQL: if len(statementInfoList) <= maxMixedDMLCount { // 5 return generateSQLForMixedDML(...) // OK for ≤5 } return generateSQLForSingleTable(...) // requires single table generateSQLForSingleTable: for _, item := range statementInfoList { if !equalTable(table, item.table) { return nil, errors.Errorf("prior backup cannot handle statements on different tables more than %d", ...) } } Fix: reinstate the count-cap gate after per-table mixing detection. When `len(dmlRefs) > maxMixedDMLCount`, compute distinct base tables across all DML references; if more than one, fire advice matching the transformer's reject condition. Single-table batches above the threshold are intentionally allowed — the transformer's single-table path handles them successfully. Constant `maxMixedDMLCount = 5` reinstated at advisor level (matches parser/tidb/backup.go:23). Synced via comment for maintenance. Regression-direction pins added (TestTiDBPriorBackupCheckAdvisor case count: 16 → 18): - "6+ DML across multiple tables fires count-cap (Codex-fix-1g)": 6 UPDATEs across tech_book + orders → MUST fire. - "6+ DML on single table — no count-cap advice (Codex-fix-1g)": 6 UPDATEs on tech_book only → MUST NOT fire count-cap (single- table path handles). Cumulative #30 sub-fix lineage updated to nine sub-fixes: 1 — SET-clause-based target extraction 1b — distinct-base gating 1c — DDL classification (DropView + AlterDatabase) 1d — schema-qualified UPDATE target lookup 1e — schema-aware unqualified-SET resolution 1f — DDL detection via pingcap DDLNode 1g — count-cap with multi-table gate (matches transformer) 2 — case-insensitive grouping key 2-revised — DBSchema.Name default-DB Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent ebc36f0 commit bf9e239

2 files changed

Lines changed: 76 additions & 0 deletions

File tree

‎backend/plugin/advisor/tidb/advisor_builtin_prior_backup_check.go‎

Lines changed: 37 additions & 0 deletions

‎backend/plugin/advisor/tidb/tidb_rules_test.go‎

Lines changed: 39 additions & 0 deletions

0 commit comments

Comments
 (0)