Repository navigation
Stabilize native CI runners and WAL replay checkpoint test - #32353
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 5dd5996c6f607c0bb252c42be84d52231670dc98
Assessment: approve
The runner update preserves workflow coverage. The WAL test uses the backend’s completion watermark, retains its replay assertions and correctly cleans up both handle generations.
Model: gpt-6.1-sol / max
Session: 01a1a004-9884-72c0-ad39-f096c4209c4a · slot 1 · generation 0
Validation:
-
Go 1.27.1/CGo: all five WAL package tests passed.
-
TestReplayWithCheckpoint passed focused race validation and 100 repetitions in one process; adaptive budget recorded in race-budget.json.
-
YAML/matrix, gofmt, assertion-preservation and clean-source audits passed. Frozen exact-head native CI checks, including both macOS 15 jobs, succeeded.
-
validation-review.json reconciles commands, source fingerprints, exits and retained logs with check-run receipts. Review plan and complete discussion assessment are saved.
Limitations:
- Full PR CI was unfinished/not green in the frozen snapshot. Release-branch driver fixes and other listed investigations remain outside this main-only change.
…32357) ## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Related to #31175 Related to #31179 ## What this PR does / why we need it: **Design.** `docs/design/20261108-pattern-matching-effective-collation.md` (revision r5, SHA256 `c37413e83c10d49cd71153d22b2066733d3ecc1f2a543b14b50b830c9ecbba42`, revised in `b9d08296ef` after the rebase onto `c99234dcf4`) records the problem evidence, invariants, MySQL/ICU/UCA precedent and alternatives, ownership and data flow, resource budgets and boundaries, compatibility/rollout, and the validation map for the complete change. r5 corrects r4's validation-map fold-fully expectation with engine bounds measured during the post-approval implementation: exact fold emission grows quadratically with run length, and the regexp2 route's binding engine bound for long fold runs is its compiled backtracking-state limit (4,096 tracks — a 40-rune fold run compiles at 1,439 tracks and is admitted; an 80-rune run compiles past the bound), so the round-14 four-alternative comment-bearing shape raises the bounded resource-limit error under `i` even after deduplication, and fold-fully proofs relocate to below-bound regexp2 shapes and to the RE2 route at the original scale. No invariant, ownership decision, budget value, or error family changes; r4's independent design-only PASS (SHA256 `c31aef6c201f712c72aca88c59149d6805f1b99fddad9d2a0cde724021edc098`) remains the base. r4 had resolved the r3 finding (equal effective inline-option state before deduplication; an intervening unscoped setter makes a duplicate ineligible, so `^(?:ss|(?i)a|ss)$` keeps both `ss` branches) and carried forward the r3 resolutions of the two r2 findings (capture/backreference/option-aware dedup eligibility; the resource-limit error contract with planned public-path BVT proof). Design r5 passed the independent design-first review, and the production deltas are implemented in head `bd80b57137` on top of the r5 design commit. Revision r6 (2026-11-09) records the resolution of the implementation review's P1 on the r5 head: the alternative-deduplication prepass is linear and carries its own charged work bound (4 MiB) — construct marks land on the innermost branch in O(1) with close-time flag folding into the enclosing branch, and each alternation closure tracks its most recent unscoped-setter branch incrementally — so many identical siblings and deeply nested groups cannot perform quadratic work before the rewrite budgets are initialized; abandoning the prepass returns the source pattern unchanged, deferring to the approved expansion budgets with no new SQL-visible outcome. It extends `docs/design/regexp-icu-compatibility.md` (issue #28305), whose admission/cache/budget layer this change threads case folding through. **Problem.** `LIKE`, `ILIKE`, `REGEXP`/`REGEXP_LIKE` and `FIND_IN_SET` ignored the effective collation and compared byte-wise. Under the default `utf8mb4_general_ci` (and under an explicit `utf8mb4_unicode_ci` column) `'a' LIKE 'A'` returned 0 and `WHERE name LIKE 'alice%'` missed `'Alice'`, while MySQL returns 1 for both — and while `=`/`IN` and `LOCATE`/`INSTR`/`POSITION` on the same data already honored the collation. Pattern operators therefore disagreed with their sibling operators, and `LIKE 'prefix%'` index range scans could return different rows than folded scans. **Root causes closed by this PR.** 1. The LIKE executor and FIND_IN_SET ran byte-wise matchers and the regexp engine ran case-sensitively; none of the pattern operators consulted the operands' resolved collation (column COLLATE, expression COLLATE, session default, `_binary` introducer, `CAST(x AS BINARY)`). 2. Collation-correct matching needs more than per-character caseless flags: `utf8mb4_general_ci` folds by MySQL's weight table, `utf8mb4_unicode_ci` compares UCA 4.0.0 primary weights per character, and ci REGEXP needs Unicode full case folding (`ß`↔`ss`) that per-character orbits cannot express. 3. The planner rewrote `col LIKE 'prefix%'` into byte-ordered `prefix_eq`/`=` filters, which return different rows than collation-folded LIKE. 4. Constant folding truncated planner-built binary→text conversions whose target width is `-1` (every non-empty constant folded to `''`) and re-marked folded `CAST(x AS BINARY)` literals as binary-introducer domains, losing a winning case-insensitive collation. 5. Aggregating the matchers into collation resolution exposed implicit ci-column vs `CAST(x AS BINARY)` ties (equal coercibility 2) to the resolver's version check, raising error 1267 where base behavior and MySQL compare byte-wise; `find_in_set`'s overload registration also cast binary operands to utf8 `varchar`, erasing the binary string domain for non-constant operands. 6. Constant `CAST(x AS BINARY)`, `BINARY 'x'` and `binary(x)` presented a coercible literal's coercibility (4) instead of MySQL's IMPLICIT coercibility (2) for cast results: folding replaces the cast with a literal that keeps only its type, and the `binary()` function fell through to the default rank. A case-insensitive column then strictly outranked the binary operand and the planner converted it to case-insensitive text, flipping `vc LIKE BINARY 'a%'` / `vc LIKE CAST('a%' AS BINARY)` / `BINARY vc LIKE 'a%'` to case-insensitive (surfaced by `operator/mysql_compat_string_binary_comparison`). **What changes.** - `pkg/common/collation/wildcard.go` (new): collation-aware LIKE matcher — general_ci weight folding, UCA per-character weights, `_`/`%`/ESCAPE handling, bounded multi-`%` segment matching with cancellation. - `pkg/sql/plan/function/func_builtin_regexp.go`, `regexp_casefold.go`/`regexp_casefold_tables.go` (new), `regexp_icu.go`: LIKE/ILIKE/REGEXP/REGEXP_LIKE resolve the operands' collation (including the ESCAPE argument; `REGEXP_LIKE` resolves from subject and pattern); ci collations route LIKE through the weighted matcher and REGEXP through an exact, bounded full-fold pattern rewrite (byte-identical below its budgets; per-character caseless orbit above them); the binary/ci mix keeps MySQL's error 3995 in both operand orders, and malformed-pattern verdicts are always taken from the source pattern as written. - `pkg/sql/plan/function/func_binary.go`: FIND_IN_SET honors the resolved collation (weighted whole-key membership, unpadded comparison; trailing spaces stay significant). - `pkg/sql/plan/collation_expression.go`: expression-level collation resolution covers the pattern matchers; a scoped pairwise tie rule (`patternBinaryCollationAdmission` + `pairwiseBinaryTieWinner`) restores the base behavior for implicit ci-column vs binary-CAST predicates only — the binary operand wins the equal-implicit-rank tie, LIKE/ILIKE/FIND_IN_SET compare byte-wise, REGEXP keeps 3995, and text-text conflicts still raise 1267. Binary-domain cast results are stamped with MySQL's IMPLICIT coercibility (2) so the tie rule, not a rank-4 literal default, decides them. - `pkg/sql/plan/base_binder.go`: `CAST(x AS BINARY)`/`BINARY 'x'` carry IMPLICIT coercibility from creation; the stamp rides the expression type, so constant folding (which preserves the type wholesale) cannot drop it. - `pkg/sql/plan/opt_misc.go`: for case-insensitive columns the planner keeps the LIKE predicate instead of rewriting it to byte-ordered `prefix_eq`/`=` filters, so scan and index paths return the same rows. - `pkg/sql/plan/function/func_cast.go`, `pkg/sql/plan/rule/constant_fold.go`: negative-width conversion targets no longer truncate folded constants, and a folded binary-CAST literal keeps the selected text domain when an explicit ci collation won the resolution. - `pkg/sql/plan/function/list_builtIn.go`: `find_in_set` uses the domain-preserving overload registration. **Issue-to-test proof.** Every reproduction row from #31175 and the preserved #31179 report is pinned: `'a' LIKE 'A'`/`'ABC' LIKE 'abc'`/`'abc' REGEXP 'ABC'`/`'abc' REGEXP '[A-Z]+'` now return 1; the `ci1`/`uci2` table rows match folded `LIKE 'alice%'` and `REGEXP '^alice'`; `FIND_IN_SET('A','a,b')` = 1; explicit `utf8mb4_unicode_ci` column and literal COLLATE cases agree across `=`/IN/LIKE/REGEXP; binary/case-sensitive controls (`_bin` collations, `_binary` domains) stay byte-wise; `LOCATE`/`INSTR`/`POSITION`/`FIND_IN_SET` neighbors keep their behavior. - UT: `pkg/common/collation` (weights, segments, boundaries), `pkg/sql/plan` (resolution/admission matrix incl. CAST and prepared shapes, executor routing over real typed batches, fold/cast preservation, folded-`CAST(x AS BINARY)`/`BINARY 'x'`/`binary()` coercibility regression test) and `pkg/sql/plan/function` (fold rewrite tables/orbits, matcher routing, error shapes). `pkg/sql/plan/build_show_desc_oracle_test.go` fixture spellings now differ beyond letter case, because the DESCRIBE/SHOW COLUMNS filter LIKE honors the effective case-insensitive collation (the #32197 replan-refilter assertions are unchanged). `pkg/tests/sqlintegration/like_prefix_index_test.go` pins its #31940 prefix-plan fixtures to `utf8mb4_bin`, the byte-ordered domain the prefix rewrite requires, and the new `TestLikePrefixCaseInsensitiveKeepsFoldedPredicate` proves that under `utf8mb4_general_ci` the analyzed planner keeps the folding LIKE predicate (no `prefix_in_range`/`prefix_eq`) while scan, forced-index and computed-subject paths all return the folded rows (`'abc'`/`'ABC'`/`'Abc'` for `LIKE 'abc%'`). - BVT: new `test/distributed/cases/charset_collation/issue_31175_pattern_collation.sql` — 416 statements covering literals, columns, explicit COLLATE in both operand orders, `_binary`/HEX/BIT/CAST domains, prepared `CAST(?)` parameters, user variables, VARBINARY columns, index-vs-scan plans, NULL/empty/escape boundaries and error texts; every expected value probed against a MySQL 8.0.44 oracle. Its resource-boundary rows pin the r5 contract: the 328-byte four-alternative comment-bearing shape raises the bounded resource-limit error naming the regexp2 4,096-track backtracking-state bound under `i` while the `c` control returns 1, below-bound shapes fold fully on the regexp2 route (six `ß` match twelve `s`), and the RE2 route folds fully at the original scale (forty `ß` match eighty `s`). New `test/distributed/cases/charset_collation/issue_31175_pattern_resource_limits.sql` (15 statements) pins the bounded error contract at every bound — per-pattern emission budget exhaustion, RE2 nesting admission, the 4,096-track bound, and below-bound positive/negative fold controls (`CONCAT(REPEAT('ß',20),'a')` matches the forty-`s`-then-`a` branch = 1; the unsuffixed subject = 0). Existing expectations updated only where folding intentionally changes results (`operator/like_operator`, `optimizer/like` plans, `function/func_regular_like` CRLF-multiline rows), plus the same intentional case-folding flips surfaced by CI in `charset_collation/charset_collation_advanced` (`code LIKE 'abc%'`), `charset_collation/charset_collation_basic` (`name LIKE 'app%'/'APP%'` on the `general_ci` table; the `utf8mb4_bin` controls are unchanged), `operator/operator.test` (`username LIKE '%Frau'`), `operator/regexp_operator` and `operator/not_regexp_operator` (`'Acorn' [NOT] REGEXP 'Corn'`), and `fulltext2/fulltext2_covered` (`tag LIKE 'Act%'`). `operator/mysql_compat_string_binary_comparison` keeps its committed expectations: its CI failure was root cause 6, fixed in code. Local validation: `mo-cgo-test -count=1 ./pkg/sql/plan ./pkg/sql/plan/rule ./pkg/sql/plan/function ./pkg/common/collation` (all packages pass), `go vet` clean, gofmt clean, `go test -count=1 -run 'TestLikePrefixIndex$|TestLikePrefixCaseInsensitiveKeepsFoldedPredicate$' ./pkg/tests/sqlintegration` (both pass, memory+persisted phases; the unadapted fixture failed the line-105 plan assertion in CI coverage UT on this head), and mo-tester `run` of the new BVT passes 410/410 on the fixed binary while the pre-fix binary fails exactly the new discriminator statements. At the pre-rebase r5 head `5c628ab92f` (same diff, now rebased): focused UT batches pass (`pkg/sql/plan/function` dedup/fold/routing suites incl. `TestRegexp2CaseFoldIdenticalAlternativesDedup` and `TestRE2CaseFoldIdenticalAlternativesDedup`; full `pkg/common/collation` batch incl. the LIKE budget UTs), and mo-tester `genrs` + independent row review + two normal-comparison `run` passes of `include=issue_31175_pattern` on one clean instance each pass 431/431 (416 collation + 15 resource-limits). After the root-cause-6 fix, mo-tester `run` additionally passes `operator/mysql_compat_string_binary_comparison` (57/57), the six refreshed files above, `function/func_regular_like`, `optimizer/like` and `optimizer/like_prefix_range` on the rebuilt binary (`operator/like_operator` passes 190/190 in CI; one `rpad`+cast INSERT at row 230 fails only under the local prepared-statement runner, before and after this change); live probes confirm `vc LIKE BINARY 'a%'` / `vc LIKE CAST('a%' AS BINARY)` / `BINARY vc LIKE 'a%'` / `vc LIKE BINARY vb` compare byte-wise while `_binary 'a%'` and plain literals keep folding case-insensitively. **Rebase note (2026-11-09).** Rebased onto main `c99234dcf4` to clear the merge conflict: #32341's `BuildPlan`/`CompilerContext.Resolve` signature migration overlapped this PR's `n_NAME`→`n_PAME` expectation update in `pkg/sql/plan/build_show_desc_oracle_test.go` (kept the PR's case-beyond-letter-case fixture with the new 4-argument call and `TableResolution` output), and one PR-added `BuildPlan` call in `pkg/sql/plan/collation_expression_test.go` was migrated to the new signature. The post-rebase PR diff is byte-identical to the pre-rebase diff outside those two resolutions. Post-rebase validation on `bd80b57137`: all five touched Go packages (`pkg/sql/plan`, `pkg/sql/plan/function`, `pkg/common/collation`, `pkg/sql/plan/rule`, `pkg/tests/sqlintegration`) compile clean via `mo-cgo-test`; the 26 DESC-oracle/LIKE-prefix/binary-tie tests and the 20 collation-expression tests (incl. the migrated `TestPatternBinaryColumnCastTieRestored`) pass; the full `pkg/sql/plan/rule` suite passes. **Review-resolution note (2026-11-09, head `c8a615913c`).** Resolved the mo-bot implementation review's P1 on `bd80b57137` (the deduplication prepass performed quadratic work before the rewrite budgets): identical-sibling dedup now makes one pass per alternation (65,536 alternatives: 2.19 s -> 4.8 ms in an exact-source probe) and capture/reference/setter marks fold upward at group close instead of walking the ancestor stack per construct (32,768 nested captures: 0.94 s -> 4.7 ms), with eligibility verdicts preserved exactly; a charged 4 MiB prepass bound abandons dedup byte-identically on exhaustion (the depth-2000 nested-alternation shape that would hash ~410 MB is capped). Validation on `c8a615913c`: focused dedup/work-bound/eligibility suites pass (incl. exact-budget straddle pins and nested flag-propagation rows), the broad `CaseFold|Dedup|Regexp|RE2` selection passes 135/135 top-level tests (917 runs incl. subtests, 0 failures), gofmt and `go vet` clean. No BVT result changes: abandonment is unreachable below the bound (every BVT pattern is orders of magnitude smaller), and dedup outputs are unchanged for all in-budget patterns. **Base refresh (2026-11-09, head `07943b3040`).** Rebased onto main `da867c90df` (6 commits: #32401, #32399, #31419, #32353, #32380, #32251) under the scheduled ci_base_refresh after run 42566409967's four failures were verified as the unrelated #27066 tool-download transport class. Zero file overlap with this PR's diff; no conflict resolutions needed and the post-rebase PR diff is byte-identical to the pre-rebase diff. Post-rebase validation on `07943b3040`: `go test -count=1` passes for all three affected packages — `pkg/common/collation` (17.2s), `pkg/sql/plan/function` (38.9s), `pkg/sql/plan` (131.1s). No code change; design r5/r6 record and all review dispositions carry over unchanged. **Residual limits** (pinned by tests and documented in the issue): LIKE stays a per-character weight comparison (no multi-character expansion spanning; `ß LIKE 'ss'` = 0); three ICU-only regexp corners diverge (character-class string closure, caseless backreference matching, quantified-atom image spanning); equality/IN over pure literals under explicit `utf8mb4_general_ci` keep a pre-existing parity gap that a follow-up issue owns; `REGEXP_INSTR`/`REGEXP_SUBSTR`/`REGEXP_REPLACE` keep their default case behavior unless `match_type` requests `i`; PAD SPACE, sort weights and key uniqueness under ci collations are out of scope per the issue's acceptance checklist. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
What type of PR is this?
Which issue(s) this PR fixes:
Refs #32343
Refs #32262
What this PR does / why we need it:
Draft checkpoint for the assigned CI/UT issues. The native-dependency workflow requests
macos-14, which GitHub retired on November 2, 2026; its two macOS jobs fail before runner allocation. Switch both jobs to the supportedmacos-15ARM64 runner while retaining both checks and the Linux matrix.TestReplayWithCheckpointcurrently treats the WAL truncation intent as proof that log-service truncation has completed. Wait for the mock backend's actual watermark to advance after each checkpoint before reopening, without assuming a fixed physical LSN. The test continues to assert the replay mappings and now checks close errors.Validation
TestReplayWithCheckpointpassed three times under race; the WAL package passed normal and race runs.go vetand configured incremental golangci-lint passed. Workflow YAML and both job matrices were parsed and checked.macos-15execution and complete PR CI are pending; local checks cannot prove GitHub runner allocation or macOS behavior.gpt-6.1-terra/ max reviewed the two-file diff with no code blockers, conditional on the above validation.Remaining scope
This draft does not resolve all assigned CI/UT issues. #32262 was reported on
4.1.6-hotfix, which still closes its WAL client pool before draining truncation; this main-only test change is not a release-branch fix.4.2-devhas a separatemacos-14downloader job. #32258 has a plausible cache destroy/retry race on 4.2; main has an ownership barrier but the CI occurrence has not been independently reproduced. #32327, #32324, #32323, #32185 and #32179 remain under investigation. #32189 was closed separately after the exact assertion was corrected in merged #32149.A PR targeting main does not update the 4.1 or 4.2 branches. Backports and validation on the affected branches are still required. Existing fork PRs must incorporate the updated workflow to use the new runner.