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


##########
modules/client-handler/src/main/java/org/apache/ignite/client/handler/ClientPrimaryReplicaTracker.java:
##########
@@ -304,9 +331,22 @@ private CompletableFuture<Boolean> 
notifyInternal(EventParameters parameters) {
         return falseCompletedFuture(); // false: don't remove listener.
     }
 
-    private void removeTable(DestroyTableEventParameters event) {
-        for (int partition = 0; partition < event.partitions(); partition++) {
-            TablePartitionId tablePartitionId = new 
TablePartitionId(event.tableId(), partition);
+    @Override
+    public CompletableFuture<Void> onLwmChanged(HybridTimestamp ts) {
+        return inBusyLockAsync(busyLock, () -> {
+            int earliestVersion = 
catalogService.earliestCatalogVersion(HybridTimestamp.hybridTimestampToLong(ts));
+
+            List<DestroyTableEvent> events = 
deferredEventsQueue.drainUpTo(earliestVersion);
+
+            events.forEach(event -> removeTable(event.tableId(), 
event.partitions()));
+
+            return nullCompletedFuture();
+        });
+    }
+
+    private void removeTable(int tableId, int partitions) {
+        for (int partition = 0; partition < partitions; partition++) {
+            TablePartitionId tablePartitionId = new TablePartitionId(tableId, 
partition);
             primaryReplicas.remove(tablePartitionId);

Review Comment:
   I'm still not sure the whole implementation is ok.
   1. `primaryReplicas` is keeping up-to-date for all table even if client 
never ask for a particular table.
   2. `primaryReplicas` size is not limited and data never expires. Even if the 
data no longer needed.
   
   I've fixed the race taking p.1-2 into account: I fill the map with poison 
entries on table creation, and prevent put into a map on the leader update.



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