Skip to content
This repository was archived by the owner on Oct 13, 2024. It is now read-only.

SCB-224 retry sub-transaction on failure#138

Merged
WillemJiang merged 7 commits intoapache:masterfrom
eric-lee-ltk:SCB-224
Apr 28, 2018
Merged

SCB-224 retry sub-transaction on failure#138
WillemJiang merged 7 commits intoapache:masterfrom
eric-lee-ltk:SCB-224

Conversation

@eric-lee-ltk
Copy link
Copy Markdown
Contributor

@eric-lee-ltk eric-lee-ltk commented Feb 24, 2018

Follow this checklist to help us incorporate your contribution quickly and easily:

  • Make sure there is a JIRA issue filed for the change (usually before you start working on it). Trivial changes like typos do not require a JIRA issue. Your pull request should address just this issue, without pulling in other changes.
  • Each commit in the pull request should have a meaningful subject line and body.
  • Format the pull request title like [SCB-XXX] Fixes bug in ApproximateQuantiles, where you replace SCB-XXX with the appropriate JIRA issue.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Run mvn clean install to make sure basic checks pass. A more thorough check will be performed on your pull request automatically.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

This PR is based on #117

@WillemJiang
Copy link
Copy Markdown
Member

@eric-lee-ltk There are some build error in you commit, could you take a look at it?

@eric-lee-ltk eric-lee-ltk force-pushed the SCB-224 branch 2 times, most recently from 3d748fd to c26feb1 Compare February 27, 2018 09:46
@coveralls
Copy link
Copy Markdown

coveralls commented Feb 27, 2018

Coverage Status

Coverage increased (+0.3%) to 95.361% when pulling 436296b on eric-lee-ltk:SCB-224 into aff2719 on apache:master.

@eric-lee-ltk eric-lee-ltk force-pushed the SCB-224 branch 3 times, most recently from f516204 to c1d96b2 Compare March 12, 2018 12:03
aspect.advise(joinPoint, compensable);
try {
aspect.advise(joinPoint, compensable);
} catch (Exception e) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's common practice to use upper case for the static constant.


private static final RecoveryPolicy forwardRecovery = new ForwardRecovery();

static RecoveryPolicy getRecoveryPolicy(int retries) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can you decide the RecoveryPolicy by using the retries parameter.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which parameter is more proper?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may cause some performance issue by using Thread.sleep here.
we may need to consider to use scheduler for it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it a backward recovery?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not exactly. As the compensation of backward recovery is handled asynchronously, this place is only used to execute bussiness logic once.

@eric-lee-ltk eric-lee-ltk changed the title [WIP] SCB-224 retry sub-transaction on failure SCB-224 retry sub-transaction on failure Apr 17, 2018
@eric-lee-ltk eric-lee-ltk force-pushed the SCB-224 branch 3 times, most recently from f627755 to b8a1163 Compare April 17, 2018 10:07
eric-lee-ltk and others added 2 commits April 24, 2018 16:18
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 "
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@WillemJiang WillemJiang merged commit ce71ab7 into apache:master Apr 28, 2018
@WillemJiang
Copy link
Copy Markdown
Member

Merged the patch into master branch.

@eric-lee-ltk eric-lee-ltk deleted the SCB-224 branch April 28, 2018 09:35
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants