Skip to content

Conversation

colinangusmackay
Copy link
Member

@colinangusmackay colinangusmackay commented Feb 23, 2025

Fix timestamps in the LogEntry

Issue

This PR addresses Issue #190.

In rare cases when many logs are created in multiple threads the timestamps and Sequence numbers can become out of order. Each should only ever increase, and ordering a set of log entries by sequence should produce the same sequence as ordering by timestamp.

This fix, ensures that timestamps are only ever increasing. The resolution of the DateTime.UtcNow function is system dependent, so can be between 0.5ms to 15ms, or 5000 to 150,000 ticks (at 10,000 ticks per millisecond). So, in some scenarios, multiple log entries can be created before the DateTime.UtcNow method produces a new value. In this event a new DateTime is produces that increments the Ticks by 1 to ensure that the value is distinct from the preceding log entry.

Check list

Required

  • I have updated release-notes/wip-release-notes.md file
  • I have addressed style warnings given by Visual Studio/ReSharper/Rider
  • I have checked that all tests pass.

Optional

  • I have updated the repo readme.md file.
  • I have updated the package readme.md file.
  • I have updated the documentation in the docs folder.
  • I have bumped the version number in the version.txt.
  • I have added or updated any necessary tests.
  • I have ensured that any new code is covered by tests where reasonably possible.

@colinangusmackay colinangusmackay linked an issue Feb 23, 2025 that may be closed by this pull request
@colinangusmackay colinangusmackay merged commit 1725606 into main Feb 23, 2025
3 checks passed
@colinangusmackay colinangusmackay deleted the #190/multi-threaded-bug branch February 23, 2025 22:44
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.

Timestamp occasionally out-of-sequence

1 participant