IGNITE-28724 Calcite engine. Support SELECT ... FOR UPDATE query - #13366
Open
vldpyatkov wants to merge 19 commits into
Open
IGNITE-28724 Calcite engine. Support SELECT ... FOR UPDATE query#13366vldpyatkov wants to merge 19 commits into
vldpyatkov wants to merge 19 commits into
Conversation
zstan
reviewed
Aug 4, 2026
tkalkirill
reviewed
Aug 5, 2026
zstan
reviewed
Aug 6, 2026
zstan
reviewed
Aug 7, 2026
tkalkirill
reviewed
Aug 7, 2026
zstan
reviewed
Aug 7, 2026
…che-based tables.
There was a problem hiding this comment.
Pull request overview
This PR adds SELECT ... FOR UPDATE support to Ignite’s Calcite query engine by extending parsing/planning/execution to acquire pessimistic row-level locks for selected rows, and by introducing the _VER system column to validate row versions during lock acquisition.
Changes:
- Add SQL grammar + AST node for
SELECT ... FOR UPDATE [OF ...] [WAIT n | NOWAIT], includingEXPLAIN PLAN FORsupport. - Implement planning/execution pipeline that appends hidden
_KEY/_VAL/_VERcolumns, collects lock targets, and acquires locks (with retry on version change). - Introduce
_VERas a system column across schema/validation/table descriptors and add integration/parser tests.
Reviewed changes
Copilot reviewed 24 out of 27 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| modules/core/src/main/java/org/apache/ignite/internal/processors/query/schema/management/SchemaManager.java | Treat _VER as a reserved/system field name during schema validation. |
| modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryUtils.java | Add _VER constant and shared helper for system-field checks. |
| modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryTypeDescriptorImpl.java | Treat _KEY/_VAL/_VER as system fields in field existence checks. |
| modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java | Retry post-lock version read on GridCacheEntryRemovedException. |
| modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java | Adjust version unmapping logic for savepoint-related unlocks. |
| modules/calcite/src/test/java/org/apache/ignite/testsuites/IntegrationTestSuite.java | Register new Calcite integration tests (system columns, deadlock, FOR UPDATE). |
| modules/calcite/src/test/java/org/apache/ignite/testsuites/IgniteCalciteTestSuite.java | Register new parser test for SELECT ... FOR UPDATE. |
| modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/sql/SqlSelectForUpdateParserTest.java | New unit tests for parsing SELECT ... FOR UPDATE variants. |
| modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/SystemColumnsScanTest.java | New integration tests ensuring _KEY/_VAL/_VER behavior and visibility rules. |
| modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/SelectForUpdateIntegrationTest.java | New integration tests for locking semantics, OF/WAIT/NOWAIT, retries, and unsupported shapes. |
| modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/BulkOperationDeadlockIntegrationTest.java | New concurrency test ensuring bulk ops don’t deadlock (adds sustained load). |
| modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/AbstractBasicIntegrationTest.java | Make SQL execution tx-aware via QueryContext (xid) + suspend/resume. |
| modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/util/IgniteResource.java | Add validation/runtime messages for system column updates, WAIT, and FOR UPDATE errors. |
| modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/sql/IgniteSqlSelectForUpdate.java | New Calcite SQL node representing SELECT ... FOR UPDATE. |
| modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/sql/generated/IgniteSqlParserImplConstants.java | Generated parser constants updated for new tokens/keywords. |
| modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/schema/CacheTableDescriptorImpl.java | Add _VER system descriptor and block updates to system columns. |
| modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/RootQuery.java | Add retryQuery() to re-run the same plan with remaining timeout/context. |
| modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/prepare/SelectForUpdatePlan.java | New query plan wrapper for FOR UPDATE execution. |
| modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/prepare/QueryPlan.java | Add FOR_UPDATE query plan type. |
| modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/prepare/PrepareServiceImpl.java | Add preparation logic for FOR UPDATE (shape checks, OF resolution, hidden columns). |
| modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/prepare/IgniteSqlValidator.java | Hide _VER from SELECT *, forbid _VER as DML target, adjust system-field logic. |
| modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/prepare/IgnitePlanner.java | Add helper to detect row-collapsing aggregation in SELECT/ORDER BY. |
| modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/ExecutionServiceImpl.java | Execute FOR UPDATE: materialize rows, order lock entries, lock with savepoint, retry on version mismatch. |
| modules/calcite/src/main/codegen/includes/parserImpls.ftl | Add grammar rules for SELECT ... FOR UPDATE and EXPLAIN PLAN FOR routing. |
| modules/calcite/src/main/codegen/config.fmpp | Add WAIT/NOWAIT keywords and parser method registrations for codegen. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
zstan
requested changes
Aug 11, 2026
zstan
requested changes
Aug 11, 2026
1) Variable rename and readability improvements 2) Avoid infinity look in case where GridCacheEntryRemovedException throwing permanently
tkalkirill
approved these changes
Aug 11, 2026
zstan
reviewed
Aug 12, 2026
| @Test | ||
| public void testExplicitSelectReturnsSystemColumns() throws Exception { | ||
| assertQuery("SELECT _key, _val, _ver FROM Person") | ||
| .columnNames("_KEY", "_VAL", "_VER") |
Contributor
There was a problem hiding this comment.
do we have a compatibility issue if someone already use this naming (i mean _ver) in previous versions ?
zstan
approved these changes
Aug 12, 2026
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.
https://issues.apache.org/jira/browse/IGNITE-28724