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(subscriber): bail rather than panic when encountering clock skew #287

Merged
merged 1 commit into from
Feb 17, 2022

Conversation

hawkw
Copy link
Member

@hawkw hawkw commented Feb 17, 2022

Motivation

Currently, if compiled in debug mode, the console-subscriber crate's
PollStats::end_poll function will panic if a poll duration is negative
(i.e. if the poll's end
timestamp occurred before its start timestamp). Because the console
currently uses non-monotonic SystemTimes rather than monotonic
Instants (due to serialization requirements), this means we are
potentially succeptible to clock skew adjustments. If one occurs during
a poll, and the system clock goes backwards, we may panic here. This
isn't great!

Solution

This branch fixes the panic by removing the assertions, and changing
end_poll to simply bail and print a warning rather than panicking when
encountering a negative poll duration. This is a short-term solution; a
better long-term solution would be to change console-subscriber to use
monotonic Instants rather than non-monotonic SystemTimes (as
discussed here and here).

Fixes #286

## Motivation

Currently, if compiled in debug mode, the `console-subscriber` crate's
`PollStats::end_poll` function will panic if a poll duration is negative
(i.e. if the poll's end
timestamp occurred before its start timestamp). Because the console
currently uses non-monotonic `SystemTime`s rather than monotonic
`Instant`s (due to serialization requirements), this means we are
potentially succeptible to clock skew adjustments. If one occurs during
a poll, and the system clock goes backwards, we may panic here. This
isn't great!

## Solution

This branch fixes the panic by removing the assertions, and changing
`end_poll` to simply bail and print a warning rather than panicking when
encountering a negative poll duration. This is a short-term solution; a
better long-term solution would be to change `console-subscriber` to use
monotonic `Instant`s rather than non-monotonic `SystemTime`s (as
discussed [here][1] and [here][2]).

Fixes #286

[1]:#254
[2]: #286 (comment)
@hawkw hawkw merged commit 24db8c6 into main Feb 17, 2022
@hawkw hawkw deleted the eliza/no-timestamp-panics branch February 17, 2022 18:01
hawkw added a commit that referenced this pull request Feb 18, 2022
## 0.1.3  (2022-02-18)

#### Bug Fixes

*  record timestamps for updates last (#289) ([703f1aa](703f1aa),
   closes [#266](266))
*  use monotonic `Instant`s for all timestamps (#288)
   ([abc0830](abc0830), closes [#286](286))
*  bail rather than panic when encountering clock skew (#287)
   ([24db8c6](24db8c6), closes [#286](286))
*  fix compilation on targets without 64-bit atomics (#282)
   ([5590fdb](5590fdb), closes [#279](279))
hawkw added a commit that referenced this pull request Feb 18, 2022
#### Features

*  add `Builder::filter_env_var` builder parameter (#276)
   ([dbdb149](dbdb149), closes [#206](206))

#### Bug Fixes

*  record timestamps for updates last (#289) ([703f1aa](703f1aa),
   closes [#266](266))
*  use monotonic `Instant`s for all timestamps (#288)
   ([abc0830](abc0830), closes [#286](286))
*  bail rather than panic when encountering clock skew (#287)
   ([24db8c6](24db8c6), closes [#286](286))
*  fix compilation on targets without 64-bit atomics (#282)
   ([5590fdb](5590fdb), closes [#279](279))
hawkw added a commit that referenced this pull request Feb 18, 2022
#### Features

*  add `Builder::filter_env_var` builder parameter (#276)
   ([dbdb149](dbdb149), closes [#206](206))

#### Bug Fixes

*  record timestamps for updates last (#289) ([703f1aa](703f1aa),
   closes [#266](266))
*  use monotonic `Instant`s for all timestamps (#288)
   ([abc0830](abc0830), closes [#286](286))
*  bail rather than panic when encountering clock skew (#287)
   ([24db8c6](24db8c6), closes [#286](286))
*  fix compilation on targets without 64-bit atomics (#282)
   ([5590fdb](5590fdb), closes [#279](279))
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.

the current poll must have started before it ended
2 participants