Repository navigation
fix(function): reject undefined real-domain POW arguments - #32863
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? |
|
Queue requested — the merge queue status continues in this comment ↓. |
9284add to
b616d49
Compare
POW/POWER with a finite negative base and a finite non-integer exponent is undefined in the real domain; reject it with the typed DOUBLE out-of-range error (1690/22003) instead of a silent row-local NULL. Empty-batch, masked/selected rows, NULL inputs, integer exponents and the matrixorigin#28375 row-local NULL semantics (overflow/NaN-input, EXP/COT) are preserved; the func_math_power BVT oracle is corrected accordingly. Fixes matrixorigin#31155
…rops - gc/v3 buildTableExistenceMap now takes the table entry RLock while reading GetDeleteAtLocked/GetID, serializing with DBEntry.DropTableEntryByID delete-node insertion (CI UT race: TestDataBranchDiffAcrossCheckpointGCAndRestart/gc_checkpoint_restart). - pkg/sql/compile/tp_allocation_reuse_test.go: real prepared-TP consumer regression binding power(v-2,0.5) onto the reused Scan->Filter->Projection pipeline; the typed moerr out-of-range error must not publish the failed batch and the same compiled executor must recover exact results. - pkg/vm/engine/tae/db/gc/v3/executor_test.go: owned-transaction GC regression with real store registration and terminal commit/rollback finalization around concurrent catalog drops.
b616d49 to
5711dd2
Compare
…rministic - arena_pool_test: run the burst age-out contract under testing/synctest with normal and delayed first reaper schedules; snapshot outside the pool lock, release a borrowed arena on failed assertions, and join in-bubble reaper work before final assertions - cdc_control_status_test: bound the initial idempotent GetClusterState readiness probe; retry only wrapped dragonboat.ErrTimeout chains, at most three attempts on the unchanged context, with deterministic bounds tests
|
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: 4061503845f25d7523c152cd6bcae87a2005a477
Assessment: approve
POW and POWER now return MySQL error 1690 with SQLSTATE 22003 for evaluated rows with a finite negative base and a finite non-integer exponent. The fix reuses the existing vector evaluation path. The GC change takes the catalog entry lock that protects the delete timestamp. The CDC retry is confined to the initial read-only fixture setup, and the arena and cleanup changes are test-only.
Model: gpt-6.2-sol / xhigh
Session: 01a1f0a0-5126-78f3-9ab8-ef4e87f2f119 · slot 0 · generation 3
Validation:
-
The isolated MySQL wire probe passed for both aliases, empty and filtered inputs, an inactive IF branch, NULL and overflow controls, and prepared-statement recovery after a domain error. See power-wire.log and checks/1795056487102292849-2.json.
-
Focused race tests passed in five packages, covering Power, prepared execution, concurrent catalog drops, arena reaping, CDC readiness and cross-CN claims, and checkpoint/GC/restart. See focused-race.log and checks/1795056505677366495-4.json.
-
The GC and object I/O package race runs passed, and the catalog-drop and arena regressions each passed 100 repetitions. Their receipts and retained logs are indexed in validation-reconciliation.json.
-
The frozen CI evidence records successful x86 unit and coverage jobs, arm64 static analysis, and proxy and pessimistic multi-CN BVT. The local diff check passed and the source checkout remained clean.
Limitations:
-
Local SQL verification used a single-CN embedded server. Multi-CN BVT coverage comes from the frozen CI status records, whose raw logs were unavailable.
-
The issue #31401 cleanup-error diagnostic was reviewed in source. Its failure branch was not induced locally.
🚫 Left the queue · pull request dequeued37 min in the queue, with no time running CI. So far
Reason Pull request #32863 has been dequeued Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.
To get back in the queue
Merge conditions not met when it left the queue
Tick the box to put this pull request back in the merge queue (same as
2 merge conditions met
Times in UTC · dashboard · how the merge queue works |
…e bases (#33147) ## What type of PR is this? - [x] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes #33126. ## What this PR does / why we need it: Restore MatrixOne's row-local NULL behavior for `POW` and `POWER` when a finite negative base has a finite non-integer exponent. Both aliases use the same evaluator. For example, a projection of `POWER(base, 0.5)` over bases `1, -2, 4` now returns `1, NULL, 2`. Previously, #32863 captured a domain error outside the per-row callback and returned it after evaluating the batch. That made a single invalid row abort the statement with MySQL error 1690. This change restores the behavior from #28375 requested by #33126 and supersedes the MySQL-compatible exception introduced for #31155. The evaluator passes non-finite results from `math.Pow` to the existing NULL-on-error vector helper. A shared internal error marker avoids formatting an error for each invalid row. The tests cover both aliases, mixed vectors, masks, aggregates, nullable writes, NOT NULL constraints, and prepared executor reuse. A separate prepared projection uses integer overflow to retain the existing check for recovery after a genuine execution error. ### Upgrade compatibility for persisted CHECK constraints An existing CHECK keeps the meaning it had when it was created. MatrixOne v4.2.9 stored both function names as POW overload 0. That overload still raises MySQL error 1690 (SQLSTATE 22003) for a non-finite result. New SQL, including newly created constraints, binds both names to overload 1 and returns NULL for that row. For `CHECK (POWER(b, 0.5) > 0)`, the two definitions admit the following writes after upgrade. | Inserted value | CHECK created on v4.2.9 | CHECK created after upgrade | | --- | --- | --- | | `-2` | 1690 | Accepted (UNKNOWN) | | `0` | 3819 | 3819 | | `4` or `NULL` | Accepted | Accepted | A shutdown upgrade from the official v4.2.9 Linux/arm64 release to commit `50e3a2cfb4` reproduced these results on the same persisted table and on a fresh definition. A second constraint with a variable exponent also retained 1690 for overflow and zero to a negative exponent. Restart, CREATE TABLE LIKE and an ALTER of a column outside the constraint preserved the released binding. A retained v4.2.9 CHECK keeps its error behavior when ALTER converts a directly referenced DOUBLE operand of POW to FLOAT. The new input can be represented exactly by the old overload. A conversion that cannot preserve the bound expression requires explicitly redefining the CHECK. A newly declared CHECK uses row-local NULL semantics. ### Released backups and views A v4.2.9 v1 table dump stores SQL and a schema fingerprint. LOAD can recover a released POW binding in a CHECK, a generated column, or a DEFAULT, including a constant DEFAULT whose stored value no longer contains the function ID. The original CREATE and catalog scopes can differ in their column nullability annotations. Recovery checks the complete candidate trees and rejects differences that change the computed expression. It installs the verified definition and the data in one transaction. LOAD also checks the table and relation fingerprints. It can reproduce the old spelling of an implicit table default when all columns and expressions are independent of text collation, including numeric POW constraints on tables with DATE, DATETIME, UUID, BINARY, or VARBINARY columns. For a v3 dump from an upgraded table, this compatibility path also requires a verified bound-expression payload containing a released POW binding and matching physical and logical fingerprints for the main relation. At `985a0d35e6`, a newly initialized target loaded three v1 archives from the official v4.2.9 release. These covered a STORED generated column with data, a metadata-only STORED column, and a metadata-only VIRTUAL column. All three generated-column catalog payloads matched the release byte for byte, including after restart. The restored columns raised 1690 for a negative base and fractional exponent, while the same expression on a freshly created table produced NULL. A missing data object rolled back both the rows and the expression change. A mismatched target declaration was rejected. Views created on v4.2.9 retain error 1690 when expanded after upgrade, including through nested views. New views and explicit ALTER VIEW statements use row-local NULL. The planner scopes binding to each stored definition, so outer SQL and views from different releases can be combined. Verified at `a74be94e2b` using the [official v4.2.9 release](https://github.com/matrixorigin/matrixone/releases/tag/v4.2.9) on Linux/arm64 and a freshly built macOS/arm64 target with Go 1.27.1. The stopped release data directory was reopened with the target binary for the view checks. The backups were loaded into a separate, newly initialized target. - On a clean target, a full v1 dump restored both original rows and a metadata-only v1 dump restored an anonymous CHECK. Both constraints raised 1690 for a negative fractional power after restart. An unrelated fresh CHECK accepted the same input. - A missing data object failed the load and left the empty target with its original NULL-producing constraint. Retrying with the complete archive succeeded. Changing the predicate from `> 0` to `>= 0` failed the schema check. - After a shutdown upgrade, direct and nested released views raised 1690. An INSERT SELECT from the released view wrote zero rows. A fresh view produced NULL and an explicit ALTER of an old view took effect through an unchanged outer view. These behaviors survived restart. - 117 focused Go tests passed. Focused coverage of executable Go statements in blocks changed by this review fix reached 87.8%. The affected packages passed the pinned static checks. The POWER BVT passed all 113 statements. At `ca96bccd40`, the official v4.2.9 release rejected `-2` before and after altering the constrained column to FLOAT. The target reproduced both outcomes on the same released data after a shutdown upgrade. Both NOT NULL column cases and both forms of DEFAULT loaded from v1 archives. The archived result of POWER(2,3) was 8, the runtime default remained a function call, and the upgraded tables could be dumped again and loaded into newly created tables. A DATE/DATETIME schema mismatch and modified v3 fingerprints were rejected. ### Released generated columns, table dumps, and SQL functions COPY ALTER preserves the bound POWER operation in retained STORED and VIRTUAL generated columns when the operand conversion is safe. An incompatible change requires an explicit new generated definition. On the released `DOUBLE NOT NULL` to `FLOAT NOT NULL` case, the upgraded table still rejects a negative fractional power with 1690 and keeps its valid row. A v3 re-dump can restore a released anonymous CHECK onto the target's generated constraint name. The compatibility check also recognizes the qualified internal CREATE name emitted by the v4.2.9 COPY ALTER implementation for the same logical table. LOAD verifies the declarations, the table and main relation fingerprints and, for v3, the original bound payload. SQL UDF bodies bind their own POWER calls under the definition's stored semantics. Call arguments keep their caller's semantics. Ordinary arithmetic function bodies retain their original catalog text. Cloning a query-bodied function that references its source database preserves its positional arguments as well as its POWER behavior. At `4c1adb1583`, the clean service reopened stopped databases from the official v4.2.9 release. All five released table shapes loaded from both their original v1 archives and their upgraded v3 re-dumps into freshly created targets. Both formats preserved 1690 for a negative fractional power and 3819 for zero. Recovery rejected a changed binary width, mismatched internal table names and a v3 payload with a different CHECK owner. Direct, nested, view, restart, database clone and snapshot clone probes preserved released and current SQL UDF behavior. The POWER BVT passed 113/113 statements and the existing account snapshot UDF section passed 51/51. Coverage of executable Go statements in blocks touched by this review fix reached 91.3%. ### SQL function clones, internal queries, and released table recovery When EXECUTE rebinds a POWER call to the supplied argument types, it preserves the overload selected for the function definition. In a shutdown upgrade from v4.2.9, executing a prepared `SET @out = released_pow(?)` with -2 raises error 1690 and leaves the variable unchanged. The same assignment through a newly defined function stores NULL. Both definitions return 4 for 16. These results were verified with SQL PREPARE and the MySQL binary prepared-statement protocol on the upgraded server and after restart. The SQL function binder and database cloner now use the same parser to distinguish complete queries from scalar expressions. This preserves set queries with a parenthesized first operand, TABLE query terms, and queries preceded by empty statements. In a shutdown upgrade from v4.2.9, the stored function with body `(select 1 where 1=0) union all select 2` returned `2` after upgrade, cloning, and restart. Released POWER functions kept error 1690 for a negative fractional power, and newly created functions returned NULL. A released function with body `perform select 7` also returned 7 after upgrade, cloning, and restart. The same tests verified that `perform` still works as a column name in a scalar function body. Database cloning rewrites source-qualified subqueries inside scalar SQL function bodies and preserves the definition's SQL mode, positional arguments and binary literals. The frontend and the internal query compiler use the same decoder for released and current function definitions. A cloned function reads the clone after the source table is dropped. A view calling POWER can also supply rows to `ivf_create`. Restoring a released table now accounts for ordinary RENAME and the way released SHOW CREATE prints primary keys, unnamed CHECK constraints and NULL defaults. LOAD verifies the declaration, bound expressions and relation fingerprints. A numeric POWER constraint can be restored alongside JSON and vector values. For regular secondary indexes, LOAD checks the actual key parts and reconstructs the released representation of the packed key before accepting the index objects. Using the official Linux/arm64 v4.2.9 server, we generated full v1 archives with table and index data. After a shutdown upgrade we generated v3 archives and loaded both formats into recreated tables. Tests checked the stored data after restart, queried the restored secondary index after another write, and verified 1690 for negative fractional powers and 3819 for a false CHECK. Mismatched predicates, constraint names, vector dimensions and mixed index fingerprints were rejected. Changing the bound type of a JSON default or a vector default’s dimension was rejected even after recomputing the v3 expression digest. The target stayed empty. A missing index object rolled back the load and the genuine archive could be retried. At `07494aeb90`, 160 top-level Go tests passed, including the real projection error recovery test on two consecutive runs. Coverage of executable statements in blocks touched by this follow-up was 89.0% (380/427). The POWER BVT passed all 113 statements, and the four affected packages passed the pinned static checks. Validation on macOS arm64 using Go 1.27.1 and a freshly built single-CN CPU service: - Six new or updated subtests reproduced the original out-of-range error against the base implementation. The full function package passed with the fix. Statement coverage was 100% for `Power` and 76.8% for the package. - Both focused prepared TP projection tests passed. - The two original MOTR regressions at `matrixorigin/motr@f0b2def2` passed all 28 statements. Both issue reproducers also returned NULL over the MySQL protocol. - mo-tester generated the POWER results. Its final comparison passed all 113 statements with the repository-format golden. - `go vet`, the repository-pinned `molint` and `golangci-lint` passed for both changed Go packages. Formatting and `git diff --check` passed. Review follow-up: - The genuine BIGINT projection error test now exercises two success/overflow/recovery cycles on the same prepared executor and compares retained memory after both recoveries. It still asserts the out-of-range error, failed-batch suppression and recovered values. The two focused TP tests passed ten repetitions. The changed compile package passed vet and the repository-pinned static checks. - matrixorigin/motr#358 now includes the companion regression update at `5a7d8a8`. Before the update, seven assertions expecting 1690 failed on this evaluator and the other fifteen passed. The updated case verifies five scalar NULL results, both rows of a mixed vector, and a stored NULL. Together with the existing #25308 and #28137 MOTR cases it passed three replays each. Coordinate the MOTR rollout with this kernel change so the updated regression is run against a build containing it. --------- Co-authored-by: XuPeng-SH <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
What type of PR is this?
Which issue(s) this PR fixes:
issue #31155
Fixes #31155
What this PR does / why we need it:
POW/POWER with a finite negative base and a finite non-integer exponent is mathematically undefined in the real domain, but MatrixOne silently returned a row-local NULL. This PR makes the Power operator reject such arguments with the typed DOUBLE out-of-range error (MySQL 1690, SQLSTATE 22003,
data out of range: data type float64, DOUBLE value is out of range in 'pow(-2,0.5)'), keeping the #28375 row-local NULL semantics untouched for overflow/NaN-input (EXP/COT) cases.It also carries a CI fix found by this PR's own required
-raceUT job:gc/v3.buildTableExistenceMapread each table catalog entry's MVCC chain delete timestamp viaGetDeleteAtLockedwithout the entry lock, racingDBEntry.DropTableEntryByID(entry write lock ->DropEntryLocked->DeleteLocked->InsertLocked), reported three times inTestDataBranchDiffAcrossCheckpointGCAndRestart/gc_checkpoint_restart. The GC reader now takes the same entry's read lock around the delete-at snapshot; no IO, callback, or extra lock inside the critical section, no live-table protection change.The branch now also preserves CI failure observability for the UT-shard cleanup deadline that still fails this job's
pkg/tests/issuesrun on both known CI attempts (its underlying wait owner is not determined by any retained artifact): a bounded test-only diagnostic in the shared fixture, added to the failing error path only. It changes no product code, budget, assertion, expected values, or cleanup semantics and does not claim to fix that cleanup failure or any 31401 behavior — it records the cleanup SQL's start/end/elapsed/error plus a bounded 16KiB goroutine snapshot before the original assert so a future CI occurrence retains additional evidence; the bounded snapshot may truncate or miss the actual wait owner.Scope (5 Power files + 2 GC files + 3 test-only CI files):
pkg/sql/plan/function/func_binary.go: Power evaluates rows first and rejects domain-invalid arguments with the typed error; empty-batch and masked/selected-row safety preserved, NULL inputs stay NULL, integer exponents valid, fix: return NULL for POWER EXP and COT arithmetic failures #28375 semantics unchanged.pkg/sql/plan/function/func_binary_test.go: focused unit coverage for the typed rejection and preserved semantics.test/distributed/cases/function/func_math_power.testandfunc_math_power.result: BVT coverage incl. the prepared-statement overflow-NULL statement before the domain cases, with canonical out-of-range goldens.pkg/sql/compile/tp_allocation_reuse_test.go: real prepared-TP consumer regression - one-constructedpower(v-2, 0.5)projection on the reused TableScan->Filter->Projection prepared pipeline; the typed moerr reaches the caller, the failed batch is never published, the SAME compiled executor recovers exact0/1results.pkg/vm/engine/tae/db/gc/v3/exec_v1.go:buildTableExistenceMapholds the table entry's RLock acrossGetDeleteAtLocked/GetID.pkg/vm/engine/tae/db/gc/v3/executor_test.go: owner regressionTestBuildTableExistenceMapConcurrentCatalogDrop- a real mock-factory catalog and txn manager; 200 concurrentbuildTableExistenceMapsnapshots against 12 serial realDBEntry.DropTableEntryByIDdrops. Every transaction the test starts is registered in its mock txn store (DB entry, table entries, and each dropped entry, exactly like the catalog mock), finalized with explicitCommit(ctx)/Rollback(ctx)on every path, and snapshots taken underownedMuare released before fatal assertions soFailNowcannot deadlock the cleanup net.pkg/tests/issues/issue_31401_scalar_test.go(8th file, test-only): inside the sharedcleanupSQLhelper, when the cleanup statement already returned an error, one bounded 16KiBruntime.Stacksnapshot plus the statement's start/end/elapsed/error/cleanup-ctx error are logged before the unchangedassert.NoErrorf; the successful result, both original cleanup budgets, the returned error, and the guarded deferred cleanup ordering retain their existing semantics. This is measurement-only: it does not alter or interpret any result, and no cleanup failure is claimed fixed.pkg/objectio/arena_pool_test.go: replace the burst-reaping test's scheduler-sensitive real-time warmup with controlledtesting/synctestnormal and deliberately delayed first-fire schedules. The actual pool reaper still runs; final synchronization includes buffer frees after the pool unlock. Snapshots release the pool lock before fatal assertions, and borrowed arenas and bubble-owned timers have explicit cleanup.pkg/embed/cdc_control_status_test.go: bound only the initial idempotent, read-onlyGetClusterStatefixture setup to three attempts on the same two-minute context, retrying onlyerrors.Is(err, dragonboat.ErrTimeout). Other errors, persistent timeouts and cancellation still fail; claims, heartbeats, writes and their assertions are unchanged. Seven deterministic cases check request bounds, error identity, context identity and cancellation. The HAKeeper stall's underlying cause remains UNKNOWN.Verification performed:
Focused owning unit suite for the Power change; the full TP-reuse trio
TestTPReusePowerProjectionDomainErrorRecovery|TestTPReusableOperatorsAllocationScope|TestTPReusablePipelineQueriesin the CI UT-matching mode via the tree'smo-cgo-testwrapper:CGO_ENABLED=1 .agents/skills/mo-dev/scripts/mo-cgo-test -race -short -tags matrixone_test -count=1 -v -timeout=10m -run '^(TestTPReusePowerProjectionDomainErrorRecovery|TestTPReusableOperatorsAllocationScope|TestTPReusablePipelineQueries)$' ./pkg/sql/compile=> all PASS, 0 data-race reports, process returncode 0.The GC owner regression in the fatal-cleanup-hardened form, same matching mode:
CGO_ENABLED=1 .agents/skills/mo-dev/scripts/mo-cgo-test -race -short -tags matrixone_test -count=1 -v -timeout=10m -run '^TestBuildTableExistenceMapConcurrentCatalogDrop$' ./pkg/vm/engine/tae/db/gc/v3=> one RUN / one PASS, 0 data-race reports, process returncode 0, source/native SHAs unchanged around the run (receipts retained).The exact CI-failed GC target with the accepted fix at its recorded validation base (reused because its executed code paths and native inputs are unchanged):
CGO_ENABLED=1 .agents/skills/mo-dev/scripts/mo-cgo-test -race -short -tags matrixone_test -count=1 -v -run '^TestDataBranchDiffAcrossCheckpointGCAndRestart$/^gc_checkpoint_restart$' ./pkg/embed=> PASS (ok github.com/matrixorigin/matrixone/pkg/embed), 0 data-race reports.This batch's retained local matching run of
^TestIssue31401ScalarRefreshProgress$used-race -short -tags matrixone_test -count=1 -v: process RC0, 17 RUN / 17 PASS including the parent and all 16 modes. It was a local non-reproduction at the recorded validation revision, reused for unchanged executed paths; the newly added diagnostic's error branch was not exercised by that passing run. Another PR's local probe is not counted as an additional own-batch pass. The original CI failure's wait owner remains UNKNOWN, and the diagnostic does not fix or explain it. The retained CI artifacts remain truncated, with omitted stderr/link/scratch evidence.The branch was linearly rebased onto the current upstream main (
035af9968069 fix(frontend): handle missing subscriber accounts in SHOW PUBLICATIONS (#32901)) with no merge commits; the eight published files remain byte-identical to their accepted blobs; the two additional changes are the arena and CDC test fixtures described above.Current official test-aware static-analysis closure at main
035af996806917b23d9428695e0295b65cb16356: 170 required packages, all covered. The previous 169-package closure comprised 107 identity-qualified reused analyses, 4 owner receipts and 58 fresh package checks. Adding the arena test selectspkg/objectio; changing the CDC test invalidates the previouspkg/embedproof. The final closure therefore has 168 still-valid analyses plus fresh pinned dual-checker passes for./pkg/objectioand./pkg/embed(both original process RC0,0 issues.). The official inventory and selector were refreshed for the actual test imports; native/configuration identities and unchanged analysis inputs qualify the reused evidence. No repository-wide lint fallback, disabled checker or suppression was used.Executed current missing-package command (58 explicit packages, original RC0 for the fatal two-checker make target):
The separate current issues-owner command was
CGO_ENABLED=1 make static-check-selected STATIC_CHECK_PACKAGES=./pkg/tests/issues, original RC0. Earlier valid function/compile/GC owner checks and the 107 unaffected analyses were reused only after source/native/config and dependency closure checks; no Go tests were repeated for this diagnostic-only timestamp move.Additional executed missing-owner checks (each original process RC0, repository-pinned molint and golangci-lint):
Additional matching verification:
CGO_ENABLED=1 .agents/skills/mo-dev/scripts/mo-cgo-test -mod=readonly -count=1 -short -v -tags matrixone_test -covermode=set -run '^TestArenaBurstReleasedWhileStillActive$' ./pkg/objectio=> original process RC0, 3 RUN/PASS; adjacent timer-contract tests also passed once. The earlier failing local variants remain recorded.CGO_ENABLED=1 .agents/skills/mo-dev/scripts/mo-cgo-test -race -short -tags matrixone_test -count=1 -v -timeout=15m -run '^(TestCDCSourceGenerationGuardAcrossCN|TestCDCInitialClusterStateReadinessBounds)$' ./pkg/embed=> original process RC0, 14 RUN including seven deterministic helper cases and the real cross-CN parent/subtests. An initial import-path setup failure had RC1 and zero selected tests; it was corrected before this successful run. These local passes do not establish CI success or explain the HAKeeper stall.Current official test-aware required package selection (170 literal packages; selection, not a claim that all 170 were rerun)
CI note: CI must be re-observed after the PR head is updated; there is no green guarantee at publication time and no historical attempt is claimed as the current state.