[jira] [Commented] (SCB-915) saga alpha event scanner optimization

2018-10-07 Thread ASF GitHub Bot (JIRA)


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

ASF GitHub Bot commented on SCB-915:


oliugian closed pull request #313: SCB-915:saga alpha event scanner optimization
URL: https://github.com/apache/incubator-servicecomb-saga/pull/313
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/CommandRepository.java
 
b/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/CommandRepository.java
index 2bbea774..6e50619b 100644
--- 
a/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/CommandRepository.java
+++ 
b/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/CommandRepository.java
@@ -21,11 +21,15 @@
 
 public interface CommandRepository {
 
-  void saveCompensationCommands(String globalTxId);
+  void saveCompensationCommands(String globalTxId, String localTxId);
 
   void markCommandAsDone(String globalTxId, String localTxId);
 
+  void markCommandAsPending(String globalTxId, String localTxId);
+
   List findUncompletedCommands(String globalTxId);
 
-  List findFirstCommandToCompensate();
+  List findAllCommandsToCompensate();
+
+  List findPendingCommands();
 }
diff --git 
a/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/CompositeOmegaCallback.java
 
b/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/CompositeOmegaCallbackRunner.java
similarity index 50%
rename from 
alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/CompositeOmegaCallback.java
rename to 
alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/CompositeOmegaCallbackRunner.java
index 54e78f7b..058e570c 100644
--- 
a/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/CompositeOmegaCallback.java
+++ 
b/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/CompositeOmegaCallbackRunner.java
@@ -20,22 +20,35 @@
 import static java.util.Collections.emptyMap;
 
 import java.lang.invoke.MethodHandles;
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Map;
+import java.util.concurrent.Callable;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class CompositeOmegaCallback implements OmegaCallback {
+public class CompositeOmegaCallbackRunner implements OmegaCallback, 
Callable> {
+
   private static final Logger LOG = 
LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
   private final Map> callbacks;
+  private final List txEvents;
 
-  public CompositeOmegaCallback(Map> 
callbacks) {
+  public CompositeOmegaCallbackRunner(Map> 
callbacks,
+  List txEvents) {
 this.callbacks = callbacks;
+this.txEvents = txEvents;
+  }
+
+  @Override
+  public List call() {
+return compensateAllEvents(txEvents);
   }
 
   @Override
   public void compensate(TxEvent event) {
-Map serviceCallbacks = 
callbacks.getOrDefault(event.serviceName(), emptyMap());
+Map serviceCallbacks = callbacks
+.getOrDefault(event.serviceName(), emptyMap());
 
 if (serviceCallbacks.isEmpty()) {
   throw new AlphaException("No such omega callback found for service " + 
event.serviceName());
@@ -43,7 +56,8 @@ public void compensate(TxEvent event) {
 
 OmegaCallback omegaCallback = serviceCallbacks.get(event.instanceId());
 if (omegaCallback == null) {
-  LOG.info("Cannot find the service with the instanceId {}, call the other 
instance.", event.instanceId());
+  LOG.info("Cannot find the service with the instanceId {}, call the other 
instance.",
+  event.instanceId());
   omegaCallback = serviceCallbacks.values().iterator().next();
 }
 
@@ -54,4 +68,37 @@ public void compensate(TxEvent event) {
   throw e;
 }
   }
+
+  @Override
+  public List compensateAllEvents(List txEvents) {
+List resultTxEvents = new ArrayList<>();
+for (TxEvent txEvent : txEvents) {
+  try {
+LOG.info("compensating event with globalTxId: {} localTxId: {}", 
txEvent.globalTxId(),
+txEvent.localTxId());
+this.compensate(txEvent);
+resultTxEvents.add(txEvent);
+  } catch (AlphaException ae) {
+LOG.error("compensate event with globalTxId: {} localTxId: {} 
failed,error message is {}",
+txEvent.globalTxId(), txEvent.localTxId(), ae);
+break;
+  } catch (Exception e) {
+logError(txEvent, e);
+  }
+}
+
+return resultTxEvents;
+  }
+
+  private void logError(TxEvent event, Exception e) {
+LOG.error(
+"Failed to {} service [{}] instance [{}] with method [{}], global tx 
id 

[jira] [Commented] (SCB-915) saga alpha event scanner optimization

2018-10-07 Thread ASF GitHub Bot (JIRA)


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

ASF GitHub Bot commented on SCB-915:


oliugian closed pull request #311: SCB-915:saga alpha event scanner optimization
URL: https://github.com/apache/incubator-servicecomb-saga/pull/311
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/saga/omega/transaction/spring/TransactionInterceptionTest.java
 
b/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/saga/omega/transaction/spring/TransactionInterceptionTest.java
index 6b66befb..4775f6b6 100644
--- 
a/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/saga/omega/transaction/spring/TransactionInterceptionTest.java
+++ 
b/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/saga/omega/transaction/spring/TransactionInterceptionTest.java
@@ -202,19 +202,13 @@ public void retryTillSuccess() {
   fail("unexpected exception throw: " + e);
 }
 
-assertThat(messages.size(), is(4));
+assertThat(messages.size(), is(2));
 
 assertThat(messages.get(0),
 is(new TxStartedEvent(globalTxId, newLocalTxId, globalTxId, 
compensationMethod2, 0, retryMethod, 2, user, 1)
 .toString()));
 
-String abortedEvent = messages.get(1);
-assertThat(abortedEvent, allOf(containsString("TxAbortedEvent"), 
containsString("Retry harder")));
-
-assertThat(messages.get(2),
-is(new TxStartedEvent(globalTxId, newLocalTxId, globalTxId, 
compensationMethod2, 0, retryMethod, 1, user, 1)
-.toString()));
-assertThat(messages.get(3),
+assertThat(messages.get(1),
 is(new TxEndedEvent(globalTxId, newLocalTxId, globalTxId, 
compensationMethod2).toString()));
 
 assertThat(userRepository.count(), is(1L));
@@ -233,7 +227,7 @@ public void retryReachesMaximumThenThrowsException() {
   assertThat(e.getMessage(), is("Retry harder"));
 }
 
-assertThat(messages.size(), is(4));
+assertThat(messages.size(), is(2));
 assertThat(messages.get(0),
 is(new TxStartedEvent(globalTxId, newLocalTxId, globalTxId, 
compensationMethod2, 0, retryMethod, 2, user, 3)
 .toString()));
@@ -241,12 +235,6 @@ public void retryReachesMaximumThenThrowsException() {
 String abortedEvent1 = messages.get(1);
 assertThat(abortedEvent1, allOf(containsString("TxAbortedEvent"), 
containsString("Retry harder")));
 
-assertThat(messages.get(2),
-is(new TxStartedEvent(globalTxId, newLocalTxId, globalTxId, 
compensationMethod2, 0, retryMethod, 1, user, 3)
-.toString()));
-
-String abortedEvent2 = messages.get(3);
-assertThat(abortedEvent2, allOf(containsString("TxAbortedEvent"), 
containsString("Retry harder")));
 
 assertThat(userRepository.count(), is(0L));
   }
diff --git 
a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/DefaultRecovery.java
 
b/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/DefaultRecovery.java
index 08449813..b37f78db 100644
--- 
a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/DefaultRecovery.java
+++ 
b/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/DefaultRecovery.java
@@ -64,13 +64,41 @@ public Object apply(ProceedingJoinPoint joinPoint, 
Compensable compensable, Comp
   throw new InvalidTransactionException("Abort sub transaction " + 
abortedLocalTxId +
   " because global transaction " + context.globalTxId() + " has 
already aborted.");
 }
-
+int remains = retries;
 try {
-  Object result = joinPoint.proceed();
-  interceptor.postIntercept(parentTxId, compensationSignature);
+  while (true) {
+try {
+  Object result = joinPoint.proceed();
+  interceptor.postIntercept(parentTxId, compensationSignature);
+  return result;
+} catch (Throwable throwable) {
+  if (remains == 0){
+throw throwable;
+  }
+  remains = remains == -1 ? -1 : remains - 1;
+  if (remains == 0) {
+LOG.error(
+"Retried sub tx failed maximum times, global tx id: {}, local 
tx id: {}, method: {}, retried times: {}",
+context.globalTxId(), context.localTxId(), method.toString(), 
retries);
+throw throwable;
+  }
 
-  return result;
-} catch (Throwable throwable) {
+  LOG.warn(
+  "Retrying sub tx failed, global tx id: {}, local tx id: {}, 
method: {}, remains: {}",
+  context.globalTxId(), context.localTxId(), 

[jira] [Commented] (SCB-915) saga alpha event scanner optimization

2018-10-07 Thread ASF GitHub Bot (JIRA)


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

ASF GitHub Bot commented on SCB-915:


oliugian commented on issue #311: SCB-915:saga alpha event scanner optimization
URL: 
https://github.com/apache/incubator-servicecomb-saga/pull/311#issuecomment-427702853
 
 
   ignore it


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


> saga alpha event scanner optimization
> -
>
> Key: SCB-915
> URL: https://issues.apache.org/jira/browse/SCB-915
> Project: Apache ServiceComb
>  Issue Type: Improvement
>Reporter: FuChenGeng
>Assignee: FuChenGeng
>Priority: Major
>
> 1.the compensate logic for retry scenarios is not perfect, in some place it 
> do not considering retry scenarios.
> 2.do one compensation in one event scanner cycle,it mean that if there are 
> 1000 aborted event, it will cost at lest 500s to compensate it. And it has 
> some bugs like
> [https://github.com/apache/incubator-servicecomb-saga/issues/253]
> 3.all hot and cold data are in the same table
> 4. omega do not send every try event to alpha.omega do it's try logic by 
> itself.



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


[jira] [Commented] (SCB-915) saga alpha event scanner optimization

2018-10-07 Thread ASF GitHub Bot (JIRA)


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

ASF GitHub Bot commented on SCB-915:


oliugian closed pull request #311: SCB-915:saga alpha event scanner optimization
URL: https://github.com/apache/incubator-servicecomb-saga/pull/311
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/saga/omega/transaction/spring/TransactionInterceptionTest.java
 
b/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/saga/omega/transaction/spring/TransactionInterceptionTest.java
index 6b66befb..4775f6b6 100644
--- 
a/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/saga/omega/transaction/spring/TransactionInterceptionTest.java
+++ 
b/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/saga/omega/transaction/spring/TransactionInterceptionTest.java
@@ -202,19 +202,13 @@ public void retryTillSuccess() {
   fail("unexpected exception throw: " + e);
 }
 
-assertThat(messages.size(), is(4));
+assertThat(messages.size(), is(2));
 
 assertThat(messages.get(0),
 is(new TxStartedEvent(globalTxId, newLocalTxId, globalTxId, 
compensationMethod2, 0, retryMethod, 2, user, 1)
 .toString()));
 
-String abortedEvent = messages.get(1);
-assertThat(abortedEvent, allOf(containsString("TxAbortedEvent"), 
containsString("Retry harder")));
-
-assertThat(messages.get(2),
-is(new TxStartedEvent(globalTxId, newLocalTxId, globalTxId, 
compensationMethod2, 0, retryMethod, 1, user, 1)
-.toString()));
-assertThat(messages.get(3),
+assertThat(messages.get(1),
 is(new TxEndedEvent(globalTxId, newLocalTxId, globalTxId, 
compensationMethod2).toString()));
 
 assertThat(userRepository.count(), is(1L));
@@ -233,7 +227,7 @@ public void retryReachesMaximumThenThrowsException() {
   assertThat(e.getMessage(), is("Retry harder"));
 }
 
-assertThat(messages.size(), is(4));
+assertThat(messages.size(), is(2));
 assertThat(messages.get(0),
 is(new TxStartedEvent(globalTxId, newLocalTxId, globalTxId, 
compensationMethod2, 0, retryMethod, 2, user, 3)
 .toString()));
@@ -241,12 +235,6 @@ public void retryReachesMaximumThenThrowsException() {
 String abortedEvent1 = messages.get(1);
 assertThat(abortedEvent1, allOf(containsString("TxAbortedEvent"), 
containsString("Retry harder")));
 
-assertThat(messages.get(2),
-is(new TxStartedEvent(globalTxId, newLocalTxId, globalTxId, 
compensationMethod2, 0, retryMethod, 1, user, 3)
-.toString()));
-
-String abortedEvent2 = messages.get(3);
-assertThat(abortedEvent2, allOf(containsString("TxAbortedEvent"), 
containsString("Retry harder")));
 
 assertThat(userRepository.count(), is(0L));
   }
diff --git 
a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/DefaultRecovery.java
 
b/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/DefaultRecovery.java
index 08449813..b37f78db 100644
--- 
a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/DefaultRecovery.java
+++ 
b/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/DefaultRecovery.java
@@ -64,13 +64,41 @@ public Object apply(ProceedingJoinPoint joinPoint, 
Compensable compensable, Comp
   throw new InvalidTransactionException("Abort sub transaction " + 
abortedLocalTxId +
   " because global transaction " + context.globalTxId() + " has 
already aborted.");
 }
-
+int remains = retries;
 try {
-  Object result = joinPoint.proceed();
-  interceptor.postIntercept(parentTxId, compensationSignature);
+  while (true) {
+try {
+  Object result = joinPoint.proceed();
+  interceptor.postIntercept(parentTxId, compensationSignature);
+  return result;
+} catch (Throwable throwable) {
+  if (remains == 0){
+throw throwable;
+  }
+  remains = remains == -1 ? -1 : remains - 1;
+  if (remains == 0) {
+LOG.error(
+"Retried sub tx failed maximum times, global tx id: {}, local 
tx id: {}, method: {}, retried times: {}",
+context.globalTxId(), context.localTxId(), method.toString(), 
retries);
+throw throwable;
+  }
 
-  return result;
-} catch (Throwable throwable) {
+  LOG.warn(
+  "Retrying sub tx failed, global tx id: {}, local tx id: {}, 
method: {}, remains: {}",
+  context.globalTxId(), context.localTxId(), 

[jira] [Commented] (SCB-915) saga alpha event scanner optimization

2018-10-07 Thread ASF GitHub Bot (JIRA)


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

ASF GitHub Bot commented on SCB-915:


oliugian opened a new pull request #311: SCB-915:saga alpha event scanner 
optimization
URL: https://github.com/apache/incubator-servicecomb-saga/pull/311
 
 
   omega do not send every try event to alpha.omega do it's try logic by itself.


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


> saga alpha event scanner optimization
> -
>
> Key: SCB-915
> URL: https://issues.apache.org/jira/browse/SCB-915
> Project: Apache ServiceComb
>  Issue Type: Improvement
>Reporter: FuChenGeng
>Assignee: FuChenGeng
>Priority: Major
>
> 1.the compensate logic for retry scenarios is not perfect, in some place it 
> do not considering retry scenarios.
> 2.do one compensation in one event scanner cycle,it mean that if there are 
> 1000 aborted event, it will cost at lest 500s to compensate it. And it has 
> some bugs like
> [https://github.com/apache/incubator-servicecomb-saga/issues/253]
> 3.all hot and cold data are in the same table
> 4. omega do not send every try event to alpha.omega do it's try logic by 
> itself.



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


[jira] [Commented] (SCB-915) saga alpha event scanner optimization

2018-09-21 Thread ASF GitHub Bot (JIRA)


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

ASF GitHub Bot commented on SCB-915:


Chenhaoqing commented on a change in pull request #313: SCB-915:saga alpha 
event scanner optimization
URL: 
https://github.com/apache/incubator-servicecomb-saga/pull/313#discussion_r219466552
 
 

 ##
 File path: 
alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/CompositeOmegaCallbackRunner.java
 ##
 @@ -54,4 +68,37 @@ public void compensate(TxEvent event) {
   throw e;
 }
   }
+
+  @Override
+  public List compensateAllEvents(List txEvents) {
+List resultTxEvents = new ArrayList<>();
+for (TxEvent txEvent : txEvents) {
+  try {
+LOG.info("compensating event with globalTxId: {} localTxId: {}", 
txEvent.globalTxId(),
+txEvent.localTxId());
+this.compensate(txEvent);
+resultTxEvents.add(txEvent);
+  } catch (AlphaException ae) {
+LOG.error("compensate event with globalTxId: {} localTxId: {} 
failed,error message is {}",
+txEvent.globalTxId(), txEvent.localTxId(), ae);
+break;
 
 Review comment:
   I think it would be better to continue executing the looping.


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


> saga alpha event scanner optimization
> -
>
> Key: SCB-915
> URL: https://issues.apache.org/jira/browse/SCB-915
> Project: Apache ServiceComb
>  Issue Type: Improvement
>Reporter: FuChenGeng
>Assignee: FuChenGeng
>Priority: Major
>
> 1.the compensate logic for retry scenarios is not perfect, in some place it 
> do not considering retry scenarios.
> 2.do one compensation in one event scanner cycle,it mean that if there are 
> 1000 aborted event, it will cost at lest 500s to compensate it. And it has 
> some bugs like
> [https://github.com/apache/incubator-servicecomb-saga/issues/253]
> 3.all hot and cold data are in the same table
> 4. omega do not send every try event to alpha.omega do it's try logic by 
> itself.



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


[jira] [Commented] (SCB-915) saga alpha event scanner optimization

2018-09-21 Thread ASF GitHub Bot (JIRA)


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

ASF GitHub Bot commented on SCB-915:


coveralls commented on issue #313: SCB-915:saga alpha event scanner optimization
URL: 
https://github.com/apache/incubator-servicecomb-saga/pull/313#issuecomment-423477947
 
 
   
   [![Coverage 
Status](https://coveralls.io/builds/19120276/badge)](https://coveralls.io/builds/19120276)
   
   Coverage decreased (-1.1%) to 90.09% when pulling 
**10eead21ddce3191f324832564101606503dcd7a on 
oliugian:SCB-915_Alpha_optimization** into 
**24ca70bbfb06b0b9e4cd60dc93837ffb0e784bec on apache:master**.
   


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


> saga alpha event scanner optimization
> -
>
> Key: SCB-915
> URL: https://issues.apache.org/jira/browse/SCB-915
> Project: Apache ServiceComb
>  Issue Type: Improvement
>Reporter: FuChenGeng
>Assignee: FuChenGeng
>Priority: Major
>
> 1.the compensate logic for retry scenarios is not perfect, in some place it 
> do not considering retry scenarios.
> 2.do one compensation in one event scanner cycle,it mean that if there are 
> 1000 aborted event, it will cost at lest 500s to compensate it. And it has 
> some bugs like
> [https://github.com/apache/incubator-servicecomb-saga/issues/253]
> 3.all hot and cold data are in the same table
> 4. omega do not send every try event to alpha.omega do it's try logic by 
> itself.



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


[jira] [Commented] (SCB-915) saga alpha event scanner optimization

2018-09-21 Thread ASF GitHub Bot (JIRA)


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

ASF GitHub Bot commented on SCB-915:


oliugian opened a new pull request #313: SCB-915:saga alpha event scanner 
optimization
URL: https://github.com/apache/incubator-servicecomb-saga/pull/313
 
 
   
   https://issues.apache.org/jira/browse/SCB-915


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


> saga alpha event scanner optimization
> -
>
> Key: SCB-915
> URL: https://issues.apache.org/jira/browse/SCB-915
> Project: Apache ServiceComb
>  Issue Type: Improvement
>Reporter: FuChenGeng
>Assignee: FuChenGeng
>Priority: Major
>
> 1.the compensate logic for retry scenarios is not perfect, in some place it 
> do not considering retry scenarios.
> 2.do one compensation in one event scanner cycle,it mean that if there are 
> 1000 aborted event, it will cost at lest 500s to compensate it. And it has 
> some bugs like
> [https://github.com/apache/incubator-servicecomb-saga/issues/253]
> 3.all hot and cold data are in the same table
> 4. omega do not send every try event to alpha.omega do it's try logic by 
> itself.



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


[jira] [Commented] (SCB-915) saga alpha event scanner optimization

2018-09-20 Thread ASF GitHub Bot (JIRA)


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

ASF GitHub Bot commented on SCB-915:


oliugian closed pull request #299: SCB-915:saga alpha event scanner optimization
URL: https://github.com/apache/incubator-servicecomb-saga/pull/299
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/AlphaException.java
 
b/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/AlphaException.java
index a7bb7564..1f63b14d 100644
--- 
a/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/AlphaException.java
+++ 
b/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/AlphaException.java
@@ -18,6 +18,7 @@
 package org.apache.servicecomb.saga.alpha.core;
 
 public class AlphaException extends RuntimeException {
+
   public AlphaException(String cause) {
 super(cause);
   }
diff --git 
a/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/Command.java
 
b/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/Command.java
index 6c8f3708..3c222c67 100644
--- 
a/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/Command.java
+++ 
b/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/Command.java
@@ -85,7 +85,8 @@ public Command(long id,
   String compensationMethod,
   byte[] payloads) {
 
-this(id, serviceName, instanceId, globalTxId, localTxId, parentTxId, 
compensationMethod, payloads, NEW.name());
+this(id, serviceName, instanceId, globalTxId, localTxId, parentTxId, 
compensationMethod,
+payloads, NEW.name());
   }
 
   public Command(TxEvent event) {
diff --git 
a/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/CommandRepository.java
 
b/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/CommandRepository.java
index 2bbea774..6e50619b 100644
--- 
a/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/CommandRepository.java
+++ 
b/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/CommandRepository.java
@@ -21,11 +21,15 @@
 
 public interface CommandRepository {
 
-  void saveCompensationCommands(String globalTxId);
+  void saveCompensationCommands(String globalTxId, String localTxId);
 
   void markCommandAsDone(String globalTxId, String localTxId);
 
+  void markCommandAsPending(String globalTxId, String localTxId);
+
   List findUncompletedCommands(String globalTxId);
 
-  List findFirstCommandToCompensate();
+  List findAllCommandsToCompensate();
+
+  List findPendingCommands();
 }
diff --git 
a/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/CompositeOmegaCallback.java
 
b/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/CompositeOmegaCallbackRunner.java
similarity index 50%
rename from 
alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/CompositeOmegaCallback.java
rename to 
alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/CompositeOmegaCallbackRunner.java
index 54e78f7b..058e570c 100644
--- 
a/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/CompositeOmegaCallback.java
+++ 
b/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/CompositeOmegaCallbackRunner.java
@@ -20,22 +20,35 @@
 import static java.util.Collections.emptyMap;
 
 import java.lang.invoke.MethodHandles;
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Map;
+import java.util.concurrent.Callable;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class CompositeOmegaCallback implements OmegaCallback {
+public class CompositeOmegaCallbackRunner implements OmegaCallback, 
Callable> {
+
   private static final Logger LOG = 
LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
   private final Map> callbacks;
+  private final List txEvents;
 
-  public CompositeOmegaCallback(Map> 
callbacks) {
+  public CompositeOmegaCallbackRunner(Map> 
callbacks,
+  List txEvents) {
 this.callbacks = callbacks;
+this.txEvents = txEvents;
+  }
+
+  @Override
+  public List call() {
+return compensateAllEvents(txEvents);
   }
 
   @Override
   public void compensate(TxEvent event) {
-Map serviceCallbacks = 
callbacks.getOrDefault(event.serviceName(), emptyMap());
+Map serviceCallbacks = callbacks
+.getOrDefault(event.serviceName(), emptyMap());
 
 if (serviceCallbacks.isEmpty()) {
   throw new AlphaException("No such omega callback found for service " + 
event.serviceName());
@@ -43,7 +56,8 @@ public 

[jira] [Commented] (SCB-915) saga alpha event scanner optimization

2018-09-20 Thread ASF GitHub Bot (JIRA)


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

ASF GitHub Bot commented on SCB-915:


oliugian commented on issue #311: SCB-915:saga alpha event scanner optimization
URL: 
https://github.com/apache/incubator-servicecomb-saga/pull/311#issuecomment-423400520
 
 
   All tests have been successful
   The functionality of ForwardRecovery has been incorporated into 
defaultRecovery, so delete it and its test code. There is a test code 
equivalent to ForwardRecover in TransactionAspectTest.
   (-1) means infinite retry, but it can also be interrupted, throwing an 
InterruptedException, which is consistent with the logic in the previous 
ForwardRecovery


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


> saga alpha event scanner optimization
> -
>
> Key: SCB-915
> URL: https://issues.apache.org/jira/browse/SCB-915
> Project: Apache ServiceComb
>  Issue Type: Improvement
>Reporter: FuChenGeng
>Assignee: FuChenGeng
>Priority: Major
>
> 1.the compensate logic for retry scenarios is not perfect, in some place it 
> do not considering retry scenarios.
> 2.do one compensation in one event scanner cycle,it mean that if there are 
> 1000 aborted event, it will cost at lest 500s to compensate it. And it has 
> some bugs like
> [https://github.com/apache/incubator-servicecomb-saga/issues/253]
> 3.all hot and cold data are in the same table
> 4. omega do not send every try event to alpha.omega do it's try logic by 
> itself.



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


[jira] [Commented] (SCB-915) saga alpha event scanner optimization

2018-09-20 Thread ASF GitHub Bot (JIRA)


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

ASF GitHub Bot commented on SCB-915:


oliugian opened a new pull request #311: SCB-915:saga alpha event scanner 
optimization
URL: https://github.com/apache/incubator-servicecomb-saga/pull/311
 
 
   omega do not send every try event to alpha.omega do it's try logic by itself.


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


> saga alpha event scanner optimization
> -
>
> Key: SCB-915
> URL: https://issues.apache.org/jira/browse/SCB-915
> Project: Apache ServiceComb
>  Issue Type: Improvement
>Reporter: FuChenGeng
>Assignee: FuChenGeng
>Priority: Major
>
> 1.the compensate logic for retry scenarios is not perfect, in some place it 
> do not considering retry scenarios.
> 2.do one compensation in one event scanner cycle,it mean that if there are 
> 1000 aborted event, it will cost at lest 500s to compensate it. And it has 
> some bugs like
> [https://github.com/apache/incubator-servicecomb-saga/issues/253]
> 3.all hot and cold data are in the same table
> 4. omega do not send every try event to alpha.omega do it's try logic by 
> itself.



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


[jira] [Commented] (SCB-915) saga alpha event scanner optimization

2018-09-17 Thread ASF GitHub Bot (JIRA)


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

ASF GitHub Bot commented on SCB-915:


oliugian commented on a change in pull request #299: SCB-915:saga alpha event 
scanner optimization
URL: 
https://github.com/apache/incubator-servicecomb-saga/pull/299#discussion_r218005683
 
 

 ##
 File path: 
alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/TxEventEnvelopeRepository.java
 ##
 @@ -110,10 +111,65 @@
   + "AND t4.localTxId = t.localTxId "
   + "AND t4.type = 'TxStartedEvent' ) = 0 "
   + "ORDER BY t.surrogateId ASC")
-  List findFirstByTypeAndSurrogateIdGreaterThan(String type, long 
surrogateId, Pageable pageable);
+  List findFirstByTypeAndSurrogateIdGreaterThan(String type, long 
surrogateId,
+  Pageable pageable);
 
   Optional findFirstByTypeAndSurrogateIdGreaterThan(String type, long 
surrogateId);
 
+  @Query("SELECT t FROM TxEvent t "
+  + "WHERE t.type = 'TxEndedEvent' AND NOT EXISTS ( "
+  + "  SELECT t1.globalTxId FROM TxEvent t1 "
+  + "  WHERE t1.globalTxId = t.globalTxId "
+  + "AND t1.type = 'TxStartedEvent' AND NOT EXISTS ( "
+  + "SELECT t2.globalTxId FROM TxEvent t2 "
+  + "WHERE t2.globalTxId = t1.globalTxId "
+  + "  AND t2.localTxId = t1.localTxId "
+  + "  AND t2.creationTime > t1.creationTime)) AND EXISTS ( "
+  + "  SELECT t3.globalTxId FROM TxEvent t3 "
+  + "  WHERE t3.globalTxId = t.globalTxId "
+  + "  AND t3.type = 'TxAbortedEvent' AND NOT EXISTS ( "
+  + "SELECT t4.globalTxId FROM TxEvent t4 "
+  + "WHERE t4.globalTxId = t3.globalTxId "
+  + "  AND t4.localTxId = t3.localTxId "
+  + "  AND t4.creationTime > t3.creationTime)) AND NOT EXISTS ( "
+  + "  SELECT t5.globalTxId FROM TxEvent t5 "
+  + "  WHERE t5.globalTxId = t.globalTxId "
+  + "AND t5.localTxId = t.localTxId "
+  + "AND t5.type = 'TxCompensatedEvent') AND NOT EXISTS ( "
+  + "   SELECT c FROM Command c "
+  + "   WHERE c.globalTxId = t.globalTxId "
+  + "AND c.localTxId = t.localTxId ) ")
+  List findNeedToCompensateTxs();
 
 Review comment:
   for the try logic. if a transaction is nested,if this sub transaction is not 
done ,it must have a tx_start_event with no other event behind.
   if a transaction is not nested.is's lasted tx event must be aborted.


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


> saga alpha event scanner optimization
> -
>
> Key: SCB-915
> URL: https://issues.apache.org/jira/browse/SCB-915
> Project: Apache ServiceComb
>  Issue Type: Improvement
>Reporter: FuChenGeng
>Assignee: FuChenGeng
>Priority: Major
>
> 1.the compensate logic for retry scenarios is not perfect, in some place it 
> do not considering retry scenarios.
> 2.do one compensation in one event scanner cycle,it mean that if there are 
> 1000 aborted event, it will cost at lest 500s to compensate it. And it has 
> some bugs like
> [https://github.com/apache/incubator-servicecomb-saga/issues/253]
> 3.all hot and cold data are in the same table



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


[jira] [Commented] (SCB-915) saga alpha event scanner optimization

2018-09-17 Thread ASF GitHub Bot (JIRA)


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

ASF GitHub Bot commented on SCB-915:


oliugian commented on a change in pull request #299: SCB-915:saga alpha event 
scanner optimization
URL: 
https://github.com/apache/incubator-servicecomb-saga/pull/299#discussion_r217999244
 
 

 ##
 File path: 
alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/AlphaConfig.java
 ##
 @@ -60,16 +54,17 @@
 
   @Bean
   OmegaCallback omegaCallback(Map> 
callbacks) {
-return new PushBackOmegaCallback(pendingCompensations, new 
CompositeOmegaCallback(callbacks));
 
 Review comment:
   do not need pending queue anymore


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


> saga alpha event scanner optimization
> -
>
> Key: SCB-915
> URL: https://issues.apache.org/jira/browse/SCB-915
> Project: Apache ServiceComb
>  Issue Type: Improvement
>Reporter: FuChenGeng
>Assignee: FuChenGeng
>Priority: Major
>
> 1.the compensate logic for retry scenarios is not perfect, in some place it 
> do not considering retry scenarios.
> 2.do one compensation in one event scanner cycle,it mean that if there are 
> 1000 aborted event, it will cost at lest 500s to compensate it. And it has 
> some bugs like
> [https://github.com/apache/incubator-servicecomb-saga/issues/253]
> 3.all hot and cold data are in the same table



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


[jira] [Commented] (SCB-915) saga alpha event scanner optimization

2018-09-17 Thread ASF GitHub Bot (JIRA)


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

ASF GitHub Bot commented on SCB-915:


oliugian commented on a change in pull request #299: SCB-915:saga alpha event 
scanner optimization
URL: 
https://github.com/apache/incubator-servicecomb-saga/pull/299#discussion_r217998661
 
 

 ##
 File path: 
alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/PushBackOmegaCallback.java
 ##
 @@ -18,41 +18,56 @@
 package org.apache.servicecomb.saga.alpha.core;
 
 import java.lang.invoke.MethodHandles;
+import java.util.*;
 import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Future;
+import java.util.stream.Collectors;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import static java.util.Collections.emptyMap;
+
 public class PushBackOmegaCallback implements OmegaCallback {
+
   private static final Logger LOG = 
LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
 
-  private final BlockingQueue pendingCompensations;
-  private final OmegaCallback underlying;
+  private final Map> callbacks;
+  private final ExecutorService compensateExecutor;
 
-  public PushBackOmegaCallback(BlockingQueue pendingCompensations, 
OmegaCallback underlying) {
-this.pendingCompensations = pendingCompensations;
-this.underlying = underlying;
+  public PushBackOmegaCallback(Map> 
callbacks,
+  ExecutorService compensateExecutor) {
+this.callbacks = callbacks;
+this.compensateExecutor = compensateExecutor;
   }
 
   @Override
-  public void compensate(TxEvent event) {
-try {
-  underlying.compensate(event);
-} catch (Exception e) {
-  logError(event, e);
-  pendingCompensations.offer(() -> compensate(event));
-}
+  public List compensateAllEvents(List txEvents) {
+List>> futures = new ArrayList<>();
+List result = new ArrayList<>();
+Set services = new HashSet<>();
 
 Review comment:
   filter all events with service name . and create threads to compensate event 
with the same service name .


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


> saga alpha event scanner optimization
> -
>
> Key: SCB-915
> URL: https://issues.apache.org/jira/browse/SCB-915
> Project: Apache ServiceComb
>  Issue Type: Improvement
>Reporter: FuChenGeng
>Assignee: FuChenGeng
>Priority: Major
>
> 1.the compensate logic for retry scenarios is not perfect, in some place it 
> do not considering retry scenarios.
> 2.do one compensation in one event scanner cycle,it mean that if there are 
> 1000 aborted event, it will cost at lest 500s to compensate it. And it has 
> some bugs like
> [https://github.com/apache/incubator-servicecomb-saga/issues/253]
> 3.all hot and cold data are in the same table



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


[jira] [Commented] (SCB-915) saga alpha event scanner optimization

2018-09-17 Thread ASF GitHub Bot (JIRA)


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

ASF GitHub Bot commented on SCB-915:


oliugian commented on a change in pull request #299: SCB-915:saga alpha event 
scanner optimization
URL: 
https://github.com/apache/incubator-servicecomb-saga/pull/299#discussion_r21799
 
 

 ##
 File path: 
alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/EventScanner.java
 ##
 @@ -79,58 +79,66 @@ private void pollEvents() {
 scheduler.scheduleWithFixedDelay(
 () -> {
   updateTimeoutStatus();
-  findTimeoutEvents();
+  findAllTimeoutEvents();
   abortTimeoutEvents();
   saveUncompensatedEventsToCommands();
   compensate();
   updateCompensatedCommands();
+  markSagaEndedForNoTxEnd();
   deleteDuplicateSagaEndedEvents();
-  updateTransactionStatus();
+  //Temporarily comment it since  AlphaIntegration Test will failed.
+  //dumpColdData();
 },
 0,
 eventPollingInterval,
 MILLISECONDS);
   }
 
-  @Trace("findTimeoutEvents")
-  private void findTimeoutEvents() {
+  private void updateTimeoutStatus() {
+timeoutRepository.markTimeoutAsDone();
+  }
+
+  @Trace("findAllTimeoutEvents")
+  private void findAllTimeoutEvents() {
 eventRepository.findTimeoutEvents()
 .forEach(event -> {
   LOG.info("Found timeout event {}", event);
   timeoutRepository.save(txTimeoutOf(event));
 });
   }
 
-  private void updateTimeoutStatus() {
-timeoutRepository.markTimeoutAsDone();
+  @Trace("abortTimeoutEvents")
+  private void abortTimeoutEvents() {
+timeoutRepository.findTimeouts().forEach(timeout -> {
+  LOG.info("Found timeout event {} to abort", timeout);
+  eventRepository.save(toTxAbortedEvent(timeout));
+});
   }
 
   @Trace("saveUncompensatedEventsToCommands")
   private void saveUncompensatedEventsToCommands() {
-
eventRepository.findFirstUncompensatedEventByIdGreaterThan(nextEndedEventId, 
TxEndedEvent.name())
+eventRepository.findNeedToCompensateTxs()
 .forEach(event -> {
   LOG.info("Found uncompensated event {}", event);
-  nextEndedEventId = event.id();
-  commandRepository.saveCompensationCommands(event.globalTxId());
+  commandRepository.saveCompensationCommands(event.globalTxId(), 
event.localTxId());
 });
   }
 
-  @Trace("updateCompensationStatus")
-  private void updateCompensatedCommands() {
-
eventRepository.findFirstCompensatedEventByIdGreaterThan(nextCompensatedEventId)
-.ifPresent(event -> {
-  LOG.info("Found compensated event {}", event);
-  nextCompensatedEventId = event.id();
-  updateCompensationStatus(event);
-});
+  @Trace("compensate")
+  private void compensate() {
+List compensateTxEvents = new ArrayList<>();
+commandRepository.findAllCommandsToCompensate()
+.forEach(command ->
+compensateTxEvents.add(txStartedEventOf(command))
+);
+omegaCallback.compensateAllEvents(compensateTxEvents).forEach(
+event -> commandRepository.markCommandAsPending(event.globalTxId(), 
event.localTxId()));
   }
 
 Review comment:
   command was mark as pending only the omega callback compensate successfully 


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


> saga alpha event scanner optimization
> -
>
> Key: SCB-915
> URL: https://issues.apache.org/jira/browse/SCB-915
> Project: Apache ServiceComb
>  Issue Type: Improvement
>Reporter: FuChenGeng
>Assignee: FuChenGeng
>Priority: Major
>
> 1.the compensate logic for retry scenarios is not perfect, in some place it 
> do not considering retry scenarios.
> 2.do one compensation in one event scanner cycle,it mean that if there are 
> 1000 aborted event, it will cost at lest 500s to compensate it. And it has 
> some bugs like
> [https://github.com/apache/incubator-servicecomb-saga/issues/253]
> 3.all hot and cold data are in the same table



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


[jira] [Commented] (SCB-915) saga alpha event scanner optimization

2018-09-17 Thread ASF GitHub Bot (JIRA)


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

ASF GitHub Bot commented on SCB-915:


oliugian commented on a change in pull request #299: SCB-915:saga alpha event 
scanner optimization
URL: 
https://github.com/apache/incubator-servicecomb-saga/pull/299#discussion_r217996731
 
 

 ##
 File path: 
alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/EventScanner.java
 ##
 @@ -79,58 +79,66 @@ private void pollEvents() {
 scheduler.scheduleWithFixedDelay(
 () -> {
   updateTimeoutStatus();
-  findTimeoutEvents();
+  findAllTimeoutEvents();
   abortTimeoutEvents();
   saveUncompensatedEventsToCommands();
   compensate();
   updateCompensatedCommands();
+  markSagaEndedForNoTxEnd();
 
 Review comment:
   for these transaction: 
   saga_start->tx_start->tx_abort->tx_abort 
   we need to add a saga_end behind them ,so we can judge them finish.
   for dumping finished transactions.


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


> saga alpha event scanner optimization
> -
>
> Key: SCB-915
> URL: https://issues.apache.org/jira/browse/SCB-915
> Project: Apache ServiceComb
>  Issue Type: Improvement
>Reporter: FuChenGeng
>Assignee: FuChenGeng
>Priority: Major
>
> 1.the compensate logic for retry scenarios is not perfect, in some place it 
> do not considering retry scenarios.
> 2.do one compensation in one event scanner cycle,it mean that if there are 
> 1000 aborted event, it will cost at lest 500s to compensate it. And it has 
> some bugs like
> [https://github.com/apache/incubator-servicecomb-saga/issues/253]
> 3.all hot and cold data are in the same table



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


[jira] [Commented] (SCB-915) saga alpha event scanner optimization

2018-09-17 Thread ASF GitHub Bot (JIRA)


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

ASF GitHub Bot commented on SCB-915:


oliugian commented on a change in pull request #299: SCB-915:saga alpha event 
scanner optimization
URL: 
https://github.com/apache/incubator-servicecomb-saga/pull/299#discussion_r217995904
 
 

 ##
 File path: 
alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/CompositeOmegaCallbackRunner.java
 ##
 @@ -20,30 +20,44 @@
 import static java.util.Collections.emptyMap;
 
 import java.lang.invoke.MethodHandles;
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Map;
+import java.util.concurrent.Callable;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class CompositeOmegaCallback implements OmegaCallback {
+public class CompositeOmegaCallbackRunner implements OmegaCallback, 
Callable> {
 
 Review comment:
   since omega call back is not thread safe. so compensate the same service use 
one thread.use other thread to compensate other service.


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


> saga alpha event scanner optimization
> -
>
> Key: SCB-915
> URL: https://issues.apache.org/jira/browse/SCB-915
> Project: Apache ServiceComb
>  Issue Type: Improvement
>Reporter: FuChenGeng
>Assignee: FuChenGeng
>Priority: Major
>
> 1.the compensate logic for retry scenarios is not perfect, in some place it 
> do not considering retry scenarios.
> 2.do one compensation in one event scanner cycle,it mean that if there are 
> 1000 aborted event, it will cost at lest 500s to compensate it. And it has 
> some bugs like
> [https://github.com/apache/incubator-servicecomb-saga/issues/253]
> 3.all hot and cold data are in the same table



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


[jira] [Commented] (SCB-915) saga alpha event scanner optimization

2018-09-17 Thread ASF GitHub Bot (JIRA)


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

ASF GitHub Bot commented on SCB-915:


oliugian commented on a change in pull request #299: SCB-915:saga alpha event 
scanner optimization
URL: 
https://github.com/apache/incubator-servicecomb-saga/pull/299#discussion_r217994961
 
 

 ##
 File path: 
alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/CompositeOmegaCallbackRunner.java
 ##
 @@ -20,30 +20,44 @@
 import static java.util.Collections.emptyMap;
 
 import java.lang.invoke.MethodHandles;
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Map;
+import java.util.concurrent.Callable;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class CompositeOmegaCallback implements OmegaCallback {
+public class CompositeOmegaCallbackRunner implements OmegaCallback, 
Callable> {
 
 Review comment:
   Compensate Thread , using by PushBackOmegaCallback . PushBackOmegaCallback  
will filter all compensate event by there service name ,do all compensate event 
list with the same service name  in one  CompositeOmegaCallbackRunner  thread 
and only return those  compensate events which are successful.


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


> saga alpha event scanner optimization
> -
>
> Key: SCB-915
> URL: https://issues.apache.org/jira/browse/SCB-915
> Project: Apache ServiceComb
>  Issue Type: Improvement
>Reporter: FuChenGeng
>Assignee: FuChenGeng
>Priority: Major
>
> 1.the compensate logic for retry scenarios is not perfect, in some place it 
> do not considering retry scenarios.
> 2.do one compensation in one event scanner cycle,it mean that if there are 
> 1000 aborted event, it will cost at lest 500s to compensate it. And it has 
> some bugs like
> [https://github.com/apache/incubator-servicecomb-saga/issues/253]
> 3.all hot and cold data are in the same table



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


[jira] [Commented] (SCB-915) saga alpha event scanner optimization

2018-09-17 Thread ASF GitHub Bot (JIRA)


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

ASF GitHub Bot commented on SCB-915:


WillemJiang commented on a change in pull request #299: SCB-915:saga alpha 
event scanner optimization
URL: 
https://github.com/apache/incubator-servicecomb-saga/pull/299#discussion_r217983819
 
 

 ##
 File path: 
alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/Command.java
 ##
 @@ -55,14 +55,14 @@
   }
 
   private Command(long id,
-  String serviceName,
-  String instanceId,
-  String globalTxId,
-  String localTxId,
-  String parentTxId,
-  String compensationMethod,
-  byte[] payloads,
-  String status) {
+  String serviceName,
 
 Review comment:
   Please don't reformat the code that you don't change. 
   You can setup your IDE to only reformat the code that VCS changed.
   http://servicecomb.apache.org/developers/setup-develop-environment/


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


> saga alpha event scanner optimization
> -
>
> Key: SCB-915
> URL: https://issues.apache.org/jira/browse/SCB-915
> Project: Apache ServiceComb
>  Issue Type: Improvement
>Reporter: FuChenGeng
>Assignee: FuChenGeng
>Priority: Major
>
> 1.the compensate logic for retry scenarios is not perfect, in some place it 
> do not considering retry scenarios.
> 2.do one compensation in one event scanner cycle,it mean that if there are 
> 1000 aborted event, it will cost at lest 500s to compensate it. And it has 
> some bugs like
> [https://github.com/apache/incubator-servicecomb-saga/issues/253]
> 3.all hot and cold data are in the same table



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


[jira] [Commented] (SCB-915) saga alpha event scanner optimization

2018-09-17 Thread ASF GitHub Bot (JIRA)


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

ASF GitHub Bot commented on SCB-915:


oliugian opened a new pull request #299: SCB-915:saga alpha event scanner 
optimization
URL: https://github.com/apache/incubator-servicecomb-saga/pull/299
 
 
   SCB-915:saga alpha event scanner optimization
   https://issues.apache.org/jira/browse/SCB-915
   
   do all compensation in one event scanner cycle,and if compensate failed,will 
try again.
   fix out https://github.com/apache/incubator-servicecomb-saga/issues/253
   optimize retry logic and judgement of tx abort event.


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


> saga alpha event scanner optimization
> -
>
> Key: SCB-915
> URL: https://issues.apache.org/jira/browse/SCB-915
> Project: Apache ServiceComb
>  Issue Type: Improvement
>Reporter: FuChenGeng
>Assignee: FuChenGeng
>Priority: Major
>
> 1.the compensate logic for retry scenarios is not perfect, in some place it 
> do not considering retry scenarios.
> 2.do one compensation in one event scanner cycle,it mean that if there are 
> 1000 aborted event, it will cost at lest 500s to compensate it. And it has 
> some bugs like
> [https://github.com/apache/incubator-servicecomb-saga/issues/253]
> 3.all hot and cold data are in the same table



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