PHOENIX-7905 :- Add transform lock primitive on SYSTEM.MUTEX with narrow caller wiring#2534
Open
lokiore wants to merge 1 commit into
Open
PHOENIX-7905 :- Add transform lock primitive on SYSTEM.MUTEX with narrow caller wiring#2534lokiore wants to merge 1 commit into
lokiore wants to merge 1 commit into
Conversation
…row caller wiring Introduces acquireTransformLock / releaseTransformLock on ConnectionQueryServices, backed by SYSTEM.MUTEX with the existing 15-min TTL auto-expiry. Wires both transform-triggering DDL paths (MetaDataClient.addColumn, MetaDataClient.alterIndex) with narrow scope: acquire only inside the if-isTransformNeeded branch after pre-validation, with an under-lock re-check via getTableNoCache to close the TOCTOU window between the first check and the acquire. Non-transform-triggering ALTERs (SET TTL, plain ADD COLUMN, IMMUTABLE_ROWS toggle, etc.) do not contend on the lock. Throws CANNOT_MODIFY_TABLE_WITH_TRANSFORM_IN_PROGRESS (42Z25) when held. This is a coarse advisory lock with no fencing token; the TTL bounds worst-case hold time. Generated-by: Claude Code (Opus 4.7)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Introduces a coarse advisory lock primitive (
acquireTransformLock/releaseTransformLock) onConnectionQueryServices, backed bySYSTEM.MUTEXwith the existing 15-min TTL auto-expiry. Wires both transform-triggering DDL paths inMetaDataClient(addColumn,alterIndex) with a narrow scope: acquire only inside theif (isTransformNeeded)branch after pre-validation, with an under-lock re-check viagetTableNoCacheto close the TOCTOU window between the firstcheckIsTransformNeededcall and the lock acquire.Non-transform-triggering ALTERs (
SET TTL, plainADD COLUMN,IMMUTABLE_ROWStoggle, etc.) do not contend on this lock. The lock is held through the addColumn / alterIndex CAS so that a concurrent caller can't sneak in betweenaddTransformand the metadata CAS. When held by another caller, throwsCANNOT_MODIFY_TABLE_WITH_TRANSFORM_IN_PROGRESS(SQLState42Z25) — message instructs the caller to retry once the in-progress modification completes (or after the SYSTEM.MUTEX 15-min TTL auto-expires).This is a coarse advisory lock with no fencing token; the TTL bounds worst-case hold time.
Scope-narrowing matrix
ALTER TABLE T ADD COLUMN c INTEGERALTER TABLE T SET TTL = 100ALTER TABLE T SET IMMUTABLE_ROWS = trueALTER TABLE T SET IMMUTABLE_STORAGE_SCHEME = SINGLE_CELL_ARRAY_WITH_OFFSETSALTER INDEX I ON T REBUILDALTER INDEX I ON T (transform-triggering)Files changed
phoenix-core-client/src/main/java/org/apache/phoenix/exception/SQLExceptionCode.java— addsCANNOT_MODIFY_TABLE_WITH_TRANSFORM_IN_PROGRESS(1225,42Z25)phoenix-core-client/src/main/java/org/apache/phoenix/query/ConnectionQueryServices.java— addsacquireTransformLock/releaseTransformLockinterface methods with Javadocphoenix-core-client/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java— addsTRANSFORM_LOCK_MARKER = "TRANSFORM_LOCK"+ impl onwriteMutexCell/deleteMutexCellphoenix-core-client/src/main/java/org/apache/phoenix/query/ConnectionlessQueryServicesImpl.java— connectionless stubsphoenix-core-client/src/main/java/org/apache/phoenix/query/DelegateConnectionQueryServices.java— forward-delegatephoenix-core-client/src/main/java/org/apache/phoenix/schema/MetaDataClient.java— wires lock intoaddColumnandalterIndexwith narrow scope, under-lock re-check, lock-held-through-CAS shapephoenix-core/src/it/java/org/apache/phoenix/end2end/transform/TransformLockIT.java— new IT class, 7 tests includingtestNonTransformAlterDoesNotAcquireLock(proves narrow scope) andtestConcurrentAlterTableSerializesViaTransformLock(proves serialization at the DDL callsite)Verification
mvn spotless:apply -DskipTests -q— clean, no driftmvn install -pl phoenix-core-client,phoenix-core,phoenix-core-server -am -DskipTests— BUILD SUCCESS (14.76s)mvn -pl phoenix-core failsafe:integration-test failsafe:verify -Dit.test=TransformLockIT— 7/7 PASS (61.15s)TransformITregression sweep — same 4 failures + 2 errors as the upstream/PHOENIX-7904-feature baseline; pre-existing, NOT introduced by this PR. These inherit from PHOENIX-7794 (Eventually Consistent Global Secondary Indexes, dual-write code path) and are tracked for fix as part of PHOENIX-7907 / Gap B which touches the same code path. Verified pre-existing via baseline-Edit-revert against the worktree before this change.Cross-link
Part of the PHOENIX-7904 Online Schema Change umbrella. PR targets
PHOENIX-7904-feature(NOT master).AI Disclosure
Per the ASF generative-tooling policy, this PR was authored with AI assistance.
claude-opus-4-7[1m]TransformLockITwere authored under the same AI-assisted process and reviewed by the human author. Pass/fail counts above are from local runs on the author's machine.The
Generated-by:commit trailer follows the precedent set by PHOENIX-7844 / PR #2462.