Skip to content

PHOENIX-7817 Resolve Omid transaction manager via provider singleton view - #2435

Open
apurtell wants to merge 2 commits into
apache:masterfrom
apurtell:PHOENIX-7817
Open

apurtell wants to merge 2 commits into
apache:masterfrom
apurtell:PHOENIX-7817

Conversation

@apurtell

@apurtell apurtell commented May 1, 2026

Copy link
Copy Markdown
Contributor

OmidTransactionClient captures the provider's HBaseTransactionManager at construction time. OmidTransactionContext in turn caches that same reference in a private field. When a prior test class shuts down OMID's TSO together with its mini-cluster, the next test class reuses the stale wrapper and is dispatched to the dead executor. The symptom is a RejectedExecutionException originating from the OMID TSOClient state-machine executor.

In production the singleton's manager is set exactly once and never replaced, but the test framework exercises the swap path between classes within a single Surefire/Failsafe fork.

Fix:

OmidTransactionClient becomes a thin view onto the singleton's current HBaseTransactionManager. It resolves
provider.transactionManager on every call to getTransactionClient(). transactionManager is marked volatile so test-framework injection is published to other threads without synchronization.

In production the dynamic lookup is functionally identical to caching.

@palashc

palashc commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

@apurtell

Copy link
Copy Markdown
Contributor Author

Claude Code (an AI assistant), posting on behalf of Andrew Purtell.

The 5.4 stabilization sweep found that this issue is still present on master (2631560c1f), 5.3 and 5.2.

I rebased the PR onto the latest master, fixed a spotless failure in OmidTransactionContext, and shortened the code comments. The code is unchanged.

@virajjasani, could you please review?

@apurtell
apurtell requested review from virajjasani and a balanced review from Copilot November 23, 2026 00:32

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

A deterministic regression test is missing to verify that a retained client and transaction context use the replacement manager for lookup and begin/commit/abort operations.

1 open issue
What changed in this PR

This PR prevents stale Omid transaction-manager references when tests replace the provider’s manager between test classes, while preserving behavior when the production manager remains unchanged.

Changes:

  • Makes the provider’s manager volatile and resolves it dynamically through the client wrapper.
  • Updates transaction contexts to retrieve the current manager for each operation rather than caching it.
  • Adds null-manager handling during transaction reconstruction and DDL fencing.
File Description
phoenix-core-client/​src/​main/​java/​org/​apache/​phoenix/​transaction/​OmidTransactionProvider.java Publishes manager replacements and makes the client a live view of the provider.
phoenix-core-client/​src/​main/​java/​org/​apache/​phoenix/​transaction/​OmidTransactionContext.java Replaces the cached manager with per-operation lookups and adds null handling.

Review effort: Balanced

…view

OmidTransactionContext now gets the current transaction manager from the
provider on each call. A replaced manager then does not leave a stale
reference in a cached context or client.

The test connection services now share one test transaction service for
each provider in the JVM. A server-side connection service no longer
starts a second TSO and replaces the manager and commit table of the
singleton provider while a transaction is open. Open regions keep the
commit table they had when they opened, so such a swap let readers miss
committed rows. The connection service that starts the shared service
owns it and closes it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@apurtell

Copy link
Copy Markdown
Contributor Author

Posted by Claude Code (an AI assistant) on behalf of Andrew Purtell.

Follow-up from the 5.4 stabilization sweep. With this PR applied, a docker gate run (HBase 2.5, JDK 11) hit a new flake: TransactionIT.testParallelConnectionOnlySeesCommittedData[OMID] failed with Expected 0 or 4096 but got these intermediary counts [4088].

Cause, in test code only: a server-side connection, here from a compaction, gets its own ConnectionQueryServicesTestImpl. That instance starts a second test TSO and injects it into the singleton OmidTransactionProvider. Open regions keep the commit table client they had when they opened. Before this PR the client also kept the old manager, so the swap did no harm. With the per-call lookup, the open transaction commits through the new TSO, and readers miss rows until all the shadow cells are written. Production never injects a test service, so it is not affected.

Fix, now folded into the PR commit (ConnectionQueryServicesTestImpl only): all test connection services in a JVM share one test transaction service per provider. The instance that starts it owns it and closes it.

Evidence (docker, JDK 11):

  • A probe that forces the swap before commit fails 10 of 10 on the previous PR head and passes 5 of 5 on master.
  • With the fix, the probe and TransactionIT pass 20 of 20 on HBase 2.5 and 5 of 5 on 2.6. One TSO starts per JVM, with no RejectedExecutionException.
  • With the fix, the OMID ITs pass on 2.5 and 2.6 (70 clean class runs in total), including GlobalMutableTxIndexIT, TxIndexIT and the rollback ITs.

The branch is rebased onto the latest master (d075e889e9).

@virajjasani, could you please review?

The change edits three lines that carry existing checkstyle warnings,
so precommit counts them as new. Remove the parentheses around an
assert expression, add braces to a one-line if, and drop a redundant
public modifier on a constructor of a package-private class.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

3 participants