korlov42 commented on code in PR #2848:
URL: https://github.com/apache/ignite-3/pull/2848#discussion_r1402982502
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/SqlQueryProcessor.java:
##########
@@ -317,6 +341,69 @@ public CompletableFuture<ExecutionTarget>
forSystemView(ExecutionTargetFactory f
services.forEach(LifecycleAware::start);
}
+ /** Get primary replicas. */
+ private CompletableFuture<List<PrimaryReplica>> primaryReplicas(int
tableId) {
+ int catalogVersion = catalogManager.latestCatalogVersion();
+
+ Catalog catalog = catalogManager.catalog(catalogVersion);
+
+ CatalogTableDescriptor tblDesc =
Objects.requireNonNull(catalog.table(tableId), "table");
+
+ CatalogZoneDescriptor zoneDesc =
Objects.requireNonNull(catalog.zone(tblDesc.zoneId()), "zone");
+
+ int partitions = zoneDesc.partitions();
+
+ List<CompletableFuture<PrimaryReplica>> result = new
ArrayList<>(partitions);
+
+ HybridTimestamp clockNow = clock.now();
+
+ // no need to wait all partitions after pruning was implemented.
+ for (int partId = 0; partId < partitions; ++partId) {
+ int partitionId = partId;
+ ReplicationGroupId partGroupId = new TablePartitionId(tableId,
partitionId);
+
+ CompletableFuture<ReplicaMeta> f =
placementDriver.awaitPrimaryReplica(
+ partGroupId,
+ clockNow,
+ AWAIT_PRIMARY_REPLICA_TIMEOUT,
+ SECONDS
+ );
+
+ result.add(f.handle((primaryReplica, e) -> {
+ if (e != null) {
+ LOG.error("Failed to retrieve primary replica for
partition {}", e, partitionId);
Review Comment:
Because from sql engine's point of view it's just one reason from thousands
why query may fail. If PlacementDriver went to failed state and can't provide
placement for table -- it's up to PlacementDriver to report this error. Sql
engine on the other hand is just a middle ware, thus we should just propagate
this error up to the client. We _may_ report to the log, but only to help
debugging certain problems. But it worth to remember that according to [logging
guideline](https://cwiki.apache.org/confluence/display/IGNITE/Java+Logging+Guidelines#JavaLoggingGuidelines-ERROR)
`ERROR is when you need a duty engineer to wake up in the middle of the
night`. I see no reason to wake duty engineer if a random query got failed,
this error will be propagate to caller anyway
--
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]