PYTHON-644#686
Closed
mambocab wants to merge 2 commits into
Closed
Conversation
This does not eliminate, but it shrinks, the window for the race condition that caused PYTHON-644. In this race, _set_result could be called from the event loop before send_request calls _start_timer. The goal of the _CANCELLED sentinel is to allow permanent cancelling of all future timers for a given ResponseFuture. Unfortunately, there's still a race -- if _timer is cancelled during _start_timer.
Contributor
Author
|
Closing this PR for now, while I investigate a lockless solution that Adam suggested. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change adds a sentinel to indicate when a
ResponseFuture's timer has been cancelled. This is similar to #685, but also uses a lock to eliminate race conditions. For instance, the lock prevents this series of events:_on_speculative_executeon thread 1_set_final_resultcancels the timer on thread 2_on_speculative_executestarts a new timer on thread 1With these changes, I have not produced memory leaks with the script provided in PYTHON-644 when running it locally many times.
@aholmberg and I both suspect that there's a better solution than explicit locking, but I haven't figured it out yet.