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


##########
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:
   It's not about the contention, it's about the code complexity. Is this 
possible that unregister will be called right after (or concurrent) in another 
thread? We should check that. I don't believe that these operations can be 
reordered, it wouldn't make any sense. What's happening in "local" snapshot 
implementation? Do they also have similar locking?



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