linliu-code opened a new pull request, #20163:
URL: https://github.com/apache/hudi/pull/20163

   ### Describe the issue this Pull Request addresses
   
   closes #20162
   
   ### Summary and Changelog
   
   A failed lock release no longer leaves a half-released provider behind, and 
the timeline archivers no longer leak their lock resources.
   
   - LockManager.unlock() closes the provider in a finally block, so the next 
lock() builds a fresh provider instead of reusing one whose lock state is no 
longer trustworthy. Release metrics are still recorded only on success.
   - TimelineArchiverV1 and TimelineArchiverV2 close their private 
TransactionManager in archiveIfRequired, and release it, only when that call 
acquired the lock. This covers a failed unlock and the case where the archive 
writer close throws and skips the release. It also stops a lost lock race from 
releasing the lock at all: some providers (FileSystemBasedLockProvider) delete 
the lock file on unlock or close without an ownership check, so the old code 
could delete the holder's lock.
   - TransactionManager is unchanged: its owner state is cleared before unlock, 
and with the provider closed the next state change starts on a fresh provider. 
A test pins that.
   - New test helper FaultInjectingLockProvider and tests in TestLockManager, 
TestTransactionManager and TestHoodieTimelineArchiver; each new test fails 
without the change.
   
   ### Impact
   
   After a failed release, the next lock acquisition always goes through a 
fresh provider with a live heartbeat. For StorageBasedLockProvider, closing the 
provider re-attempts the release once more, which can clear a lock that would 
otherwise stay stranded until its lease elapses. No config or public API change.
   
   ### Risk Level
   
   low. The change only adds cleanup on failure paths. Verified locally: the 
new tests fail without the change and pass with it; TestLockManager, 
TestTransactionManager, TestStorageBasedLockProvider, TestLockResultEnums and 
TestHoodieTimelineArchiver pass; checkstyle is clean.
   
   ### Documentation Update
   
   none
   
   ### Contributor's checklist
   
   - [x] Read through [contributor's 
guide](https://hudi.apache.org/contribute/how-to-contribute)
   - [x] Enough context is provided in the sections above
   - [x] Adequate tests were added if applicable
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to