Repository navigation
fix: align user-level lock argument semantics - #28783
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? |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Reviewed the full diff at head 07076bac6a8f858f4f391286197a0b251c8a65df; exact-head CI (UT, SCA, coverage, relevant BVT, CodeQL) is green. The name preflight-before-side-effects design, NULL timeout FastFail behavior, selected-row handling, and fixed-width DECIMAL conversion look sound; I found no unrelated lock ownership/resource regression. One compatibility issue to resolve or explicitly accept: negative timeout is no longer infinite. Before this change, userLevelLockContext used WaitPolicy_Wait with no deadline for every negative DOUBLE timeout; the new conversion maps negative rounded values to maxUserLevelLockTimeoutSeconds (about 68 years). MySQL 8.4 documents negative GET_LOCK timeout as infinite (reference). Please preserve an explicit no-deadline state for negative values across DOUBLE and DECIMAL domains, or document why this intentional behavior change is acceptable, and add a regression test. This is narrow (the finite cap is practically long) but the current PR description says timeout caps are unchanged, which is not true for this case.
…8801) ## What type of PR is this? - [ ] API-change - [ ] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [x] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Related to #28653, #28249, and #28250. This PR only changes regression tests; it does not itself fix or close these issues. The GROUP_CONCAT production fix was merged in #28702, and the user-level lock behavior fix was merged in #28783. ## What this PR does / why we need it: This test-only follow-up consolidates related SQL-function coverage while preserving distinct test oracles: - Keeps the existing 70,000-byte text case and adds exact-output JSON and float32-vector cases through the real GROUP_CONCAT ordered-spill path. JSON and vector rendered outputs are each 65,536 bytes. The test asserts spill occurred before flush, checks complete output bytes, and verifies memory-pool cleanup. - Moves the three unique free-lock timeout-type probes (DOUBLE `0`, DECIMAL `0.5`, and DOUBLE `0.5`) into the broader `user_lock.sql` case, then removes the duplicate `func_user_lock.test/.result`. Existing lock lifecycle, contention, NULL-name, NULL-timeout, and case-insensitive checks remain. The precise DECIMAL-vs-DOUBLE rounding behavior remains owned by `TestGetLockDecimalTimeoutUsesDecimalRounding`. - Removes one adjacent, identical basic GROUP_CONCAT SELECT and its duplicate expected-output block. The first assertion remains; this was not a controlled cache/reuse test, and no measured runtime improvement is claimed. No production code or behavior changes. ## Test Plan - [x] Focused CGo UTs: `TestGroupConcatLargeValuesAcrossOrderedSpill`, `TestAppendGroupConcatDataCoversTypes`, and `TestGroupConcatVectorValuesAcrossFinalizers` — PASS. - [x] Full `./pkg/sql/colexec/aggexec` test package — PASS (1.346s). - [x] `go vet -mod=readonly ./pkg/sql/colexec/aggexec` with repository-matched CGo flags — PASS. - [x] Incremental `golangci-lint` for `./pkg/sql/colexec/aggexec` against the PR base — 0 issues. - [x] On 55, using a service built from current main `68860942354a7deb58158197e1e458d6094ec1bd` in an isolated network namespace, ran each modified BVT twice with mo-tester: - `user_lock.sql`: 67/67 passed on both runs. - `function_group_concat.sql`: 228/228 passed on both runs. - [x] `gofmt` and `git diff --check` — PASS. QA can run the two BVT cases with `./run.sh -n -g -p <path-to-case.sql>` against a test-owned MatrixOne instance. Both cases clean up their database/table state and were rerun successfully on the same isolated instance. CI was not awaited for this update.
## What type of PR is this? - [x] BUG ## Which issue(s) this PR fixes: Fixes matrixorigin#28249 Fixes matrixorigin#28250 ## What this PR does / why we need it: ### Root cause The user-level lock functions did not consistently preserve MySQL argument semantics. NULL/invalid lock names were not mapped to MySQL's `ER_USER_LOCK_WRONG_NAME` contract. `GET_LOCK` also used a single DOUBLE timeout domain, so a DECIMAL `0.5` could round like DOUBLE and become a zero-second fast-fail instead of the one-second wait selected by MySQL's DECIMAL-to-integer conversion. A bare prepared timeout marker was provisionally bound as DOUBLE without a test proving the generic execute-time specialization path. ### Changes - Return MySQL error 3057 for NULL, empty, embedded-NUL, and invalid-UTF-8 lock names across `GET_LOCK`, `RELEASE_LOCK`, `IS_FREE_LOCK`, and `IS_USED_LOCK`. Preserve the existing separate overlength behavior. - Treat a NULL timeout as zero seconds: acquire a free lock, preserve same-session reentrancy, and fail immediately when another session owns it. - Preserve timeout source domains: DOUBLE uses ties-to-even; DECIMAL64/128/256 uses exact fixed-width HALF_UP conversion; explicit casts retain their selected domain. Non-DECIMAL integer/string operands retain MatrixOne's existing DOUBLE coercion; this PR does not change global cast behavior. - Keep existing DOUBLE overload ID 0 and append DECIMAL overloads. Prepared bare markers use the existing generic runtime specialization; explicit `CAST` remains authoritative. - Preflight selected batch rows before lock-service operations so an invalid later lock name or NaN cannot leave earlier rows' lock side effects behind. Rows excluded by the selection mask are not validated or acted on. - Add focused planner/function UTs and SQL BVT coverage for name errors, NULL timeouts, DECIMAL-vs-DOUBLE fractional timeouts, and prepared overload selection. ### Performance and risks Vector execution adds one O(batch size) preflight scan before the normal evaluation pass. Constant timeouts are converted once per invocation; varying DECIMAL values use fixed-width arithmetic without float conversion, per-row big integers, or O(batch-size) scratch allocation. The scan adds validation work on a side-effecting function path but prevents invalid later inputs from partially changing lock state. Preflight does not make user-level locks transactional: a lock-service error, cancellation, or result-vector append failure after execution starts can still occur after earlier rows have taken effect. Lock ownership, timeout caps, and lock-service behavior otherwise remain unchanged. ### Validation - `gofmt` and `git diff --cached --check`: passed. - Incremental `golangci-lint` for `pkg/common/moerr`, `pkg/sql/plan`, and `pkg/sql/plan/function` against base `0d701bb966f3dbc313d6659baec1c47762d1c186`: passed, 0 issues. - Targeted planner UT wrapper stopped before compilation because this isolated worktree lacks provenance-stamped `cgo/libmo.dylib`; no UT pass is claimed. Local BVT was not run because unrelated MatrixOne services are active; exact-head CI remains the runtime verification. - GPT-6 Astra medium final review: PASS on staged diff fingerprint `eac682749af3696a42a516007577da7d743cc3ac24de6ee9d294b1c22f9e82e2`. Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…trixorigin#28801) ## What type of PR is this? - [ ] API-change - [ ] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [x] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Related to matrixorigin#28653, matrixorigin#28249, and matrixorigin#28250. This PR only changes regression tests; it does not itself fix or close these issues. The GROUP_CONCAT production fix was merged in matrixorigin#28702, and the user-level lock behavior fix was merged in matrixorigin#28783. ## What this PR does / why we need it: This test-only follow-up consolidates related SQL-function coverage while preserving distinct test oracles: - Keeps the existing 70,000-byte text case and adds exact-output JSON and float32-vector cases through the real GROUP_CONCAT ordered-spill path. JSON and vector rendered outputs are each 65,536 bytes. The test asserts spill occurred before flush, checks complete output bytes, and verifies memory-pool cleanup. - Moves the three unique free-lock timeout-type probes (DOUBLE `0`, DECIMAL `0.5`, and DOUBLE `0.5`) into the broader `user_lock.sql` case, then removes the duplicate `func_user_lock.test/.result`. Existing lock lifecycle, contention, NULL-name, NULL-timeout, and case-insensitive checks remain. The precise DECIMAL-vs-DOUBLE rounding behavior remains owned by `TestGetLockDecimalTimeoutUsesDecimalRounding`. - Removes one adjacent, identical basic GROUP_CONCAT SELECT and its duplicate expected-output block. The first assertion remains; this was not a controlled cache/reuse test, and no measured runtime improvement is claimed. No production code or behavior changes. ## Test Plan - [x] Focused CGo UTs: `TestGroupConcatLargeValuesAcrossOrderedSpill`, `TestAppendGroupConcatDataCoversTypes`, and `TestGroupConcatVectorValuesAcrossFinalizers` — PASS. - [x] Full `./pkg/sql/colexec/aggexec` test package — PASS (1.346s). - [x] `go vet -mod=readonly ./pkg/sql/colexec/aggexec` with repository-matched CGo flags — PASS. - [x] Incremental `golangci-lint` for `./pkg/sql/colexec/aggexec` against the PR base — 0 issues. - [x] On 55, using a service built from current main `68860942354a7deb58158197e1e458d6094ec1bd` in an isolated network namespace, ran each modified BVT twice with mo-tester: - `user_lock.sql`: 67/67 passed on both runs. - `function_group_concat.sql`: 228/228 passed on both runs. - [x] `gofmt` and `git diff --check` — PASS. QA can run the two BVT cases with `./run.sh -n -g -p <path-to-case.sql>` against a test-owned MatrixOne instance. Both cases clean up their database/table state and were rerun successfully on the same isolated instance. CI was not awaited for this update.
## What type of PR is this? - [x] BUG ## Which issue(s) this PR fixes: Fixes matrixorigin#28249 Fixes matrixorigin#28250 ## What this PR does / why we need it: ### Root cause The user-level lock functions did not consistently preserve MySQL argument semantics. NULL/invalid lock names were not mapped to MySQL's `ER_USER_LOCK_WRONG_NAME` contract. `GET_LOCK` also used a single DOUBLE timeout domain, so a DECIMAL `0.5` could round like DOUBLE and become a zero-second fast-fail instead of the one-second wait selected by MySQL's DECIMAL-to-integer conversion. A bare prepared timeout marker was provisionally bound as DOUBLE without a test proving the generic execute-time specialization path. ### Changes - Return MySQL error 3057 for NULL, empty, embedded-NUL, and invalid-UTF-8 lock names across `GET_LOCK`, `RELEASE_LOCK`, `IS_FREE_LOCK`, and `IS_USED_LOCK`. Preserve the existing separate overlength behavior. - Treat a NULL timeout as zero seconds: acquire a free lock, preserve same-session reentrancy, and fail immediately when another session owns it. - Preserve timeout source domains: DOUBLE uses ties-to-even; DECIMAL64/128/256 uses exact fixed-width HALF_UP conversion; explicit casts retain their selected domain. Non-DECIMAL integer/string operands retain MatrixOne's existing DOUBLE coercion; this PR does not change global cast behavior. - Keep existing DOUBLE overload ID 0 and append DECIMAL overloads. Prepared bare markers use the existing generic runtime specialization; explicit `CAST` remains authoritative. - Preflight selected batch rows before lock-service operations so an invalid later lock name or NaN cannot leave earlier rows' lock side effects behind. Rows excluded by the selection mask are not validated or acted on. - Add focused planner/function UTs and SQL BVT coverage for name errors, NULL timeouts, DECIMAL-vs-DOUBLE fractional timeouts, and prepared overload selection. ### Performance and risks Vector execution adds one O(batch size) preflight scan before the normal evaluation pass. Constant timeouts are converted once per invocation; varying DECIMAL values use fixed-width arithmetic without float conversion, per-row big integers, or O(batch-size) scratch allocation. The scan adds validation work on a side-effecting function path but prevents invalid later inputs from partially changing lock state. Preflight does not make user-level locks transactional: a lock-service error, cancellation, or result-vector append failure after execution starts can still occur after earlier rows have taken effect. Lock ownership, timeout caps, and lock-service behavior otherwise remain unchanged. ### Validation - `gofmt` and `git diff --cached --check`: passed. - Incremental `golangci-lint` for `pkg/common/moerr`, `pkg/sql/plan`, and `pkg/sql/plan/function` against base `0d701bb966f3dbc313d6659baec1c47762d1c186`: passed, 0 issues. - Targeted planner UT wrapper stopped before compilation because this isolated worktree lacks provenance-stamped `cgo/libmo.dylib`; no UT pass is claimed. Local BVT was not run because unrelated MatrixOne services are active; exact-head CI remains the runtime verification. - GPT-6 Astra medium final review: PASS on staged diff fingerprint `eac682749af3696a42a516007577da7d743cc3ac24de6ee9d294b1c22f9e82e2`. Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…trixorigin#28801) ## What type of PR is this? - [ ] API-change - [ ] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [x] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Related to matrixorigin#28653, matrixorigin#28249, and matrixorigin#28250. This PR only changes regression tests; it does not itself fix or close these issues. The GROUP_CONCAT production fix was merged in matrixorigin#28702, and the user-level lock behavior fix was merged in matrixorigin#28783. ## What this PR does / why we need it: This test-only follow-up consolidates related SQL-function coverage while preserving distinct test oracles: - Keeps the existing 70,000-byte text case and adds exact-output JSON and float32-vector cases through the real GROUP_CONCAT ordered-spill path. JSON and vector rendered outputs are each 65,536 bytes. The test asserts spill occurred before flush, checks complete output bytes, and verifies memory-pool cleanup. - Moves the three unique free-lock timeout-type probes (DOUBLE `0`, DECIMAL `0.5`, and DOUBLE `0.5`) into the broader `user_lock.sql` case, then removes the duplicate `func_user_lock.test/.result`. Existing lock lifecycle, contention, NULL-name, NULL-timeout, and case-insensitive checks remain. The precise DECIMAL-vs-DOUBLE rounding behavior remains owned by `TestGetLockDecimalTimeoutUsesDecimalRounding`. - Removes one adjacent, identical basic GROUP_CONCAT SELECT and its duplicate expected-output block. The first assertion remains; this was not a controlled cache/reuse test, and no measured runtime improvement is claimed. No production code or behavior changes. ## Test Plan - [x] Focused CGo UTs: `TestGroupConcatLargeValuesAcrossOrderedSpill`, `TestAppendGroupConcatDataCoversTypes`, and `TestGroupConcatVectorValuesAcrossFinalizers` — PASS. - [x] Full `./pkg/sql/colexec/aggexec` test package — PASS (1.346s). - [x] `go vet -mod=readonly ./pkg/sql/colexec/aggexec` with repository-matched CGo flags — PASS. - [x] Incremental `golangci-lint` for `./pkg/sql/colexec/aggexec` against the PR base — 0 issues. - [x] On 55, using a service built from current main `68860942354a7deb58158197e1e458d6094ec1bd` in an isolated network namespace, ran each modified BVT twice with mo-tester: - `user_lock.sql`: 67/67 passed on both runs. - `function_group_concat.sql`: 228/228 passed on both runs. - [x] `gofmt` and `git diff --check` — PASS. QA can run the two BVT cases with `./run.sh -n -g -p <path-to-case.sql>` against a test-owned MatrixOne instance. Both cases clean up their database/table state and were rerun successfully on the same isolated instance. CI was not awaited for this update.
## What type of PR is this? - [x] BUG ## Which issue(s) this PR fixes: Fixes matrixorigin#28249 Fixes matrixorigin#28250 ## What this PR does / why we need it: ### Root cause The user-level lock functions did not consistently preserve MySQL argument semantics. NULL/invalid lock names were not mapped to MySQL's `ER_USER_LOCK_WRONG_NAME` contract. `GET_LOCK` also used a single DOUBLE timeout domain, so a DECIMAL `0.5` could round like DOUBLE and become a zero-second fast-fail instead of the one-second wait selected by MySQL's DECIMAL-to-integer conversion. A bare prepared timeout marker was provisionally bound as DOUBLE without a test proving the generic execute-time specialization path. ### Changes - Return MySQL error 3057 for NULL, empty, embedded-NUL, and invalid-UTF-8 lock names across `GET_LOCK`, `RELEASE_LOCK`, `IS_FREE_LOCK`, and `IS_USED_LOCK`. Preserve the existing separate overlength behavior. - Treat a NULL timeout as zero seconds: acquire a free lock, preserve same-session reentrancy, and fail immediately when another session owns it. - Preserve timeout source domains: DOUBLE uses ties-to-even; DECIMAL64/128/256 uses exact fixed-width HALF_UP conversion; explicit casts retain their selected domain. Non-DECIMAL integer/string operands retain MatrixOne's existing DOUBLE coercion; this PR does not change global cast behavior. - Keep existing DOUBLE overload ID 0 and append DECIMAL overloads. Prepared bare markers use the existing generic runtime specialization; explicit `CAST` remains authoritative. - Preflight selected batch rows before lock-service operations so an invalid later lock name or NaN cannot leave earlier rows' lock side effects behind. Rows excluded by the selection mask are not validated or acted on. - Add focused planner/function UTs and SQL BVT coverage for name errors, NULL timeouts, DECIMAL-vs-DOUBLE fractional timeouts, and prepared overload selection. ### Performance and risks Vector execution adds one O(batch size) preflight scan before the normal evaluation pass. Constant timeouts are converted once per invocation; varying DECIMAL values use fixed-width arithmetic without float conversion, per-row big integers, or O(batch-size) scratch allocation. The scan adds validation work on a side-effecting function path but prevents invalid later inputs from partially changing lock state. Preflight does not make user-level locks transactional: a lock-service error, cancellation, or result-vector append failure after execution starts can still occur after earlier rows have taken effect. Lock ownership, timeout caps, and lock-service behavior otherwise remain unchanged. ### Validation - `gofmt` and `git diff --cached --check`: passed. - Incremental `golangci-lint` for `pkg/common/moerr`, `pkg/sql/plan`, and `pkg/sql/plan/function` against base `0d701bb966f3dbc313d6659baec1c47762d1c186`: passed, 0 issues. - Targeted planner UT wrapper stopped before compilation because this isolated worktree lacks provenance-stamped `cgo/libmo.dylib`; no UT pass is claimed. Local BVT was not run because unrelated MatrixOne services are active; exact-head CI remains the runtime verification. - GPT-6 Astra medium final review: PASS on staged diff fingerprint `eac682749af3696a42a516007577da7d743cc3ac24de6ee9d294b1c22f9e82e2`. Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…trixorigin#28801) ## What type of PR is this? - [ ] API-change - [ ] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [x] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Related to matrixorigin#28653, matrixorigin#28249, and matrixorigin#28250. This PR only changes regression tests; it does not itself fix or close these issues. The GROUP_CONCAT production fix was merged in matrixorigin#28702, and the user-level lock behavior fix was merged in matrixorigin#28783. ## What this PR does / why we need it: This test-only follow-up consolidates related SQL-function coverage while preserving distinct test oracles: - Keeps the existing 70,000-byte text case and adds exact-output JSON and float32-vector cases through the real GROUP_CONCAT ordered-spill path. JSON and vector rendered outputs are each 65,536 bytes. The test asserts spill occurred before flush, checks complete output bytes, and verifies memory-pool cleanup. - Moves the three unique free-lock timeout-type probes (DOUBLE `0`, DECIMAL `0.5`, and DOUBLE `0.5`) into the broader `user_lock.sql` case, then removes the duplicate `func_user_lock.test/.result`. Existing lock lifecycle, contention, NULL-name, NULL-timeout, and case-insensitive checks remain. The precise DECIMAL-vs-DOUBLE rounding behavior remains owned by `TestGetLockDecimalTimeoutUsesDecimalRounding`. - Removes one adjacent, identical basic GROUP_CONCAT SELECT and its duplicate expected-output block. The first assertion remains; this was not a controlled cache/reuse test, and no measured runtime improvement is claimed. No production code or behavior changes. ## Test Plan - [x] Focused CGo UTs: `TestGroupConcatLargeValuesAcrossOrderedSpill`, `TestAppendGroupConcatDataCoversTypes`, and `TestGroupConcatVectorValuesAcrossFinalizers` — PASS. - [x] Full `./pkg/sql/colexec/aggexec` test package — PASS (1.346s). - [x] `go vet -mod=readonly ./pkg/sql/colexec/aggexec` with repository-matched CGo flags — PASS. - [x] Incremental `golangci-lint` for `./pkg/sql/colexec/aggexec` against the PR base — 0 issues. - [x] On 55, using a service built from current main `68860942354a7deb58158197e1e458d6094ec1bd` in an isolated network namespace, ran each modified BVT twice with mo-tester: - `user_lock.sql`: 67/67 passed on both runs. - `function_group_concat.sql`: 228/228 passed on both runs. - [x] `gofmt` and `git diff --check` — PASS. QA can run the two BVT cases with `./run.sh -n -g -p <path-to-case.sql>` against a test-owned MatrixOne instance. Both cases clean up their database/table state and were rerun successfully on the same isolated instance. CI was not awaited for this update.
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #28249
Fixes #28250
What this PR does / why we need it:
Root cause
The user-level lock functions did not consistently preserve MySQL argument semantics. NULL/invalid lock names were not mapped to MySQL's
ER_USER_LOCK_WRONG_NAMEcontract.GET_LOCKalso used a single DOUBLE timeout domain, so a DECIMAL0.5could round like DOUBLE and become a zero-second fast-fail instead of the one-second wait selected by MySQL's DECIMAL-to-integer conversion. A bare prepared timeout marker was provisionally bound as DOUBLE without a test proving the generic execute-time specialization path.Changes
GET_LOCK,RELEASE_LOCK,IS_FREE_LOCK, andIS_USED_LOCK. Preserve the existing separate overlength behavior.CASTremains authoritative.Performance and risks
Vector execution adds one O(batch size) preflight scan before the normal evaluation pass. Constant timeouts are converted once per invocation; varying DECIMAL values use fixed-width arithmetic without float conversion, per-row big integers, or O(batch-size) scratch allocation. The scan adds validation work on a side-effecting function path but prevents invalid later inputs from partially changing lock state.
Preflight does not make user-level locks transactional: a lock-service error, cancellation, or result-vector append failure after execution starts can still occur after earlier rows have taken effect. Lock ownership, timeout caps, and lock-service behavior otherwise remain unchanged.
Validation
gofmtandgit diff --cached --check: passed.golangci-lintforpkg/common/moerr,pkg/sql/plan, andpkg/sql/plan/functionagainst base0d701bb966f3dbc313d6659baec1c47762d1c186: passed, 0 issues.cgo/libmo.dylib; no UT pass is claimed. Local BVT was not run because unrelated MatrixOne services are active; exact-head CI remains the runtime verification.eac682749af3696a42a516007577da7d743cc3ac24de6ee9d294b1c22f9e82e2.