priyeshkaratha commented on code in PR #9904:
URL: https://github.com/apache/ozone/pull/9904#discussion_r2940040129
##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/RDBStoreAbstractIterator.java:
##########
@@ -48,6 +56,20 @@ abstract class RDBStoreAbstractIterator<RAW>
this.rocksDBTable = table;
this.prefix = prefix;
this.type = type;
+ this.dbRef = acquireDbRef(table);
+ }
+
+ private static UncheckedAutoCloseable acquireDbRef(RDBTable table) {
+ if (table == null) {
+ return null;
+ }
+ try {
+ return table.acquireIterator();
+ } catch (RocksDatabaseException e) {
+ LOG.warn("Failed to acquire DB reference for iterator on table {}: {}",
+ table.getName(), e.getMessage());
+ return null;
Review Comment:
Good catch.
If `acquire()` threw a `RocksDatabaseException`, the code caught it, logged
a warning, and returned `null`. This left the iterator without a DB reference
and made it appear as if the table was empty. It also leaked the
`ManagedRocksIterator`. I added a fix that removes the try-catch, closes the
iterator if `acquire()` fails, and rethrows the exception. Subclass
constructors now declare `throws RocksDatabaseException`.
--
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]