Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add time limit when transaction retry on the server #824

Merged
merged 27 commits into from
May 21, 2019

Conversation

XCXCXCXCX
Copy link
Contributor

Ⅰ. Describe what this PR did

add time limit when transaction retry on the server
Provide configuration items in file.conf :
max.commit.retry.timeout=
max.rollback.retry.timeout=
default permanent.

The retry timeout period is determined by the user. If it is not configured or configured as a negative number, it will run permanently; if configured to 0, it will be removed from the retry list on the first detection.

Ⅱ. Does this pull request fix one issue?

Ⅲ. Why don't you add test cases (unit test/integration test)?

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

@codecov-io
Copy link

codecov-io commented Apr 18, 2019

Codecov Report

Merging #824 into develop will decrease coverage by 0.15%.
The diff coverage is 9.09%.

Impacted file tree graph

@@              Coverage Diff              @@
##             develop     #824      +/-   ##
=============================================
- Coverage       39.6%   39.44%   -0.16%     
  Complexity      1138     1138              
=============================================
  Files            221      222       +1     
  Lines           8828     8872      +44     
  Branches        1130     1143      +13     
=============================================
+ Hits            3496     3500       +4     
- Misses          4891     4931      +40     
  Partials         441      441
Impacted Files Coverage Δ Complexity Δ
...c/main/java/io/seata/common/util/DurationUtil.java 0% <0%> (ø) 0 <0> (?)
...o/seata/server/coordinator/DefaultCoordinator.java 31.79% <26.66%> (-0.49%) 14 <0> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4f2dd84...b7af7dd. Read the comment docs.

}
}

