SCB-224 retry sub-transaction on failure#138
Conversation
|
@eric-lee-ltk There are some build error in you commit, could you take a look at it? |
3d748fd to
c26feb1
Compare
f516204 to
c1d96b2
Compare
| aspect.advise(joinPoint, compensable); | ||
| try { | ||
| aspect.advise(joinPoint, compensable); | ||
| } catch (Exception e) { |
There was a problem hiding this comment.
We don't need to catch the exception here, as the JUnit test failed when the exception is throw.
| expectFailing(InterruptedException.class); | ||
| } catch (InterruptedException ignored) { | ||
| } catch (Throwable throwable) { | ||
| fail("unexpected exception throw: " + throwable); |
There was a problem hiding this comment.
I'm not sure if the fail can work, as the exception is thrown in another thread. Maybe you need to run a test for it.
| @Aspect | ||
| public class TransactionAspect { | ||
| private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); | ||
| private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); |
There was a problem hiding this comment.
It's common practice to use upper case for the static constant.
| package org.apache.servicecomb.saga.omega.transaction; | ||
|
|
||
| public class RecoveryPolicyFactory { | ||
| private static final RecoveryPolicy defaultRecovery = new DefaultRecovery(); |
There was a problem hiding this comment.
It's common practice to use upper case for the static constant.
|
|
||
| private static final RecoveryPolicy forwardRecovery = new ForwardRecovery(); | ||
|
|
||
| static RecoveryPolicy getRecoveryPolicy(int retries) { |
There was a problem hiding this comment.
How can you decide the RecoveryPolicy by using the retries parameter.
There was a problem hiding this comment.
Which parameter is more proper?
There was a problem hiding this comment.
It depends on the RecoveryPolicy that you have, maybe you need to add some comments for the DefaultRecovery.
|
|
||
| log.warn("Retrying sub tx failed, global tx id: {}, local tx id: {}, method: {}, remains: {}", | ||
| context.globalTxId(), context.localTxId(), method.toString(), remains); | ||
| Thread.sleep(compensable.retryDelayInMilliseconds()); |
There was a problem hiding this comment.
It may cause some performance issue by using Thread.sleep here.
we may need to consider to use scheduler for it.
There was a problem hiding this comment.
Scheduler requires to implement the Callable interface to retrieve the return value. However, we need to construct a new instance for every execution to pass the paramenters. The times of execution is also hard to control. I guess this also introduce performance penalty.
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| public class DefaultRecovery implements RecoveryPolicy { |
There was a problem hiding this comment.
Not exactly. As the compensation of backward recovery is handled asynchronously, this place is only used to execute bussiness logic once.
f627755 to
b8a1163
Compare
Signed-off-by: Eric Lee <dagang.li@huawei.com>
Signed-off-by: Eric Lee <eric.lee.ltk@gmail.com>
| + "t.type, t.compensationMethod, t.payloads " | ||
| + ") FROM TxEvent t " | ||
| + "WHERE t.globalTxId = ?1 AND t.type = ?2") | ||
| + "WHERE t.globalTxId = ?1 AND t.type = ?2 " |
There was a problem hiding this comment.
It's a litter bit complicated, as we have retry option, the retry failed event is not same with the abort event. It should be easy if we introduce retry failed event.
|
Merged the patch into master branch. |
Follow this checklist to help us incorporate your contribution quickly and easily:
[SCB-XXX] Fixes bug in ApproximateQuantiles, where you replaceSCB-XXXwith the appropriate JIRA issue.mvn clean installto make sure basic checks pass. A more thorough check will be performed on your pull request automatically.This PR is based on #117