Skip to content

PHOENIX-8121 Deadlock between index metadata lookups and the server connection pool - #2753

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

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

Conversation

@apurtell

@apurtell apurtell commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

The concurrent mutation tests with eventual index consistency stall at random after a table split, and the region server stops serving writes while it stays alive.

The cause is a deadlock between two bounded resources on the region server. Write handlers read index metadata through the server side Phoenix connection. That read used the range form of the HBase coprocessor call, which hands the work to the connection batch pool and waits without a timeout. The pool threads can at the same time hold scans from the eventual index consumers, and those scans wait in the call queue for the same handlers.

The metadata read always targets one row, so it now uses the single row coprocessor channel and runs on the calling thread. The remote call, its timeout and its retries are the same as before. Only the thread changes, so the read no longer waits for the pool.

🤖 Generated with Claude Code

…onnection pool

metaDataCoprocessorExec read one row of a system table with the range
form of Table.coprocessorService. HBase runs each region call of that
form as a task in the batch pool of the connection, and the caller
waits for the task without a timeout.

On a region server, write handlers make this call when the index
metadata of a batch comes from the server. The batch pool of the
server connection is bounded. Its threads can hold scans that wait in
the default call queue for the same handlers. Then neither side makes
progress, and the region server stops serving writes.

The call now uses the single-row coprocessor channel and runs on the
caller thread. The channel call is the same call that the pool task
made, with the same operation timeout and retries, so results and
errors do not change. The call does not wait for a pool thread.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@apurtell
apurtell requested a balanced review from Copilot December 4, 2026 20:10

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

The call goes to the one region that holds the table key. The comment
now says this, and it says what happens when the call goes through the
batch pool of the connection instead.

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

apurtell commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

Self-review (Claude Code, pr-review-toolkit) — Copilot could not review this PR because of a review quota limit, so this is an automated self-review in its place.

Suggestions

  • Comment wording (ConnectionQueryServicesImpl.java:2412-2414): The new comment says the call "reads one row". This helper also runs the metadata DDL calls (create, drop, alter), so "targets the one region that holds the row key" is more accurate. The comment also lists the conditions for the deadlock but does not say what happens. One more sentence would help: a handler that waits on a full pool blocks forever, and the range form must not come back here because it uses the batch pool.

Strengths

  • The fix is small and targeted. Only the dispatch of the single-row metadata call changes. Retries, the forced region reload on a split, metrics and table cleanup stay the same.
  • The remote call is the same as before. HBase builds the same per-row coprocessor channel inside the range form, so timeouts, retries and request attributes are unchanged. Errors still surface through the server RPC controller and the existing exception parsing.
  • The call now runs on the caller thread and no longer waits on a batch pool future without a timeout. A slow or stuck call fails with an RPC timeout instead of quietly hanging the write handlers.
  • Removing the result-map assertion also removes a failure mode that gave no context. The single-row channel returns exactly one response or throws.
  • The comment sits where a maintainer might switch back to the range form. It explains the design reason and has no ticket ids or caller lists.

Recommendation: merge after nits

🤖 Generated with Claude Code

@apurtell

apurtell commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

Response to the self-review (Claude Code):

  • Comment wording. Fixed in a29e2c8. The comment now says that the call goes to the one region that holds the table key, so it is correct for the DDL calls too. It also says what happens if the call goes through the batch pool: a region server handler can make this call, the pool can be full of calls that wait for the same handlers, and the call can then wait forever.

The addendum changes only the comment.

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