Copilot commented on code in PR #3673:
URL: https://github.com/apache/celeborn/pull/3673#discussion_r3207283081


##########
worker/src/main/java/org/apache/celeborn/service/deploy/worker/shuffledb/RocksDBIterator.java:
##########
@@ -81,15 +83,23 @@ public void close() throws IOException {
 
   @Override
   public void seek(byte[] key) {
-    it.seek(key);
+    metrics.onRead(
+        () -> {
+          it.seek(key);
+          it.status();
+        });
   }
 
   private Map.Entry<byte[], byte[]> loadNext() {
-    if (it.isValid()) {
-      Map.Entry<byte[], byte[]> nextEntry = new 
AbstractMap.SimpleEntry<>(it.key(), it.value());
-      it.next();
-      return nextEntry;
+    if (!it.isValid()) {

Review Comment:
   `loadNext()` returns `null` immediately when `!it.isValid()` without calling 
`it.status()`. In RocksDB, iterator errors are typically surfaced via 
`status()` (and can occur even when `isValid()` is false), so this can silently 
swallow iteration failures and skip the failure metric. Consider calling 
`it.status()` (wrapped in `metrics.onRead(...)`) before returning `null` to 
ensure errors are thrown and counted.
   



##########
worker/src/test/java/org/apache/celeborn/service/deploy/worker/shuffledb/DBProviderSuiteJ.java:
##########
@@ -66,10 +68,12 @@ private void testCheckVersionFailed(DBBackend dbBackend, 
String namePrefix) thro
             : new File(dbDir.getPath(), String.format("%s-%s", namePrefix, 
UUID.randomUUID()));
     try {
       StoreVersion v1 = new StoreVersion(1, 0);
-      DBProvider.initDB(dbBackend, dbFile, v1).close();
+      DBProvider.initDB(dbBackend, dbFile, v1, new WorkerSource(new 
CelebornConf())).close();
       StoreVersion v2 = new StoreVersion(2, 0);
       IOException ioe =
-          assertThrows(IOException.class, () -> DBProvider.initDB(dbBackend, 
dbFile, v2));
+          assertThrows(
+              IOException.class,
+              () -> DBProvider.initDB(dbBackend, dbFile, v2, new 
WorkerSource(new CelebornConf())));

Review Comment:
   This test now constructs `WorkerSource` instances inline but never calls 
`destroy()` on them. `WorkerSource`/`AbstractSource` starts a scheduled cleaner 
thread (daemon) and keeps metric state; leaving it undisposed can leak 
resources across tests and cause flaky behavior. Create a single `WorkerSource` 
for the test scope and `destroy()` it in a `finally` block (or pass a 
mock/`null` source since the test is validating version checks, not metrics).



-- 
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]

Reply via email to