smengcl opened a new pull request, #11500: URL: https://github.com/apache/ozone/pull/11500
Generated-by: Claude Code (Sonnet 5.5) ## What changes were proposed in this pull request? `SnapshotChainManager#iterator` read the pre-fetched current snapshot id and then looked up its neighbours in the global chain without holding the chain lock. If a snapshot purge removed that snapshot in between, `hasPreviousGlobalSnapshot` / `hasNextGlobalSnapshot` threw `NoSuchElementException` out of `Iterator#next`. For example `DirectoryDeletingService#getTasks` then failed for the whole cycle (the AOS task and every snapshot task were lost). This patch advances the iterator under the same lock as `deleteSnapshot`, and ends the walk if the snapshot it moved to has been purged. It also throws `NoSuchElementException` from `next()` once the iterator is exhausted, as the `Iterator` contract requires. This is a follow up to HDDS-16949 (apache/ozone#11496), which keeps a background service scheduled when `getTasks()` throws. ## What is the link to the Apache JIRA https://issues.apache.org/jira/browse/HDDS-16954 ## How was this patch tested? Added `TestSnapshotChain#testSnapshotChainIteratorWhenNextSnapshotIsPurged` (forward and reverse), which purges the snapshot the iterator has moved to. It fails with `NoSuchElementException` without the fix and passes with it. `TestSnapshotChain` (22 tests) and checkstyle pass locally. - 10x10 [flaky-test-check](https://github.com/smengcl/hadoop-ozone/actions/runs/38310020009) on this branch: in progress 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
