mengw15 commented on code in PR #9636:
URL: https://github.com/apache/texera/pull/9636#discussion_r4670968389


##########
amber/src/main/scala/org/apache/texera/web/service/WorkflowService.scala:
##########
@@ -418,12 +418,7 @@ class WorkflowService(
     (resultUris ++ consoleMessagesUris).foreach { uri =>
       if (WarehouseReadGuard.skipWhileDisabled(uri)) {
         logger.info(s"skipping cleanup of $uri: per-user warehouses are 
disabled")
-      } else
-        try DocumentFactory.openDocument(uri)._1.clear()
-        catch {
-          case error: Throwable =>
-            logger.debug(s"Error processing document at $uri: 
${error.getMessage}")
-        }
+      } else WorkflowExecutionsResource.clearDocument(uri)
     }
 
     // Expire any Iceberg snapshots for runtime statistics

Review Comment:
   Done in ff0fee8bc950267906ab2555a65390bcac9a4a13: a missing document is 
passed over and any other failure is logged as a warning, like `clearDocument`. 
`WorkflowServiceSpec` now runs that block too.



##########
common/workflow-core/src/test/scala/org/apache/texera/amber/core/storage/result/iceberg/IcebergDocumentSpec.scala:
##########
@@ -427,6 +427,37 @@ class IcebergDocumentSpec extends AnyFlatSpec with 
Matchers with BeforeAndAfterA
     doc.asInstanceOf[IcebergDocument[Tuple]].tableNamespace shouldBe 
tableNamespace
     doc.asInstanceOf[IcebergDocument[Tuple]].tableName shouldBe name
   }
+
+  /**
+    * Writes `rows` rows, and returns a document that reads them through a 
catalog which lets
+    * `succeeding` `loadTable` calls through before it fails. The document 
overrides its catalog
+    * rather than replacing a shared one: outside `rest`, every warehouse 
shares one entry.
+    */
+  private def documentOnFailingCatalog(rows: Int, succeeding: Int): 
IcebergDocument[Tuple] = {
+    val tableName = freshTableName()
+    write(newDocument(tableName), (0 until rows).map(tuple))
+    val failing = new FailingCatalog(IcebergCatalogInstance.getInstance(), 
succeeding)
+    new IcebergDocument[Tuple](tableNamespace, tableName, icebergSchema, 
serde, deserde) {
+      override def catalog: Catalog = failing
+    }
+  }
+
+  it should "throw rather than count 0 rows when its catalog is unavailable" 
in {
+    val error = intercept[RuntimeException](documentOnFailingCatalog(3, 
0).getCount)
+    error.getMessage shouldBe "catalog unavailable"
+  }
+
+  it should "throw rather than read as empty when its catalog is unavailable" 
in {
+    val error = intercept[RuntimeException](documentOnFailingCatalog(3, 
0).get().toList)
+    error.getMessage shouldBe "catalog unavailable"
+  }
+
+  it should "keep the rows it has read when its catalog fails while it looks 
for newer ones" in {
+    // The first call resolves the table; the second is the look for files 
committed since, made
+    // once every row of that snapshot has been returned.
+    documentOnFailingCatalog(3, 1).get().toList should have size 3
+  }
+
   it should "re-resolve its catalog on every seek, keeping a polling reader's 
entry live" in {
     // #7290 review: a reader that refreshed a pinned Table never touched the 
catalog
     // cache again, so a long poll looked idle -- expiry could close the 
catalog under

Review Comment:
   Done in ff0fee8bc950267906ab2555a65390bcac9a4a13: the test overrides 
`catalog` like the new cases, so the spec no longer replaces the shared one.



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