fix dup log race condition on shutdown#40
Merged
JeffreyLMelvin merged 2 commits intozach-taylor:masterfrom Oct 9, 2020
Merged
Conversation
Collaborator
Author
|
Ok, I will merge and cut a release |
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.
Problem
wait_until_emptyallows the code to wait until the queue has been emptied. However, there is still a race condition between the response from the Splunk server and the execution of shutdown.Instance
shutdown()calls_splunk_worker(), which will callempty_queue(). If the connection to splunk is still open from the Timer call that emptied the queue, the Timer thread will not have yet clearedself.log_payload, which can result in the shutdown resending the payload, becauseempty_queue()only appends toself.log_payload.Solution
There are multiple options:
_splunk_worker()check the queue size. This was not done as it doesnt align with the option to send a payload as an arg to the functionshutdown()send the payload in the_splunk_worker()call.self.log_payloadas soon as it is read instead of after it is received by splunk. The payload is thrown away regardless of error already, so this seemed like the best option.Additionally removed the
flush_intervaladjustment made inwait_until_empty()as the timer is already adjusted in_splunk_worker()when there is content in the queue after completing a call to splunk@zach-taylor