AMashenkov commented on code in PR #6593:
URL: https://github.com/apache/ignite-3/pull/6593#discussion_r2359500856


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/PrepareServiceImpl.java:
##########
@@ -231,6 +271,58 @@ public void start() {
         metricManager.enable(PLANNING_EXECUTOR_SOURCE_NAME);
 
         IgnitePlanner.warmup();
+
+        planUpdater.scheduleAtFixedRate(() -> {
+            CompletableFuture<PlanInfo> planFut = rePlanningFut.get();
+            if (planFut != null && !planFut.isDone()) {
+                // some work still in progress
+                return;
+            } else {
+                rePlanningFut.set(null);
+            }
+
+            for (Entry<CacheKey, Object> ent : reScheduledPlans.entrySet()) {
+                CacheKey key = ent.getKey();
+                CompletableFuture<PlanInfo> fut = cache.get(key);
+
+                // can be evicted
+                if (fut != null) {
+                    assert isCompletedSuccessfully(fut);
+
+                    PlanInfo info = fut.join();
+
+                    assert info.context != null && info.statement != null;
+
+                    int currentCatalogVersion = 
schemaManager.catalogVersion(clockService.now().longValue());
+
+                    if (currentCatalogVersion == key.catalogVersion()) {
+                        SqlQueryType queryType = 
info.statement.parsedResult().queryType();
+
+                        if (queryType == SqlQueryType.QUERY || queryType == 
SqlQueryType.DML) {
+                            PlanningContext planningContext = 
PlanningContext.builder()
+                                    .frameworkConfig(info.context.config())
+                                    
.query(info.statement.parsedResult().originalQuery())
+                                    .plannerTimeout(plannerTimeout)
+                                    
.catalogVersion(info.context.catalogVersion())
+                                    
.defaultSchemaName(info.context.schemaName())
+                                    .parameters(info.context.parameters())
+                                    .explicitTx(info.context.explicitTx())
+                                    .build();
+
+                            CompletableFuture<PlanInfo> newPlanFut =
+                                    preparePlan(queryType, 
info.statement.parsedResult, planningContext, key);
+
+                            rePlanningFut.updateAndGet(prev -> prev == null ? 
newPlanFut : prev.thenCompose(none -> newPlanFut));

Review Comment:
   Can planning future fail due to timeout or any other reason?
   If so, this will affect the whole chain and lead to next scheduling task 
execution, however some planner tasks were not finished yet.



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