Gargi-jais11 commented on code in PR #9904:
URL: https://github.com/apache/ozone/pull/9904#discussion_r2922402250
##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/RDBStoreAbstractIterator.java:
##########
Review Comment:
@priyeshkaratha While understanding the code I think there is a narrow race
window: if `hasNext()` returns **true,** and another thread closes the DB
before `next()` is called, `next()` will throw `NoSuchElementException `instead
of exiting cleanly. The scan loop `while (hasNext()) { next(); }` could see
this exception in that rare case.
Roughly the scenario is like:
Thread A: hasNext() → isDbClosed() is false →
rocksDBIterator.get().isValid() is true → returns true
Thread B: close() → isClosed = true → blocks in waitAndClose() (iterator
still holds dbRef)
Thread A: next() → setCurrentEntry() sees isDbClosed() true → sets
currentEntry = null → throws NoSuchElementException
I think we should consider handling the "DB closeed and no current entry"
case in next() to avoid throwing if we want a fully clean exit in all cases.
However, the main goal (preventing JVM crash) is achieved.
What do you say?
--
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]