package.elm-lang.org icon indicating copy to clipboard operation
package.elm-lang.org copied to clipboard

Data loss on reboot if two packages were ever published the same second

Open drathier opened this issue 5 years ago • 0 comments
trafficstars

Problem sequence

  1. Two packages are published the same second.
  2. Timestamps get floored to a one-second resolution in Releases.hs:
encode :: [Release] -> Encode.Value
encode releases =
  Encode.object $ flip map (List.sort releases) $ \(Release version time) ->
    ( Pkg.versionToText version, Encode.int (floor time) )
  1. The server reboots and loads History.History from disk, sorting Events by time by putting package versions into this dict:
type TimeDict =
  Map.Map Time.NominalDiffTime (Pkg.Name, Pkg.Version)

which will drop packages with the same Time.NominalDiffTime.

Suggested fix:

Don't floor timestamps. We probably won't see two packages published the same 10^-12 s timestamp.

drathier avatar Jan 18 '20 08:01 drathier