Skip to content

fix(hive-sync): drop the unreachable HMS lock timeout-recovery path - #19371

Merged
voonhous merged 2 commits into
apache:masterfrom
wombatu-kun:hive-sync-drop-dead-lock-recovery
Jul 27, 2026
Merged

fix(hive-sync): drop the unreachable HMS lock timeout-recovery path#19371
voonhous merged 2 commits into
apache:masterfrom
wombatu-kun:hive-sync-drop-dead-lock-recovery

Conversation

@wombatu-kun

@wombatu-kun wombatu-kun commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Describe the issue this Pull Request addresses

Closes #19345, point 1. Point 2 of that issue is addressed by #19370.

Summary and Changelog

An acquire that times out now reports the timeout instead of a misleading NoSuchLockException.

  • Removed the catch (InterruptedException | TimeoutException e) block from HiveMetastoreBasedLockProvider.acquireLockInternal. Both exceptions are already declared by the method, so they propagate and tryLock wraps the actual TimeoutException.
  • Collapsed the hoisted lockRequest local and its lockRequestFinal copy into one final local, since they only existed to feed checkLock after the try block.
  • Added TestHiveMetastoreBasedLockProviderAcquireTimeout on top of the shared HiveMetastoreBasedLockProviderTestBase: with a mocked IMetaStoreClient whose lock() never answers, the acquire must fail with HoodieLockException caused by TimeoutException and must not call checkLock. Without this change that test fails with a bare NullPointerException.

Impact

HoodieLockException on an acquire timeout is now caused by TimeoutException rather than NoSuchLockException. No API or configuration change.

Risk Level

low

The removed code could not execute against a real metastore, so no working behaviour is taken away.

Documentation Update

none

Contributor's checklist

  • Read through contributor's guide
  • Enough context is provided in the sections above
  • Adequate tests were added if applicable

@github-actions github-actions Bot added the size:M PR with lines of changes in (100, 300] label Jul 24, 2026
@wombatu-kun

Copy link
Copy Markdown
Contributor Author

@voonhous could you please review this too.
To close hive-sync lock provider issue finally.

@wombatu-kun
wombatu-kun force-pushed the hive-sync-drop-dead-lock-recovery branch from f7645fb to fc893fd Compare July 24, 2026 13:39
@wombatu-kun
wombatu-kun requested a review from voonhous July 24, 2026 13:40
@github-actions github-actions Bot added size:S PR with lines of changes in (10, 100] and removed size:M PR with lines of changes in (100, 300] labels Jul 24, 2026

@hudi-agent hudi-agent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ 🤖 This review was generated by an AI agent and may contain mistakes. Please verify any suggestions before applying.

Thanks for the contribution! This PR removes an unreachable HMS lock timeout-recovery branch so that an acquire timeout now reports a TimeoutException-caused HoodieLockException instead of a misleading error, and adds a focused test. No issues flagged from this automated pass — a Hudi committer or PMC member can take it from here for a final review.

cc @yihua

@voonhous voonhous left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed the removal itself and it holds up. LockRequestBuilder.build() never sets txnid (only setTransactionId(long) does, and the provider never calls it), so getTxnid() returns 0 and TxnHandler.checkLock throws NoSuchLockException for lock id 0 -- lock ids come from NEXT_LOCK_ID, seeded at 1.

Worth adding to the PR body: there is a second, independent reason the branch was dead. Both callers of acquireLockInternal are gated by ValidationUtils.checkArgument(this.lock == null), and the only assignment to lock inside the try is the get(time, unit) that threw, so this.lock == null was always true at the catch site -- the state == ACQUIRED adopt-and-return branch could never be taken even if checkLock had been given the right id.

Two notes on the new test below.

@hudi-agent hudi-agent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ 🤖 This review was generated by an AI agent and may contain mistakes. Please verify any suggestions before applying.

Thanks for working on this! This PR removes the unreachable HMS lock timeout-recovery branch in HiveMetastoreBasedLockProvider.acquireLockInternal so an acquire timeout now surfaces a TimeoutException cause instead of a misleading NoSuchLockException. Tracing both the old and new paths, the removed branch could not recover against a real metastore (it looked up lockRequest.getTxnid(), which is 0 for a request never populated from a server response), and the server-granted-lock leak behavior is unchanged, so this is a net improvement. No new issues flagged from this automated pass beyond what other reviewers already noted on the test. Please take a look at any inline comments, and this should be ready for a Hudi committer or PMC member to take it from here.

cc @yihua

@wombatu-kun

Copy link
Copy Markdown
Contributor Author

On the second reason: with this.lock == null invariant at the catch site the outer if (this.lock == null || this.lock.getState() != ACQUIRED) is a tautology, so what it kills is that second disjunct and the implicit fall-through that swallowed the exception when a lock was already held, while the inner adopt branch reads only what checkLock returns and a correct lock id would have made it reachable.

Leaving the body as is on that basis, since the txnid-0 argument stays the only reason the recovery was dead.

@hudi-bot

Copy link
Copy Markdown
Collaborator

CI report:

Bot commands @hudi-bot supports the following commands:
  • @hudi-bot run azure re-run the last Azure build

@github-actions github-actions Bot added size:M PR with lines of changes in (100, 300] and removed size:S PR with lines of changes in (10, 100] labels Jul 27, 2026
@voonhous
voonhous enabled auto-merge (squash) July 27, 2026 13:23
@voonhous
voonhous merged commit 4a5d5b0 into apache:master Jul 27, 2026
74 of 75 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M PR with lines of changes in (100, 300]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] hive-sync lock provider: timeout recovery calls checkLock() with a txn id, and Heartbeat retries a permanently gone lock

4 participants