Use truncated exponential backoff for reconnection #272
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.
When the communication with the Riemann server is connected (TCP/TLS) and the link breaks, riemann-wrapper drop the events that failed to be send, log a warning, and immediately try to reconnect and proceed with remaining data.
When the Riemann server is unreachable because of some network connectivity issue, this new connection will likely immediately fail, freshly gathered events will be dropped, a new warning will be logged, and a new connection will be tried immediately.
Because we do not wait before reconnecting, we log an unexpectedly large amount of information about dropped messages, and because of the delays introduced by the reconnection attempts, we might be sending stale data when the connection succeed again.
Rework the disconnection detection logic to apply some truncated exponential backoff when the connection dies. Sleep at least 0.5 and at most 30s between attempts, and drop any pending events before trying to reconnect.