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

make LazyFaultTolerance lock-free #1034

Closed
wants to merge 1 commit into from
Closed

Conversation

mariofusco
Copy link
Contributor

This pull request is intended to fix the issue reported here quarkusio/quarkus#41314

Its main drawback is in the fact that with this change multiple threads could concurrently call two or more times the FaultTolerance builder. I don't know how heavy that invocation actually is, but in case you think that this is not acceptable, the other alternative that I see is replacing that synchronized block with a ReentrantLock. Please advice on which of the 2 solutions you prefer.

@@ -36,15 +37,13 @@ public void run(Runnable action) {
}

private FaultTolerance<T> instance() {
FaultTolerance<T> instance = this.instance;
FaultTolerance<T> instance = this.instance.get();
Copy link

@franz1981 franz1981 Jul 12, 2024

Choose a reason for hiding this comment

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

this is making builder.get() to be called more than once, changing the expected behaviour for users.
Using ReentrantLock(s) is preferrable here - or use a 2 state lock-free behaviour instead

@Ladicek
Copy link
Contributor

Ladicek commented Jul 12, 2024

The problem isn't in how heavy the FT builder is, it's in how it creates certain resources; notably, the registration with the circuit breaker maintenance must be done exactly once (subsequent invocations end up with an error IIRC). So a ReentrantLock would be preferred.

Thanks for working on this BTW, I totally missed that Quarkus issue!

@mariofusco
Copy link
Contributor Author

Replace by #1035

@mariofusco mariofusco closed this Jul 12, 2024
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.

3 participants