Skip to content

Handle Clock Drift cases #9

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

Merged
merged 7 commits into from
Jun 2, 2025
Merged

Handle Clock Drift cases #9

merged 7 commits into from
Jun 2, 2025

Conversation

Nyvil
Copy link
Contributor

@Nyvil Nyvil commented Jun 2, 2025

as per discord discussion with Krypton.

TLDR:

  • add lastTimestamp uint64 to worker. If milliseconds < w.lastTimestamp, a clock drift (VM suspension, NTP revert...) happened and it'll wait for the time to catch up before generating the next ID.

@Nyvil
Copy link
Contributor Author

Nyvil commented Jun 2, 2025

also threw out the base epoch change test cuz it's suboptimal (baseepoch should never be allowed to change to begin with, absolute time (sf.Time()) is always dependant on the BaseEpoch, and two different base epochs by definition mean different ids, which is what u want

@kkrypt0nn kkrypt0nn self-assigned this Jun 2, 2025
@kkrypt0nn kkrypt0nn added the enhancement New feature or request label Jun 2, 2025
Copy link
Owner

@kkrypt0nn kkrypt0nn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@kkrypt0nn kkrypt0nn merged commit 6cd2e7e into kkrypt0nn:main Jun 2, 2025
8 checks passed
@Nyvil Nyvil deleted the clockdrift branch June 2, 2025 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants