uros-b opened a new pull request, #58741: URL: https://github.com/apache/spark/pull/58741
### What changes were proposed in this pull request? `HistoryServerDiskManager.Lease` now releases its reserved (uncommitted) usage exactly once, whether the lease is committed, fails to commit, or is rolled back. The two `updateUsage(-leased)` calls in `commit()` and `rollback()` are replaced by an idempotent `releaseLease()` helper guarded by a `released` flag. A regression test forces the rename in `commit()` to fail, then calls `rollback()` (as the caller does) and asserts the usage tracker returns to zero rather than going negative, and that a subsequent lease/commit still succeeds. ### Why are the changes needed? `Lease.commit()` releases the reservation with `updateUsage(-leased)` before renaming the temporary store into place. SPARK-58985 made that rename throw an `IOException` on failure, which happens *after* the reservation has already been released. The caller then rolls the lease back -- e.g. `FsHistoryProvider.createDiskStore()` calls `lease.rollback()` on `IOException` -- and `rollback()` releases the reservation a second time. The reservation is added once (in `lease()`) but subtracted twice, so the current-usage tracker is under-counted by the leased amount and can go negative, throwing: ``` java.lang.IllegalStateException: Disk usage tracker went negative (now = ..., delta = ...) ``` This is the same crash SPARK-58985 aimed to prevent; it is reachable whenever `renameTo` fails (I/O error, full disk, destination parent removed out of band). In `createDiskStore()`'s retry loop the exception also escapes the loop, so the store is never rebuilt. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? New unit test in `HistoryServerDiskManagerSuite` (runs for both the LevelDB and RocksDB backends). It fails on the current code with `IllegalStateException: Disk usage tracker went negative` and passes with this change. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
