Repository navigation
Keep the audit log in the order events happened when the clock steps back - #290
Merged
Merged
Conversation
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.
The audit log lists events newest first by
created_at, then by ID.created_atcame from one read of the wall clock, and the UUIDv7 ID from a second read. When the clock steps back, as WSL's does by whole seconds under load (and as NTP can on a real server), later events got earlier times and the log came back out of order.That was the cause of two flaky server tests:
reports::reports_need_their_permissions_and_are_auditedalerts::channels_email_users_and_roles_and_test_webhooksIn one failing run, three events were stamped 14 s before the event that came ahead of them, though their IDs were still in order.
The fix:
audit::recordnow uses the time inside the event's ID as itscreated_at. The uuid crate keeps a process's v7 IDs increasing even when the clock goes back, so time and ID now agree and the order holds.Testing
applicationsfile timed out opening SQLite once while the machine was stalled on disk, and passed on rerun.-D warningsand fmt are clean.