[ 
https://issues.apache.org/jira/browse/SCB-220?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16326054#comment-16326054
 ] 

ASF GitHub Bot commented on SCB-220:
------------------------------------

seanyinx commented on a change in pull request #116: SCB-220 avoid redundant 
compensation
URL: 
https://github.com/apache/incubator-servicecomb-saga/pull/116#discussion_r161470583
 
 

 ##########
 File path: 
alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/TxEventEnvelopeRepository.java
 ##########
 @@ -19,15 +19,33 @@
 
 import java.util.List;
 
+import org.apache.servicecomb.saga.alpha.core.TxEvent;
 import org.springframework.data.jpa.repository.Query;
 import org.springframework.data.repository.CrudRepository;
 
 interface TxEventEnvelopeRepository extends CrudRepository<TxEventEnvelope, 
Long> {
-  TxEventEnvelope findByEventGlobalTxId(String globalTxId);
+  List<TxEventEnvelope> findByEventGlobalTxId(String globalTxId);
 
-  @Query("SELECT DISTINCT new 
org.apache.servicecomb.saga.alpha.server.TxEventEnvelope("
+  @Query("SELECT DISTINCT new org.apache.servicecomb.saga.alpha.core.TxEvent("
       + "t.event.serviceName, t.event.instanceId, t.event.globalTxId, 
t.event.localTxId, t.event.parentTxId, t.event.type, 
t.event.compensationMethod, t.event.payloads"
       + ") FROM TxEventEnvelope t "
       + "WHERE t.event.globalTxId = ?1 AND t.event.type = ?2")
-  List<TxEventEnvelope> findByEventGlobalTxIdAndEventType(String globalTxId, 
String type);
+  List<TxEvent> findByEventGlobalTxIdAndEventType(String globalTxId, String 
type);
+
+  TxEventEnvelope 
findFirstByEventGlobalTxIdAndEventLocalTxIdAndEventType(String globalTxId, 
String localTxId, String type);
+
+  @Query("SELECT DISTINCT new org.apache.servicecomb.saga.alpha.core.TxEvent("
+      + "t.event.serviceName, t.event.instanceId, t.event.globalTxId, 
t.event.localTxId, t.event.parentTxId, t.event.type, 
t.event.compensationMethod, t.event.payloads"
+      + ") FROM TxEventEnvelope t "
+      + "WHERE t.event.globalTxId = ?1 AND t.event.type = 'TxStartedEvent' AND 
EXISTS ( "
+      + "  FROM TxEventEnvelope t1 "
+      + "  WHERE t1.event.globalTxId = ?1 "
+      + "  AND t1.event.localTxId = t.event.localTxId "
+      + "  AND t1.event.type = 'TxEndedEvent'"
+      + ") AND NOT EXISTS ( "
+      + "  FROM TxEventEnvelope t2 "
+      + "  WHERE t2.event.globalTxId = ?1 "
+      + "  AND t2.event.localTxId = t.event.localTxId "
+      + "  AND t2.event.type = 'TxCompensatedEvent')")
+  List<TxEvent> 
findStartedEventsWithMatchingEndedButNotCompensatedEvents(String globalTxId);
 
 Review comment:
   did you try this query? left join returns all records from left table...

----------------------------------------------------------------
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:
us...@infra.apache.org


> [pack] duplicate abort event filter to avoid redundant compensation
> -------------------------------------------------------------------
>
>                 Key: SCB-220
>                 URL: https://issues.apache.org/jira/browse/SCB-220
>             Project: Apache ServiceComb
>          Issue Type: Improvement
>          Components: Saga
>    Affects Versions: saga-0.1.0
>            Reporter: Yin Xiang
>            Assignee: Yin Xiang
>            Priority: Major
>
> aborted events may be triggered by multiple services in the same LLT, we have 
> to filter them, so that we don't trigger compensation more than once. 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to