Gannalyo opened a new issue #227: Doesn't Saga support the compensation when 
the value of retries is greater than naught?
URL: https://github.com/apache/incubator-servicecomb-saga/issues/227
 
 
   I wrote a compensable method (**retries = 2**), its rollback method would 
not be called when the program encounter some errors.
   
   I guess that there is a problem on script which is response for finding 
uncompensation method out.
   
   Code:
   ```
   private void saveUncompensatedEventsToCommands() {
       
eventRepository.findFirstUncompensatedEventByIdGreaterThan(nextEndedEventId, 
TxEndedEvent.name())
           .forEach(event -> {
             LOG.info("Found uncompensated event {}", event);
             nextEndedEventId = event.id();
             commandRepository.saveCompensationCommands(event.globalTxId());
           });
   }
   
   @Override
   public List<TxEvent> findFirstUncompensatedEventByIdGreaterThan(long id, 
String type) {
       return eventRepo.findFirstByTypeAndSurrogateIdGreaterThan(type, id, 
SINGLE_TX_EVENT_REQUEST);
    }
   
   // script for finding uncompensation out
   @Query("SELECT t FROM TxEvent t "
         + "WHERE t.type = ?1 AND t.surrogateId > ?2 AND EXISTS ( "
         + "  SELECT t1.globalTxId FROM TxEvent t1 "
         + "  WHERE t1.globalTxId = t.globalTxId "
         + "    AND t1.type = 'TxAbortedEvent' AND NOT EXISTS ( "
         + "    SELECT t2.globalTxId FROM TxEvent t2 "
         + "    WHERE t2.globalTxId = t1.globalTxId "
         + "      AND t2.localTxId = t1.localTxId "
         + "      AND t2.type = 'TxStartedEvent' "
         + "      AND t2.creationTime > t1.creationTime)) AND NOT EXISTS ( "
         + "  SELECT t3.globalTxId FROM TxEvent t3 "
         + "  WHERE t3.globalTxId = t.globalTxId "
         + "    AND t3.localTxId = t.localTxId "
         + "    AND t3.type = 'TxCompensatedEvent') AND ( "
         + "  SELECT MIN(t4.retries) FROM TxEvent t4 "
         + "  WHERE t4.globalTxId = t.globalTxId "
         + "    AND t4.localTxId = t.localTxId "
         + "    AND t4.type = 'TxStartedEvent' ) = 0 "
         + "ORDER BY t.surrogateId ASC")
     List<TxEvent> findFirstByTypeAndSurrogateIdGreaterThan(String type, long 
surrogateId, Pageable pageable);
   ```
   formative script:
   
![image](https://user-images.githubusercontent.com/34175244/42861967-0a897d58-8a90-11e8-9d47-fb3f4ea5fa97.png)
   
   This script told us what it's invalid to rollback a compensable method of 
enabled retry, because the value of retries attribute must be greater than 
naught in its last condition.
   
   Please point them out when I make some mistakes. Thank you!

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


With regards,
Apache Git Services

Reply via email to