public static void main(String[] args) {
Copy link
Contributor

Choose a reason for hiding this comment

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

remove the main method?use test case。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK

@zhangthen
Copy link
Contributor

Plz add new config items to the nacos-config.txt too .

Copy link
Member

@xingfudeshi xingfudeshi left a comment

Choose a reason for hiding this comment

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

LGTM

@XCXCXCXCX
Copy link
Contributor Author

Plz add new config items to the nacos-config.txt too .

OK.

@zhangthen
Copy link
Contributor

zhangthen commented Apr 24, 2019

@XCXCXCXCX

I have a mind.

It shoud be retry all the time until the rollback get success, this is the guarantee of final-consistency(BASE).
Stopping retries after a certain number of times may result in transactions not being rollbacked, which is contrary to the final consistency(BASE).

So is it necessary for this PR ?
If the rollback is not necessary to be executed, then why do you need distributed transaction of Seata?

@slievrly
Copy link
Member

@XCXCXCXCX @zhangthen This requirement is what I proposed. The default should be a permanent retry. When a database downtime or a single-point application fails to start, you need to stop retrying.

@zhangthen
Copy link
Contributor

@XCXCXCXCX @zhangthen This requirement is what I proposed. The default should be a permanent retry. When a database downtime or a single-point application fails to start, you need to stop retrying.

If retry stop, how to make the transaction to be final consistency ?

@slievrly
Copy link
Member

@XCXCXCXCX @zhangthen This requirement is what I proposed. The default should be a permanent retry. When a database downtime or a single-point application fails to start, you need to stop retrying.

If retry stop, how to make the transaction to be final consistency ?

If the physical failure of the database hangs, it is known that it cannot be started, and how to ensure consistency.

@zhangthen
Copy link
Contributor

zhangthen commented Apr 24, 2019

@XCXCXCXCX @zhangthen This requirement is what I proposed. The default should be a permanent retry. When a database downtime or a single-point application fails to start, you need to stop retrying.

If retry stop, how to make the transaction to be final consistency ?

If the physical failure of the database hangs, it is known that it cannot be started, and how to ensure consistency.

If retry stop, how to make the transaction to be final consistency ?

I think it shoud allways retry, even if database down or application fails , unless there is a manual intervention to make the transaction to be final consistency, not stop retry automatically, must stop by manual-intervention.

In addition , without manual judgment, how to know the cause of failure, it is too hasty to stop retrying automatically after several failures.

@slievrly
Copy link
Member

@XCXCXCXCX @zhangthen This requirement is what I proposed. The default should be a permanent retry. When a database downtime or a single-point application fails to start, you need to stop retrying.

If retry stop, how to make the transaction to be final consistency ?

If the physical failure of the database hangs, it is known that it cannot be started, and how to ensure consistency.

If retry stop, how to make the transaction to be final consistency ?

I think it shoud allways retry, even if database down or application fails , unless there is a manual intervention to make the transaction to be final consistency, not stop retry automatically, must stop by manual-intervention.

In addition , without manual judgment, how to know the cause of failure, it is too hasty to stop retrying automatically after several failures.

This value defaults to permanent retry. When the user determines that this cannot be recovered because of a physical failure, the user can stop the retry by configuring this value.

@CoffeeLatte007
Copy link
Contributor

@XCXCXCXCX @zhangthen This requirement is what I proposed. The default should be a permanent retry. When a database downtime or a single-point application fails to start, you need to stop retrying.

If retry stop, how to make the transaction to be final consistency ?

If the physical failure of the database hangs, it is known that it cannot be started, and how to ensure consistency.

If retry stop, how to make the transaction to be final consistency ?
I think it shoud allways retry, even if database down or application fails , unless there is a manual intervention to make the transaction to be final consistency, not stop retry automatically, must stop by manual-intervention.
In addition , without manual judgment, how to know the cause of failure, it is too hasty to stop retrying automatically after several failures.

This value defaults to permanent retry. When the user determines that this cannot be recovered because of a physical failure, the user can stop the retry by configuring this value.

I have a suggest, the retry provides a configuration,it is up to the user to decide whether to retry permanently.
If not permanent try again, then we can modify the retry mechanism, don't use Java ScheduledThreadPoolExecutor, we can use the Time Wheel, using an Exponential Backoff way retry

@CoffeeLatte007
Copy link
Contributor

@XCXCXCXCX @zhangthen This requirement is what I proposed. The default should be a permanent retry. When a database downtime or a single-point application fails to start, you need to stop retrying.

If retry stop, how to make the transaction to be final consistency ?

If the physical failure of the database hangs, it is known that it cannot be started, and how to ensure consistency.

If retry stop, how to make the transaction to be final consistency ?
I think it shoud allways retry, even if database down or application fails , unless there is a manual intervention to make the transaction to be final consistency, not stop retry automatically, must stop by manual-intervention.
In addition , without manual judgment, how to know the cause of failure, it is too hasty to stop retrying automatically after several failures.

This value defaults to permanent retry. When the user determines that this cannot be recovered because of a physical failure, the user can stop the retry by configuring this value.

I have a suggest, the retry provides a configuration,it is up to the user to decide whether to retry permanently.
If not permanent try again, then we can modify the retry mechanism, don't use Java ScheduledThreadPoolExecutor, we can use the Time Wheel, using an Exponential Backoff way retry

@zhangthen
Copy link
Contributor

@XCXCXCXCX @zhangthen This requirement is what I proposed. The default should be a permanent retry. When a database downtime or a single-point application fails to start, you need to stop retrying.

If retry stop, how to make the transaction to be final consistency ?

If the physical failure of the database hangs, it is known that it cannot be started, and how to ensure consistency.

If retry stop, how to make the transaction to be final consistency ?
I think it shoud allways retry, even if database down or application fails , unless there is a manual intervention to make the transaction to be final consistency, not stop retry automatically, must stop by manual-intervention.
In addition , without manual judgment, how to know the cause of failure, it is too hasty to stop retrying automatically after several failures.

This value defaults to permanent retry. When the user determines that this cannot be recovered because of a physical failure, the user can stop the retry by configuring this value.

I have a suggest, the retry provides a configuration,it is up to the user to decide whether to retry permanently.
If not permanent try again, then we can modify the retry mechanism, don't use Java ScheduledThreadPoolExecutor, we can use the Time Wheel, using an Exponential Backoff way retry

I think this implementation is too simple, will affect the rollback of all transactions;
The retry can not stop (unless stopped manually), which is the basic guarantee for the final consistency.
If too many failures, the retry frequency can be reduced appropriately.

@XCXCXCXCX
Copy link
Contributor Author

@zhangthen @slievrly
So I think we can stop its retry through a management entry. When the user determines that a transaction cannot be recovered due to a physical failure, it can be marked with a new failure status (eg. CANCEL) and removed from the retrying list.
In addition, it is better to use Time Wheel for situations where there may be a lot of retry tasks.
@CoffeeLatte007

@zhangthen
Copy link
Contributor

@zhangthen @slievrly
So I think we can stop its retry through a management entry. When the user determines that a transaction cannot be recovered due to a physical failure, it can be marked with a new failure status (eg. CANCEL) and removed from the retrying list.
In addition, it is better to use Time Wheel for situations where there may be a lot of retry tasks.
@CoffeeLatte007

I agree this solution.

@CoffeeLatte007
Copy link
Contributor

@zhangthen @slievrly
So I think we can stop its retry through a management entry. When the user determines that a transaction cannot be recovered due to a physical failure, it can be marked with a new failure status (eg. CANCEL) and removed from the retrying list.
In addition, it is better to use Time Wheel for situations where there may be a lot of retry tasks.
@CoffeeLatte007

yes, i think use time wheel and Exponential Backoff is better for retry

@slievrly
Copy link
Member

@zhangthen Currently configured for permanent retry, this modification entry is reserved for higher-order users. After the webconsole is perfected, the console UI needs to join the manual stop retry button.

Copy link
Contributor

@CoffeeLatte007 CoffeeLatte007 left a comment

Choose a reason for hiding this comment

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

LGTM

@xingfudeshi xingfudeshi requested review from slievrly and leizhiyuan and removed request for slievrly May 19, 2019 05:57
Copy link
Contributor

@leizhiyuan leizhiyuan left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@slievrly slievrly left a comment

Choose a reason for hiding this comment

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

LGTM

@leizhiyuan leizhiyuan merged commit 415e5c8 into apache:develop May 21, 2019
@leizhiyuan leizhiyuan added this to the 0.6.0 milestone May 21, 2019
nick-tan pushed a commit to nick-tan/seata that referenced this pull request Jul 12, 2019
* add: add time limit when transaction retry on the server

* fix: change int to long

* add: Configuration api add getDuration()

* add: copyright

* fix: use test case instead main

* add new config items to the nacos-config.txt

* fix

* parse -1 and default Duration.ofMillis(-1)

* add comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants