You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by ni...@apache.org on 2018/03/09 12:17:41 UTC

[incubator-servicecomb-saga] 02/03: SCB-330 swallow exception when saving the same timeout concurrently

This is an automated email from the ASF dual-hosted git repository.

ningjiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-saga.git

commit 787cce112fcc99eeef0581654a29558ee332c32e
Author: Eric Lee <da...@huawei.com>
AuthorDate: Fri Mar 9 11:07:56 2018 +0800

    SCB-330 swallow exception when saving the same timeout concurrently
    
    Signed-off-by: Eric Lee <da...@huawei.com>
---
 .../saga/alpha/server/SpringTxTimeoutRepository.java           | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/SpringTxTimeoutRepository.java b/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/SpringTxTimeoutRepository.java
index ee75496..7195139 100644
--- a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/SpringTxTimeoutRepository.java
+++ b/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/SpringTxTimeoutRepository.java
@@ -19,15 +19,19 @@ package org.apache.servicecomb.saga.alpha.server;
 
 import static org.apache.servicecomb.saga.alpha.core.TaskStatus.PENDING;
 
+import java.lang.invoke.MethodHandles;
 import java.util.List;
 
 import javax.transaction.Transactional;
 
 import org.apache.servicecomb.saga.alpha.core.TxTimeout;
 import org.apache.servicecomb.saga.alpha.core.TxTimeoutRepository;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.data.domain.PageRequest;
 
 public class SpringTxTimeoutRepository implements TxTimeoutRepository {
+  private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
   private final TxTimeoutEntityRepository timeoutRepo;
 
   SpringTxTimeoutRepository(TxTimeoutEntityRepository timeoutRepo) {
@@ -36,7 +40,11 @@ public class SpringTxTimeoutRepository implements TxTimeoutRepository {
 
   @Override
   public void save(TxTimeout timeout) {
-    timeoutRepo.save(timeout);
+    try {
+      timeoutRepo.save(timeout);
+    } catch (Exception ignored) {
+      log.warn("Failed to save some timeout {}", timeout);
+    }
   }
 
   @Override

-- 
To stop receiving notification emails like this one, please contact
ningjiang@apache.org.