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

tornado: Fix race condition on handler._request #22220

Merged
merged 2 commits into from
Jun 9, 2022

Conversation

andersk
Copy link
Member

@andersk andersk commented Jun 8, 2022

Commit 6fd1a55 (#21469) introduced an await point where get_events_backend calls fetch_events in order to switch threads. This opened the possibility that, in the window between the connect_handler call in fetch_events and the old location of this assignment in get_events_backend, an event could arrive, causing ClientDescriptor.add_event to crash on missing handler._request. Fix this by assigning handler._request earlier.

I found this by trying to improve #22058 (cc @asah) to avoid relying on a fixed timeout. So this improved test now also serves as a test case for this race condition.

Commit 6fd1a55 (zulip#21469) introduced an
await point where get_events_backend calls fetch_events in order to
switch threads.  This opened the possibility that, in the window
between the connect_handler call in fetch_events and the old location
of this assignment in get_events_backend, an event could arrive,
causing ClientDescriptor.add_event to crash on missing
handler._request.  Fix this by assigning handler._request earlier.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
The 0.1 second delay was sometimes not long enough to guarantee we hit
the async response path, resulting in a nondeterministic coverage
failure.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
@timabbott timabbott merged commit 0430705 into zulip:main Jun 9, 2022
@timabbott
Copy link
Sponsor Member

Merged, thanks @andersk!

@andersk andersk deleted the tornado-race branch June 25, 2022 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants