amogh-jahagirdar commented on code in PR #15863:
URL: https://github.com/apache/iceberg/pull/15863#discussion_r3030596195
##########
core/src/test/java/org/apache/iceberg/rest/TestRESTScanPlanning.java:
##########
@@ -1153,6 +1153,76 @@ public void serverSupportsPlanningButNotCancellation()
throws IOException {
assertThat(cancelled).isFalse();
}
+ @Test
+ public void asyncPlanningRespectsConfigurablePollTimeout() {
+ // Create an adapter that always returns SUBMITTED (never completes)
+ List<Endpoint> endpoints =
+ endpointsWithPlanning(
+ Endpoint.V1_SUBMIT_TABLE_SCAN_PLAN,
+ Endpoint.V1_FETCH_TABLE_SCAN_PLAN,
+ Endpoint.V1_CANCEL_TABLE_SCAN_PLAN,
+ Endpoint.V1_FETCH_TABLE_SCAN_PLAN_TASKS);
+
+ RESTCatalogAdapter adapter =
+ Mockito.spy(
+ new RESTCatalogAdapter(backendCatalog) {
+ @Override
+ public <T extends RESTResponse> T execute(
+ HTTPRequest request,
+ Class<T> responseType,
+ Consumer<ErrorResponse> errorHandler,
+ Consumer<Map<String, String>> responseHeaders,
+ ParserContext parserContext) {
+ if (ResourcePaths.config().equals(request.path())) {
+ return castResponse(
+ responseType,
ConfigResponse.builder().withEndpoints(endpoints).build());
+ }
+ T response =
+ super.execute(
+ request, responseType, errorHandler, responseHeaders,
parserContext);
+ if (response instanceof LoadTableResponse) {
+ return castResponse(
+ responseType,
+ withPlanningMode(
+ (LoadTableResponse) response,
+
RESTCatalogProperties.ScanPlanningMode.SERVER.modeName()));
+ }
+
+ // Override fetch responses to always return SUBMITTED so the
poll never completes
+ if (response instanceof FetchPlanningResultResponse) {
+ return castResponse(
+ responseType,
+ FetchPlanningResultResponse.builder()
+ .withPlanStatus(PlanStatus.SUBMITTED)
+ .build());
+ }
+
+ return response;
+ }
+ });
+
+
adapter.setPlanningBehavior(TestPlanningBehavior.builder().asynchronous().build());
+
+ RESTCatalog catalog =
+ new RESTCatalog(SessionCatalog.SessionContext.createEmpty(), (config)
-> adapter);
+ catalog.initialize(
+ "test-poll-timeout",
+ ImmutableMap.of(
+ CatalogProperties.FILE_IO_IMPL,
+ "org.apache.iceberg.inmemory.InMemoryFileIO",
+ RESTCatalogProperties.SCAN_PLANNING_MODE,
+ RESTCatalogProperties.ScanPlanningMode.SERVER.modeName(),
+ RESTCatalogProperties.REST_SCAN_PLANNING_POLL_TIMEOUT_MS,
+ "1"));
+
+ RESTTable table = restTableFor(catalog, "poll_timeout_test");
+ setParserContext(table);
+ RESTTableScan scan = restTableScanFor(table);
+
+ // With a 1ms timeout and a server that never completes, planFiles should
fail
+
assertThatThrownBy(scan::planFiles).isInstanceOf(RuntimeException.class).hasMessage(null);
Review Comment:
Agree that we need a semantically clear exception like
`RemovePlanTimeoutException`. I'm not sure we're really stuck with this, we
can just update it to wrap the Tasks invocation in a try/catch, remap the Not
complete to the new exception type. We already do that in a few other places
like
[BaseTransaction](https://github.com/apache/iceberg/blob/1a2a8a5ecc701629183405ca842f2d1eb23505ee/core/src/main/java/org/apache/iceberg/BaseTransaction.java#L378)
and
[CatalogHandlers](https://github.com/apache/iceberg/blob/main/core/src/main/java/org/apache/iceberg/rest/CatalogHandlers.java#L815)
--
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]