rpuch commented on code in PR #1226:
URL: https://github.com/apache/ignite-3/pull/1226#discussion_r1003290602


##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/raft/snapshot/outgoing/OutgoingSnapshotsManager.java:
##########
@@ -65,41 +91,69 @@ public MessagingService messagingService() {
 
     @Override
     public void start() {
-        messagingService.addMessageHandler(TableMessageGroup.class, 
this::messageHandler);
+        executor = Executors.newFixedThreadPool(4, new 
NamedThreadFactory("outgoing-snapshots", LOG));
+
+        messagingService.addMessageHandler(TableMessageGroup.class, 
this::handleMessage);
     }
 
     @Override
     public void stop() throws Exception {
+        IgniteUtils.shutdownAndAwaitTermination(executor, 10, 
TimeUnit.SECONDS);
     }
 
     /**
      * Registers an outgoing snapshot in the manager.
      *
-     * @param snapshotId Snapshot id.
+     * @param snapshotId       Snapshot id.
      * @param outgoingSnapshot Outgoing snapshot.
      */
-    void registerOutgoingSnapshot(UUID snapshotId, OutgoingSnapshot 
outgoingSnapshot) {
-        outgoingSnapshots.put(snapshotId, outgoingSnapshot);
+    @Override
+    public void registerOutgoingSnapshot(UUID snapshotId, OutgoingSnapshot 
outgoingSnapshot) {
+        synchronized (snapshotsLock) {

Review Comment:
   I tried to imagine a scenario like registering a snapshot and immediately 
unregistering it from another thread (unregister starts before the registering 
returns). Then unregisterer might see the snapshot in first collection but not 
in second.
   
   This does not look realistic, but it seems possible. The lock allows to 
avoid this.
   
   Do we expect high contention on this lock? Is it a problem? How often will 
snapshots be registered?



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