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

Fix race condition causing unexpected idle disconnections #846

Merged
merged 1 commit into from
Jul 18, 2023
Merged

Fix race condition causing unexpected idle disconnections #846

merged 1 commit into from
Jul 18, 2023

Conversation

nyckyta
Copy link
Contributor

@nyckyta nyckyta commented Jul 5, 2023

This issue may appear when 'send[data]' methods are triggered from different threads. As a result threads race appears between cancelIdleTimeoutExecutor and scheduling new idle task. Example of race:

  1. Thread 1 cancels task
  2. Thread 2 waits until thread 1 will finish
  3. Thread 1 finishes
  4. Thread 2 tries to cancel already cancelled task and leaves synchronized block
  5. Thread 1 schedules new idle task
  6. Thread 2 schedules another idle task, the first is overwritten and never cancelled. As a result disconnection is triggered precisely after set idle timeout passes.

I would appreciate if this fix will be added to the version responsible for Java 1.x implementation, since this is one we still use in our internal project.

This issue may appear when 'send[data]' methods are triggered from different threads. As a result
threads race appears between cancelIdleTimeoutExecutor and scheduling new idle task.
Example of race:
1. Thread 1 cancels task
2. Thread 2 waits until thread 1 will finish
3. Thread 1 finishes
4. Thread 2 tries to cancel already cancelled task and leaves synchronized block
5. Thread 1 schedules new idle task
6. Thread 2 schedules another idle task, the first is overwritten and never cancelled.
As a result disconnection is triggered precisely after set idle timeout passes.

Signed-off-by: Mykyta Leonov <[email protected]>
@nyckyta
Copy link
Contributor Author

nyckyta commented Jul 12, 2023

@jansupol Should I do something additionaly to request review? There is no hurry, but I just want to make sure that this PR won't stuck here for unknown reason.

Copy link
Contributor

@jansupol jansupol left a comment

Choose a reason for hiding this comment

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

Nice catch, thanks!

@jansupol jansupol merged commit 0a1d33f into eclipse-ee4j:master Jul 18, 2023
@jansupol jansupol added this to the 1.21 milestone Oct 18, 2023
@nyckyta
Copy link
Contributor Author

nyckyta commented Oct 18, 2023

@rok-povsic FYI, when this is released, dev build version must be replaced by the release (1.21). (Unless something has changed of course).

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.

2 participants