xtern commented on code in PR #2982:
URL: https://github.com/apache/ignite-3/pull/2982#discussion_r1438281377
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/mapping/MappingServiceImpl.java:
##########
@@ -96,12 +108,54 @@ public CompletableFuture<List<MappedFragment>>
map(MultiStepPlan multiStepPlan)
return initialTopologyFuture.thenComposeAsync(ignore ->
map0(multiStepPlan), taskExecutor);
}
+ /** Called when the primary replica has expired. */
+ public CompletableFuture<Boolean>
onPrimaryReplicaExpired(PrimaryReplicaEventParameters parameters) {
+ assert parameters != null;
+ assert parameters.groupId() instanceof TablePartitionId;
+
+ int tabId = ((TablePartitionId) parameters.groupId()).tableId();
+
+ return CompletableFuture.supplyAsync(() -> {
+ mappingsCache.values().removeIf(value ->
value.tableIds.contains(tabId));
+
+ return false;
+ }, ForkJoinPool.commonPool());
Review Comment:
It seems that the full cache scan should be done asynchronously, at least to
avoid blocking other listeners. But I'm not sure which pool is best to use for
this.
Also it might make sense to wrap
```
mappingsCache.values().removeIf(value -> value.tableIds.contains(tabId));
```
into a synchronized block to reduce contention if there are will be a lot of
simultaneous events about the same table (for each partition for example).
--
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]