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

Allow blocking calls in WorkerTask#dispose #3213

Merged
merged 1 commit into from Oct 6, 2022

Conversation

nathankooij
Copy link
Contributor

This avoids flagging (short-lived) blocking calls that cannot always be avoided when a dispose call results in the removal of a task of the worker-backed queue when access to said queue is currently held by a guard.

Fixes #3210.

This avoids flagging (short-lived) blocking calls that cannot always be
avoided when a `dispose` call results in the removal of a task of the
worker-backed queue when access to said queue is currently held by a guard.

Fixes reactor#3210.
@nathankooij nathankooij requested a review from a team as a code owner October 4, 2022 09:37
@@ -74,26 +74,50 @@ public void shouldDetectBlockingCallsInOperators() {
}

@Test
public void shouldNotReportScheduledFutureTask() {
for (int i = 0; i < 1_000; i++) {
public void shouldNotReportSchedulerScheduledFutureTask() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've adopted this test with learnings from writing the test below.

}
finally {
taskScheduler.dispose();
}
}
}

@Test
public void shouldNotReportWorkerScheduledFutureTask() {
for (int i = 0; i < 10_000; i++) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

On my local machine 10_000 was reliable in producing the exception -- 1_000 not so much. Let me know if this is acceptable.

Copy link
Contributor

Choose a reason for hiding this comment

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

it does not have to be the same for CI env since it increases the general run time. Thus, let's keep it as it was before.

Copy link
Member

Choose a reason for hiding this comment

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

As a follow up to this comment, I created #3216 which would create an opportunity to use a more heavy crunching when run locally and do a quicker run-through via CI.

};

for (int j = 0; j < 257; j++) {
worker.schedule(dummyRunnable, j + 1, TimeUnit.MILLISECONDS);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since the race was between dispose (and consequently, queue#remove) and the queue picking up another task, I found that having alternate scheduling increased the likelihood of hitting the issue.

}
Disposable disposable = worker.schedule(dummyRunnable, 1, TimeUnit.SECONDS);

RaceTestUtils.race(Schedulers.parallel(), disposable::dispose);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

RaceTestUtils#race was refactored at some point to default to the bounded elastic scheduler on which blocking is "allowed", making the above test previously moot.

I use the RaceTestUtils even though we're not racing anymore as it's convenient for grabbing/throwing the exceptions.

Copy link
Member

@chemicL chemicL left a comment

Choose a reason for hiding this comment

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

LGTM!

@chemicL chemicL merged commit d9fae3a into reactor:3.4.x Oct 6, 2022
@reactorbot
Copy link

@chemicL this PR seems to have been merged on a maintenance branch, please ensure the change is merge-forwarded to intermediate maintenance branches and up to main 🙇

chemicL added a commit that referenced this pull request Oct 6, 2022
Copy link
Contributor

@OlegDokuka OlegDokuka left a comment

Choose a reason for hiding this comment

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

LGTM with minor comments

}
finally {
taskScheduler.dispose();
}
}
}

@Test
public void shouldNotReportWorkerScheduledFutureTask() {
for (int i = 0; i < 10_000; i++) {
Copy link
Contributor

Choose a reason for hiding this comment

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

it does not have to be the same for CI env since it increases the general run time. Thus, let's keep it as it was before.

@chemicL chemicL added the type/bug A general bug label Oct 11, 2022
@OlegDokuka OlegDokuka added this to the 3.4.24 milestone Nov 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug A general bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants