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

[SCB-962] Support ForwardPolicy to configure the maximum of retries#322

Merged
zhfeng merged 1 commit intoapache:masterfrom
KomachiSion:SCB-962
Oct 25, 2018
Merged

[SCB-962] Support ForwardPolicy to configure the maximum of retries#322
zhfeng merged 1 commit intoapache:masterfrom
KomachiSion:SCB-962

Conversation

@KomachiSion
Copy link
Member

Support ForwardPolicy to configure the maximum of retries

- compensation - user-defined compensation that executed by the Saga.
- method - user-defined, HTTP method.
- path - user-defined, HTTP path.
- retries - int, optional, default 3. The max retry times for compensation.
Copy link
Member

Choose a reason for hiding this comment

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

Does it support -1 setting?

Copy link
Member Author

Choose a reason for hiding this comment

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

When compensation set retries less than or equal to 0, it will be set default value.
This is the logic that was there, I have not changed it.

}
throw new TransactionAbortedException(
String.format(
"Too many failures in transaction %s of service %s, stop transaction!",
Copy link
Member

Choose a reason for hiding this comment

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

How about using "abort the transaction"?


@Override
public int retries() {
return 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

why it return 0 here ? it means to retry infinite ?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, Fallback does not retry currently.
Because I abstracted the retires method from Compensation to Operation, Fallback needs to implement this method temporarily.
Considering the default number of retries if Fallback needs to retry in the future.

}

private boolean isRetryable(int i, Transaction transaction) {
return transaction.retries() == Transaction.INFINITE_RETRY || i <= transaction.retries();
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it could be an issue here. if the transaction.retries() is 0, it just run sout of the loop and has no retry at all. But you mention in the document

If this parameter is less than or equal to 0, transaction will retry infinitely.

Copy link
Member Author

Choose a reason for hiding this comment

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

When Transaction is generated from Json and retries is 0, retires will be set to Transaction.INFINITE_RETRY.
The correlation can be viewed from JacksonSQLTransaction or JacksonRestTransaction.
Of course, the problem you said does exist, I fix it right now.

Copy link
Contributor

@zhfeng zhfeng Oct 23, 2018

Choose a reason for hiding this comment

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

Thanks @KomachiSion , as i starts from 0

for(int i = 0; isRetryable(i, request.transaction()); i++)

it looks like the condition should be i < transcaction.retries() ?

@zhfeng
Copy link
Contributor

zhfeng commented Oct 23, 2018

@KomachiSion Thanks for your contribution and can you check the travis-ci message at first. We have to make sure the all the tests pass.

@coveralls
Copy link

coveralls commented Oct 23, 2018

Coverage Status

Coverage increased (+0.07%) to 91.805% when pulling f5c8682 on KomachiSion:SCB-962 into 181a7bd on apache:master.

@zhfeng
Copy link
Contributor

zhfeng commented Oct 23, 2018

@KomachiSion How to config the retries parameter globally as we discussed in the mailing list ? I think it could be possible to make the DEFAULT_RETRIES configurable ? Also can you squash these changes to one commit ?

@KomachiSion
Copy link
Member Author

I think it may not be reasonable to configure retries parameter globally. Because the retry features of transaction, compensation, and fallback may be inconsistent. If you need to configure global retries parameter, it may not be compatible with multiple cases.

About squashing commit, I execute as soon as possible.

SCB-962 ForwardRecovery support the maximum of retries.

SCB-962 Add ForwardRecovery retry unit case.

SCB-962 Implement retries in Transcation unit case.

SCB-962 Implement retries for Rest and SQL Transaction.

SCB-962 Abstract retries to Operation.

SCB-962 Implement retries for Rest and SQL Operation.

SCB-962 Move retries from transaction/compensation to operation.

SCB-962 Abort transaction while reaching the max of retries.

SCB-962 Update api docs for retries

SCB-962 Catch and throw Aborted exception in consumer

SCB-962 Add unit case for maximum retries

SCB-962 Fix default value of transaction retries

SCB-962 Change description when transaction aborted

SCB-962 Fix transaction does not retry when transaction.retires = 0
@zhfeng
Copy link
Contributor

zhfeng commented Oct 24, 2018

Thanks @KomachiSion and it looks good to me. @WillemJiang do you have any input here ?

@zhfeng zhfeng merged commit 1e7d762 into apache:master Oct 25, 2018
@zhfeng
Copy link
Contributor

zhfeng commented Oct 25, 2018

@KomachiSion Thanks for your contribution !

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants