eric-lee-ltk 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_r162838796
 
 

 ##########
 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:
   When the SagaStart node fails, the transaction is no longer valid because 
user will get an error immediately instead of the subsequent result. We should 
stop it from executing.

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to