AMashenkov commented on code in PR #6593:
URL: https://github.com/apache/ignite-3/pull/6593#discussion_r2351715616
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/PrepareServiceImpl.java:
##########
@@ -231,12 +262,67 @@ public void start() {
metricManager.enable(PLANNING_EXECUTOR_SOURCE_NAME);
IgnitePlanner.warmup();
+
+ ScheduledExecutorService planUpdater =
Executors.newSingleThreadScheduledExecutor(
+ IgniteThreadFactory.create(nodeName, "sql-query-plan-refresh",
true, LOG)
+ );
+
+ planUpdater.scheduleAtFixedRate(() -> {
+ for (CacheKey key : weakCache.asMap().keySet()) {
+ CompletableFuture<PlanInfo> fut = cache.get(key);
+
+ // can be evicted
+ if (fut != null) {
+ PlanInfo info = fut.join();
+ assert info.context != null && info.statement != null;
+
+ assert isCompletedSuccessfully(fut);
+
+ int currentCatalogVersion =
schemaManager.catalogVersion(clockService.now().longValue());
+
+ if (currentCatalogVersion == key.catalogVersion()) {
+ SqlQueryType queryType =
key.parsedResult().queryType();
+
+ if (queryType == SqlQueryType.QUERY || queryType ==
SqlQueryType.DML) {
+ CompletableFuture<PlanInfo> newPlanFut =
CompletableFuture.supplyAsync(
+ () -> buildPlan(queryType, key,
info.statement, info.context), planningPool)
+ .exceptionally(e -> {
+ LOG.warn("Failed to re-planning query:
" + key.parsedResult().originalQuery(), e);
+
+ return null;
+ });
+
+ try {
+ PlanInfo newPlan = newPlanFut.get();
Review Comment:
We put a an async task into a separate pool.
What the purpose of waiting the result synchronously here?
--
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]