Skip to content

IGNITE-27651 Clean up direct tx on client disconnect#7779

Open
ptupitsyn wants to merge 44 commits intoapache:mainfrom
ptupitsyn:ignite-27651
Open

IGNITE-27651 Clean up direct tx on client disconnect#7779
ptupitsyn wants to merge 44 commits intoapache:mainfrom
ptupitsyn:ignite-27651

Conversation

@ptupitsyn
Copy link
Contributor

@ptupitsyn ptupitsyn commented Mar 13, 2026

Store remote enlistments in client resource registry and clean up on disconnect.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds server-side tracking/cleanup for direct-mapped (lightweight) client transactions so that partitions enlisted on a node can be cleaned up when a client disconnects, and documents the direct-tx coordinator flow.

Changes:

  • Expose RemotelyTriggeredResourceRegistry via TxManager and wire it in TxManagerImpl.
  • Track direct-tx remote enlistments per client connection and attempt cleanup on disconnect; refactor discard cleanup into ClientTxPartitionEnlistmentCleaner.
  • Add/enable integration tests around tx cleanup and JDBC transaction failover behavior.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
modules/transactions/src/main/java/org/apache/ignite/internal/tx/impl/TxManagerImpl.java Stores and exposes RemotelyTriggeredResourceRegistry via new resourceRegistry() API.
modules/transactions/src/main/java/org/apache/ignite/internal/tx/TxManager.java Adds resourceRegistry() accessor to support cross-module cleanup registration.
modules/client-handler/src/main/java/org/apache/ignite/client/handler/ClientResourceRegistry.java Tracks per-connection tx cleaners and triggers cleanup on disconnect.
modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTableCommon.java Registers per-tx cleanup hooks when processing direct-mapped requests.
modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/tx/ClientTxPartitionEnlistmentCleaner.java New helper to collect enlistments and invoke discardLocalWriteIntents.
modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/tx/ClientTransactionDiscardRequest.java Refactors discard request handling to reuse the new cleaner helper.
modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/client/ItThinClientTransactionCleanupTest.java New IT covering “disconnect releases locks” scenario for direct tx.
modules/jdbc/src/integrationTest/java/org/apache/ignite/jdbc/ItJdbcConnectionFailoverTest.java Re-enables a previously disabled failover test.
modules/client/src/test/java/org/apache/ignite/client/fakes/FakeTxManager.java Implements new TxManager.resourceRegistry() method (currently returns null).
modules/client/src/main/java/org/apache/ignite/internal/client/tx/DEVNOTES.md New developer notes describing the direct transaction coordinator protocol/lifecycle.
Comments suppressed due to low confidence (1)

modules/client-handler/src/main/java/org/apache/ignite/client/handler/ClientResourceRegistry.java:180

  • Catching Throwable during resource cleanup will also swallow serious Errors (e.g., OutOfMemoryError, StackOverflowError) and continue execution, which can leave the JVM in an inconsistent state and makes diagnosing such failures harder. It's safer to catch Exception here (and let Error propagate), while still collecting/suppressing regular cleanup failures.
        for (ClientResource r : res.values()) {
            try {
                r.release();
            } catch (Throwable e) {
                if (ex == null) {
                    ex = new IgniteInternalException(e);
                } else {
                    ex.addSuppressed(e);
                }
            }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to ensure server-side cleanup of direct-mapped (lightweight) client transactions when a thin client disconnects, by tracking remote partition enlistments per client connection and triggering write-intent/lock cleanup.

Changes:

  • Add per-connection tracking of direct-tx partition enlistments in ClientResourceRegistry, and run cleanup on registry close (client disconnect).
  • Refactor discard cleanup logic into a dedicated helper (ClientTxPartitionEnlistmentCleaner) and integrate enlistment tracking into direct-tx request processing.
  • Expose RemotelyTriggeredResourceRegistry via TxManager and add an integration test for lock release on disconnect.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
modules/transactions/src/main/java/org/apache/ignite/internal/tx/impl/TxManagerImpl.java Stores injected resource registry and exposes it via new TxManager.resourceRegistry().
modules/transactions/src/main/java/org/apache/ignite/internal/tx/TxManager.java Adds resourceRegistry() accessor to support registering tx-finish callbacks.
modules/client-handler/src/main/java/org/apache/ignite/client/handler/ClientResourceRegistry.java Tracks per-tx cleaners and triggers cleanup on registry close (disconnect).
modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTableCommon.java Records direct-tx enlistments for disconnect cleanup and registers tx-finish untracking.
modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/tx/ClientTxPartitionEnlistmentCleaner.java New helper that groups enlisted partitions and calls discardLocalWriteIntents.
modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/tx/ClientTransactionDiscardRequest.java Uses the new cleaner helper instead of duplicating enlistment grouping logic.
modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/client/ItThinClientTransactionCleanupTest.java New integration test verifying locks are released after client disconnect with direct enlistments.
modules/jdbc/src/integrationTest/java/org/apache/ignite/jdbc/ItJdbcConnectionFailoverTest.java Re-enables a previously disabled transaction failover test.
modules/client/src/test/java/org/apache/ignite/client/fakes/FakeTxManager.java Updates test fake for the new TxManager.resourceRegistry() method.
modules/client/src/main/java/org/apache/ignite/internal/client/tx/DEVNOTES.md Adds developer documentation describing the direct transaction coordinator flow.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants