You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@servicecomb.apache.org by GitBox <gi...@apache.org> on 2018/01/22 01:29:05 UTC

[GitHub] seanyinx commented on a change in pull request #122: SCB-239 abort/recompensate per instance on connected/disconnected

seanyinx commented on a change in pull request #122: SCB-239 abort/recompensate per instance on connected/disconnected
URL: https://github.com/apache/incubator-servicecomb-saga/pull/122#discussion_r162834696
 
 

 ##########
 File path: alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/GrpcTxEventEndpointImpl.java
 ##########
 @@ -54,14 +58,22 @@
 
   @Override
   public void onConnected(GrpcServiceConfig request, StreamObserver<GrpcCompensateCommand> responseObserver) {
+    LOG.warn("Abort all started event of instance {} because of a new connection", request.getInstanceId());
+    txConsistentService.abortAllStartedEventsByInstanceId(request.getServiceName(), request.getInstanceId());
+
     omegaCallbacks
         .computeIfAbsent(request.getServiceName(), key -> new ConcurrentHashMap<>())
-        .computeIfAbsent(request.getInstanceId(), key -> new GrpcOmegaCallback(responseObserver));
+        .put(request.getInstanceId(), new GrpcOmegaCallback(responseObserver));
+
+    txConsistentService.recompensateByInstanceId(request.getInstanceId());
   }
 
   // TODO: 2018/1/5 connect is async and disconnect is sync, meaning callback may not be registered on disconnected
   @Override
   public void onDisconnected(GrpcServiceConfig request, StreamObserver<GrpcAck> responseObserver) {
+    LOG.warn("Abort all started event of instance {} because connection is closing.", request.getInstanceId());
+    txConsistentService.abortAllStartedEventsByInstanceId(request.getServiceName(), request.getInstanceId());
 
 Review comment:
   why abort all transactions when an instance is down?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services