You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "smengcl (via GitHub)" <gi...@apache.org> on 2026/10/12 21:20:50 UTC

[PR] HDDS-16954. SnapshotChainManager iterator throws NoSuchElementException when a snapshot is purged during iteration [ozone]

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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-16954. NoSuchElementException in SnapshotChainManager if snapshot is purged during iteration [ozone]

Posted by "adoroszlai (via GitHub)" <gi...@apache.org>.
adoroszlai commented on PR #11500:
URL: https://github.com/apache/ozone/pull/11500#issuecomment-6156357394

   Thanks @smengcl for the patch, @jojochuang for the review.


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-16954. NoSuchElementException in SnapshotChainManager if snapshot is purged during iteration [ozone]

Posted by "smengcl (via GitHub)" <gi...@apache.org>.
smengcl commented on PR #11500:
URL: https://github.com/apache/ozone/pull/11500#issuecomment-6160096917

   Thanks @jojochuang @adoroszlai for the reviewing and merging this.


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-16954. NoSuchElementException in SnapshotChainManager if snapshot is purged during iteration [ozone]

Posted by "adoroszlai (via GitHub)" <gi...@apache.org>.
adoroszlai merged PR #11500:
URL: https://github.com/apache/ozone/pull/11500


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org