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

   ### Describe the issue this Pull Request addresses
   
   Follow-up to #20163, and stacked on it: the first commit here is #20163's 
commit, and this PR's own change is the second commit.
   
   #20163 gates the timeline archiver's lock release and close on "this call 
acquired the lock", so that an archiver which lost the lock race cannot delete 
the holder's lock. Skipping close() on a failed acquisition, though, leaks the 
lock provider that attempt created. For StorageBasedLockProvider that is a 
heartbeat executor and a JVM shutdown hook on every contended archive run.
   
   ### Summary and Changelog
   
   - The archivers (V1 and V2) close their transaction manager on every exit 
path. The release (endStateChange) is still gated on the lock having been 
acquired.
   - Closing without the lock is safe because that call's provider instance 
holds no lock. The one provider where this did not hold was 
FileSystemBasedLockProvider: its unlock() and close() deleted the lock file 
whoever owned it. It now records the content it wrote when it acquired the 
lock, and deletes the file only while the file still has that content (or a 
prefix of it, after an interrupted write).
     - The record is cleared only once the file is gone or belongs to another 
owner, so close() still retries a release that failed on an I/O error.
   - Tests:
     - TestFileSystemBasedLockProvider: a non-holder's unlock and close keep 
the holder's lock; a former holder does not delete a lock taken over by another 
owner; an owner still releases a lock file left with partial content.
     - TestHoodieTimelineArchiver: after a failed acquisition, the provider is 
closed and no unlock is attempted.
     - The ownership and archiver tests fail without this change.
   
   ### Impact
   
   No API or config change. A failed archive lock acquisition no longer leaks 
its lock provider. FileSystemBasedLockProvider no longer deletes a lock file 
another writer holds.
   
   ### Risk Level
   
   low. It changes only the archiver's cleanup path and 
FileSystemBasedLockProvider's release. Verified locally: the lock and archiver 
test classes pass, and 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