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

Address ConcurrentModificationException on ThreadLocalPool #14511

Conversation

nachogiljaldo
Copy link
Contributor

Fixes #14510

I tried to keep the solution super-simple since I saw this code might go away real soon, I added a test that reproduces.

IMHO, there should be a 1.11.1 with this change, this seems like a deal breaker for users in that version (I had to move back to 1.10.5.FINAL for example).

@@ -72,7 +72,7 @@ PoolType pool() {
}

private final void scanForAbandonedConnections() {
for (PoolAndThread pair : allConnections) {
for (PoolAndThread pair : new ArrayList<>(allConnections)) {
Copy link
Contributor

@gastaldi gastaldi Jan 22, 2021

Choose a reason for hiding this comment

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

I think this may still run into ConcurrentModificationException (when copying to the other list).

A proper solution is to replace the ArrayList instance used in allConnections with a CopyOnWriteArrayList

Copy link
Member

Choose a reason for hiding this comment

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

I agree - just pushed a small additional commit.

Copy link
Member

Choose a reason for hiding this comment

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

(I used a slightly different approach as I actually did it before seeing your suggestion)

Copy link
Member

Choose a reason for hiding this comment

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

And it's actually still not 100% right..

Copy link
Member

Choose a reason for hiding this comment

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

Nevermind, should be correct as all accesses to this method are exclusive because of the synchronization pattern.

Copy link
Member

@Sanne Sanne left a comment

Choose a reason for hiding this comment

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

Approved, just need another CI run.

@Sanne Sanne added triage/waiting-for-ci Ready to merge when CI successfully finishes area/reactive area/persistence labels Jan 22, 2021
@Sanne Sanne added this to the 1.12 - master milestone Jan 22, 2021
@@ -72,13 +72,19 @@ PoolType pool() {
}

private final void scanForAbandonedConnections() {
ArrayList<PoolAndThread> garbage = new ArrayList<>();
for (PoolAndThread pair : allConnections) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This iteration may still fail if the allConnections list changes

Copy link
Member

Choose a reason for hiding this comment

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

it's locked, it's not going to change at this time.

@Sanne
Copy link
Member

Sanne commented Jan 23, 2021

only a JDK8/JVM test failed, and it was:

[ERROR] Errors: 
[ERROR]   ScalaDevModeIT.testThatTheApplicationIsReloadedOnScalaChange:23->RunAndCheckMojoTestBase.runAndCheck:63->RunAndCheckMojoTestBase.runAndCheck:70 » ConditionTimeout

That's not related, so let's merge this one.

@Sanne
Copy link
Member

Sanne commented Jan 23, 2021

Many thanks @nachogiljaldo !

@Sanne Sanne merged commit 70e1c9a into quarkusio:master Jan 23, 2021
@gsmet gsmet modified the milestones: 1.12 - master, 1.11.1.Final Jan 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/persistence area/reactive triage/waiting-for-ci Ready to merge when CI successfully finishes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ConcurrentModificationException thrown when closing a connection on a reactive pool
4 participants