[WIP] Various improvements and bugfixes #7
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "gitlab-mr-iid-2"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
os:system_timeinstead oferlang:system_time(fixes pleroma/pleroma#1681)Workerto a dedicated moduleBuilderBTW I think that once this MR is merged we should release a 1.0, as it's now feature complete and the API won't change.
A couple of typos. Thanks for the work!
Should we return
{:ok, flake}instead of just the flake ? In some cases it could return{:error, ...}. However this will just happen with time being crazy, and will probably crash up the caller later when they do expected a string.If you think that returning
{:error, …}is a normal value while operating under normal circumstances, then yes I recommend using{:ok, flakeId}as the return value.If it is because "Time has gone crazy" and "our dimension is falling appart", I recommend raising an runtime exception and making peace with your Creator.
Yes but it can be transient. The clock may go back in the past for a while (like pleroma/pleroma#1681 where the time isn't set correctly when Pleroma starts), but it can be set correctly later. A crash/runtime exception there would make the pleroma service failing (either by refusing to start the flake worker entierly, or by hitting the restart limit from others), while it can resume its work once the clock is set correctly.
Then tuples are the correct way to return a value, if error handling at the library consumer-level makes sense. :)
I think so too. This would require an API change. But since it's at 0.1.0 and we're planning 1.0, it's ok, I think.
Also worth noticing for discussion, in pleroma/pleroma#1681, @feld mentioned using
+C multi_time_warp. While it is nice, I'd tend against it (and using os:system_time) because: flakes are made to reflect time. The real, human time. Using a time wrap makes it a logical time; and this would require users to set the vm.args properly. On an OTP release well made it's not really an issue, but on dev/home-compiled envs, it is one. We don't want our ids to be possibly wrong because of a small +C issue. Wrap is definitely useful when you have to deal with logical time-- but flakes time isn't one.Yeah, huge +1 for returning tuples if it can fail and I'd rather see the API break now to have this than much later on when we're forced to.
Wouldn't that break things during daylight saving time changes, when the clock goes backwards?
It is unix epoch, so UTC/GMT+0, and theres no daylight here
ah, i get it now. these time options confuse me :)
aaaahhhhh but.
But it's probably really an issue either-- if the clock get stuck for a second, we could still generate up to 65536 flakes in that period (the sequence) until it will refuse to generate more (the sequence is 16bit). A worker ips is around ~64k at full speed in a second.
"Repeats the last second" is a bit worrying, not sure I understand it right: would it go backwards like 30 -> 29 or 30 -> 30 ?
maybe we need something like https://erlang.org/doc/man/erlang.html#monotonic_time-0
yeah, that could work, but that would break the fact that flakes are human time based, and sorted on human time: it's a logical clock. We won't be able to match a flake to a point in time. "since some unspecified point in time", "Different runtime system instances will use different unspecified points in time as base for their Erlang monotonic clocks"; "it is pointless comparing monotonic times from different runtime system instances".
oof
Apparently POSIX CLOCK_MONOTONIC cannot go backwards-- but I'm not sure if Erlang is using this one. i'll continue digging
so huh basically time is so fucked up! to not fuck up with leap seconds etc, it'll definitely need the multi time warp mode to be enabled. Added a warning at flake's startup if it's not enabled.
{:ok, flake} | {:error, _}. ef9f2ae2afFlakeId, doc warp and hint 1536170bfaView command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.