unisonweb / unison

A friendly programming language from the future
https://unison-lang.org
Other
5.81k stars 271 forks source link

Database Integrity Error on update #2786

Closed ChrisPenner closed 2 years ago

ChrisPenner commented 2 years ago

Paul provided the following transcript:

```ucm
.> pull https://github.com/pchiusano/unisoncode:#sfd4vt59vm code
.> cd code._distributed.channels 
```
```unison
Channels.receiveUntil : (b -> a -> Optional b) -> b -> Channel a ->{Channels} b
Channels.receiveUntil f b chan =
  a = receive chan
  match f b a with
    None   -> b
    Some b -> Channels.receiveUntil f b chan
Channels.broadcast : a -> [Channel a] ->{Channels} ()
Channels.broadcast a cs =
  map_ (Channels.send a) cs
  ()
unique type failure.Channel.UnknownChannel = 
unique type Channel a
  = { id : UID, location : Location {Channels} }
unique ability Channels where
  new : {Channels} (Channel a)
  size : Channel a ->{Channels} Nat
  nonce : Channel a ->{Channels} Nat
  receiveNow : Channel a ->{Channels} Optional a
  peekNow : Channel a ->{Channels} Optional a
  unreceive : a -> Channel a ->{Channels} ()
  sends : [a] -> Channel a ->{Channels} ()
  sendUnconfirmeds : [a] -> Channel a ->{Channels} ()
  receives : Nat -> Channel a ->{Channels} Nonempty a
  peek : Channel a ->{Channels} a
  copy : Channel a ->{Channels} Channel a
  close : Channel a ->{Channels} ()
  clear : Channel a ->{Channels} ()
Channels.receive : Channel a ->{Channels} a
Channels.receive chan = match receives 1 chan with
  Nonempty a _ -> a
Channels.send : a -> Channel a ->{Channels} ()
Channels.send a c = sends [a] c
Channels.sendUnconfirmed : a -> Channel a ->{Channels} ()
Channels.sendUnconfirmed a c = sendUnconfirmeds [a] c
```
```ucm
.code._distributed.channels> update
```

Which fails with:

Encountered Exception: DatabaseIntegrityError (NoObjectForPrimaryHashId (HashId 103233))
CallStack (from HasCallStack):
  error, called at src/Unison/Codebase/SqliteCodebase.hs:921:29 in unison-parser-typechecker-0.0.0-3ZCXoyD1xK78Xx2xOdGxbl:Unison.Codebase.SqliteCodebase
ChrisPenner commented 2 years ago

Upon exiting UCM we can see that there are un-saved component pieces left in the codebase buffer;

fromList [("591abd63g644hs5b0nopii3rafpb3t7ol0vibu99un2vp1oof6ffuf0h5634p14jemlfae8rgp56olihvms8hnebnvimtnongm1mfi0",BufferEntry {beComponentTargetSize = Nothing, beComponent = fromList [], beMissingDependencies = fromList [], beWaitingDependents = fromList ["biefqfabbc1977k87v54bt5djuca7k81lms9vps87f79hqan104jkq6pebg3udjthn4vas7tl8fcivkl94ded3er3k3cui8sfu94ogg"]}),("5mjvk4b6ufon9o8cb7583h3tnk080d6psmihesasjdqb9agi0g1tgc8qmb5pgfp32o7fnaqh7i6sc34cj0s01j0t270tr3d54hdali0",BufferEntry {beComponentTargetSize = Nothing, beComponent = fromList [], beMissingDependencies = fromList [], beWaitingDependents = fromList ["mqi5hahfiem4nb3gvlmthmoas4dhtn360831dfpho1k71baaj2sdn5gic1lmfl96aspb2ecbml244s9483uvdp4m1nhaou4av9n2l00"]}),("80b9dman731i9qp3bl7i073cb09nevteiiaoam0a3pncagb3ad4qt128mrko8lugh9eb52nh959jebd4ppm3615p4v95lr5fb6jkda0",BufferEntry {beComponentTargetSize = Just 1, beComponent = fromList [(0,((λ (User "f". (λ (User "b". (λ (User "chan". (let Ref(#qr5jn) (Var User "chan") in (User "a". (case (Var User "f") (Var User "b") (Var User "a") of [MatchCase Constructor #5islt 0 [] Nothing (Var User "b"),MatchCase Constructor #5islt 1 [Var] Nothing (User "b". (Ref(#80b9d) (Var User "f") (Var User "b") (Var User "chan")))]))))))))):(User "a". (User "b". (Var User "b" -> (Var User "a" -> #5islt (Var User "b"))) -> Var User "b" -> #pqauj.1c2 (Var User "a") -> ({[#pqauj.0c2]} Var User "b"))),(User "a". (User "b". (Var User "b" -> (({[]} (Var User "a" -> (({[]} #5islt (Var User "b"))))))) -> ({[]} Var User "b" -> ({[]} #pqauj.1c2 (Var User "a") -> ({[#pqauj.0c2]} Var User "b")))))))], beMissingDependencies = fromList ["qr5jn9u7j7s3eu3mhlc03fhgfgnn6puhkpiv2gebmmulmkv62o1u1t1ga71cfs32fe0v7uq5dhrskttg3lah5f4k2336tp8422k9uq8"], beWaitingDependents = fromList []}),("biefqfabbc1977k87v54bt5djuca7k81lms9vps87f79hqan104jkq6pebg3udjthn4vas7tl8fcivkl94ded3er3k3cui8sfu94ogg",BufferEntry {beComponentTargetSize = Just 1, beComponent = fromList [(0,((λ (User "f". (λ (User "b". (λ (User "chan". (let Ref(#591ab) (Var User "chan") in (User "a". (case (Var User "f") (Var User "b") (Var User "a") of [MatchCase Constructor #5islt 0 [] Nothing (Var User "b"),MatchCase Constructor #5islt 1 [Var] Nothing (User "b". (Ref(#biefq) (Var User "f") (Var User "b") (Var User "chan")))]))))))))):(User "a". (User "b". (Var User "b" -> (Var User "a" -> #5islt (Var User "b"))) -> Var User "b" -> #27bvf (Var User "a") -> ({[#cjfir]} Var User "b"))),(User "a". (User "b". (Var User "b" -> (({[]} (Var User "a" -> (({[]} #5islt (Var User "b"))))))) -> ({[]} Var User "b" -> ({[]} #27bvf (Var User "a") -> ({[#cjfir]} Var User "b")))))))], beMissingDependencies = fromList ["591abd63g644hs5b0nopii3rafpb3t7ol0vibu99un2vp1oof6ffuf0h5634p14jemlfae8rgp56olihvms8hnebnvimtnongm1mfi0"], beWaitingDependents = fromList []}),("cnjr30em1beh0nmnf2l4k4d11cg8ngermbrrsikoj2a5lng2ckm67m7p5m9adfil7c0djah2q6am429ec3fbp4sueb52nr17og4qm1g",BufferEntry {beComponentTargetSize = Nothing, beComponent = fromList [], beMissingDependencies = fromList [], beWaitingDependents = fromList ["k1u16inudtpikvqr1fhf87kvgj1p8v5rdg73bib2k9hl81okf0a7elh5qbh28na62merftkmjr2t7a7mgblckiteilpn1lq6dj8odl8"]}),("cvlq9vbafu1cbsc8rds960kln43iijll0bv8q8pet34fd9rfk0j7iruotpqie7tqgp01bjhophtnj8r3sht65h133pe6pg8hb75l2uo",BufferEntry {beComponentTargetSize = Nothing, beComponent = fromList [], beMissingDependencies = fromList [], beWaitingDependents = fromList ["u036oq1ok77kf7qaov16if5pmoffsdqa1lmhfok1h15t1uuo2ebv6eva2ttu23pdini0euordghjklflt0lg3eusbed395at3nel6kg"]}),("ddd5rblfte5h203pgblv2c24scjgogq683bac4tl9lbcmsd1u7613gtodagl7guvhnvuigs7gg0ngmleb0eo7dgkbrokpsev9rot6f0",BufferEntry {beComponentTargetSize = Just 1, beComponent = fromList [(0,((λ (User "a". (λ (User "cs". (let Ref(#a24n6) (Ref(#qlc8q) (Var User "a")) (Var User "cs") in (User "_"-500003. Con#568rs#0)))))),(User "a". (User "g". Var User "a" -> ({[Var User "g"]} ##Sequence (#27bvf (Var User "a")) -> ({[#cjfir]} #568rs))))))], beMissingDependencies = fromList ["qlc8qs664i00iqsclrckpasf50p30ol81mribt5c02ndpjjhjfcopv2d0dqt95iiqk7qn3mgv4tvf4e9p148ao1qolv2ct00vl7r6d0"], beWaitingDependents = fromList []}),("k1u16inudtpikvqr1fhf87kvgj1p8v5rdg73bib2k9hl81okf0a7elh5qbh28na62merftkmjr2t7a7mgblckiteilpn1lq6dj8odl8",BufferEntry {beComponentTargetSize = Just 1, beComponent = fromList [(0,((λ (User "a". (λ (User "cs". (let Ref(#a24n6) (Ref(#cnjr3) (Var User "a")) (Var User "cs") in (User "_"-550003. Con#568rs#0)))))),(User "a". (User "g". Var User "a" -> ({[Var User "g"]} ##Sequence (#amhb7.0c2 (Var User "a")) -> ({[#amhb7.1c2]} #568rs))))))], beMissingDependencies = fromList ["cnjr30em1beh0nmnf2l4k4d11cg8ngermbrrsikoj2a5lng2ckm67m7p5m9adfil7c0djah2q6am429ec3fbp4sueb52nr17og4qm1g"], beWaitingDependents = fromList []}),("mqi5hahfiem4nb3gvlmthmoas4dhtn360831dfpho1k71baaj2sdn5gic1lmfl96aspb2ecbml244s9483uvdp4m1nhaou4av9n2l00",BufferEntry {beComponentTargetSize = Just 1, beComponent = fromList [(0,((λ (User "a". (λ (User "cs". (let Ref(#a24n6) (Ref(#5mjvk) (Var User "a")) (Var User "cs") in (User "_"-500003. Con#568rs#0)))))),(User "a". (User "g". Var User "a" -> ({[Var User "g"]} ##Sequence (#pqauj.1c2 (Var User "a")) -> ({[#pqauj.0c2]} #568rs))))))], beMissingDependencies = fromList ["5mjvk4b6ufon9o8cb7583h3tnk080d6psmihesasjdqb9agi0g1tgc8qmb5pgfp32o7fnaqh7i6sc34cj0s01j0t270tr3d54hdali0"], beWaitingDependents = fromList []}),("qlc8qs664i00iqsclrckpasf50p30ol81mribt5c02ndpjjhjfcopv2d0dqt95iiqk7qn3mgv4tvf4e9p148ao1qolv2ct00vl7r6d0",BufferEntry {beComponentTargetSize = Nothing, beComponent = fromList [], beMissingDependencies = fromList [], beWaitingDependents = fromList ["ddd5rblfte5h203pgblv2c24scjgogq683bac4tl9lbcmsd1u7613gtodagl7guvhnvuigs7gg0ngmleb0eo7dgkbrokpsev9rot6f0"]}),("qr5jn9u7j7s3eu3mhlc03fhgfgnn6puhkpiv2gebmmulmkv62o1u1t1ga71cfs32fe0v7uq5dhrskttg3lah5f4k2336tp8422k9uq8",BufferEntry {beComponentTargetSize = Nothing, beComponent = fromList [], beMissingDependencies = fromList [], beWaitingDependents = fromList ["80b9dman731i9qp3bl7i073cb09nevteiiaoam0a3pncagb3ad4qt128mrko8lugh9eb52nh959jebd4ppm3615p4v95lr5fb6jkda0"]}),("u036oq1ok77kf7qaov16if5pmoffsdqa1lmhfok1h15t1uuo2ebv6eva2ttu23pdini0euordghjklflt0lg3eusbed395at3nel6kg",BufferEntry {beComponentTargetSize = Just 1, beComponent = fromList [(0,((λ (User "f". (λ (User "b". (λ (User "chan". (let Ref(#cvlq9) (Var User "chan") in (User "a". (case (Var User "f") (Var User "b") (Var User "a") of [MatchCase Constructor #5islt 0 [] Nothing (Var User "b"),MatchCase Constructor #5islt 1 [Var] Nothing (User "b". (Ref(#u036o) (Var User "f") (Var User "b") (Var User "chan")))]))))))))):(User "a". (User "b". (Var User "b" -> (Var User "a" -> #5islt (Var User "b"))) -> Var User "b" -> #amhb7.0c2 (Var User "a") -> ({[#amhb7.1c2]} Var User "b"))),(User "a". (User "b". (Var User "b" -> (({[]} (Var User "a" -> (({[]} #5islt (Var User "b"))))))) -> ({[]} Var User "b" -> ({[]} #amhb7.0c2 (Var User "a") -> ({[#amhb7.1c2]} Var User "b")))))))], beMissingDependencies = fromList ["cvlq9vbafu1cbsc8rds960kln43iijll0bv8q8pet34fd9rfk0j7iruotpqie7tqgp01bjhophtnj8r3sht65h133pe6pg8hb75l2uo"], beWaitingDependents = fromList []})]

So that would explain why putRoot fails with an integrity error. We need to find why these components aren't being properly resolved though.

aryairani commented 2 years ago

Something can (and does) also appear stuck in the buffer above when it's "put" to the codebase before one of its transitive dependencies has been. See beMissingDependencies above. i.e. it doesn't actually have to be an incomplete component to show up there.

aryairani commented 2 years ago

Here is a formatted version of the above, which gives a little more insight. There are no incomplete components after all, only missing dependencies:

fromList [
  ("591abd63g644hs5b0nopii3rafpb3t7ol0vibu99un2vp1oof6ffuf0h5634p14jemlfae8rgp56olihvms8hnebnvimtnongm1mfi0",
    BufferEntry {
      beComponentTargetSize = Nothing, 
      beComponent = fromList [], 
      beMissingDependencies = fromList [], 
      beWaitingDependents = fromList ["biefqfabbc1977k87v54bt5djuca7k81lms9vps87f79hqan104jkq6pebg3udjthn4vas7tl8fcivkl94ded3er3k3cui8sfu94ogg"]
    }),
  ("5mjvk4b6ufon9o8cb7583h3tnk080d6psmihesasjdqb9agi0g1tgc8qmb5pgfp32o7fnaqh7i6sc34cj0s01j0t270tr3d54hdali0",
    BufferEntry {
      beComponentTargetSize = Nothing, 
      beComponent = fromList [], 
      beMissingDependencies = fromList [], 
      beWaitingDependents = fromList ["mqi5hahfiem4nb3gvlmthmoas4dhtn360831dfpho1k71baaj2sdn5gic1lmfl96aspb2ecbml244s9483uvdp4m1nhaou4av9n2l00"]
    }),
  ("80b9dman731i9qp3bl7i073cb09nevteiiaoam0a3pncagb3ad4qt128mrko8lugh9eb52nh959jebd4ppm3615p4v95lr5fb6jkda0",
    BufferEntry {
      beComponentTargetSize = Just 1, 
      beComponent = fromList [(0,((λ (User "f". (λ (User "b". (λ (User "chan". (let Ref(#qr5jn) (Var User "chan") in (User "a". (case (Var User "f") (Var User "b") (Var User "a") of [MatchCase Constructor #5islt 0 [] Nothing (Var User "b"),MatchCase Constructor #5islt 1 [Var] Nothing (User "b". (Ref(#80b9d) (Var User "f") (Var User "b") (Var User "chan")))]))))))))):(User "a". (User "b". (Var User "b" -> (Var User "a" -> #5islt (Var User "b"))) -> Var User "b" -> #pqauj.1c2 (Var User "a") -> ({[#pqauj.0c2]} Var User "b"))),(User "a". (User "b". (Var User "b" -> (({[]} (Var User "a" -> (({[]} #5islt (Var User "b"))))))) -> ({[]} Var User "b" -> ({[]} #pqauj.1c2 (Var User "a") -> ({[#pqauj.0c2]} Var User "b")))))))], 
      beMissingDependencies = fromList ["qr5jn9u7j7s3eu3mhlc03fhgfgnn6puhkpiv2gebmmulmkv62o1u1t1ga71cfs32fe0v7uq5dhrskttg3lah5f4k2336tp8422k9uq8"], 
      beWaitingDependents = fromList []
    }),
  ("biefqfabbc1977k87v54bt5djuca7k81lms9vps87f79hqan104jkq6pebg3udjthn4vas7tl8fcivkl94ded3er3k3cui8sfu94ogg",
    BufferEntry {
      beComponentTargetSize = Just 1, 
      beComponent = fromList [(0,((λ (User "f". (λ (User "b". (λ (User "chan". (let Ref(#591ab) (Var User "chan") in (User "a". (case (Var User "f") (Var User "b") (Var User "a") of [MatchCase Constructor #5islt 0 [] Nothing (Var User "b"),MatchCase Constructor #5islt 1 [Var] Nothing (User "b". (Ref(#biefq) (Var User "f") (Var User "b") (Var User "chan")))]))))))))):(User "a". (User "b". (Var User "b" -> (Var User "a" -> #5islt (Var User "b"))) -> Var User "b" -> #27bvf (Var User "a") -> ({[#cjfir]} Var User "b"))),(User "a". (User "b". (Var User "b" -> (({[]} (Var User "a" -> (({[]} #5islt (Var User "b"))))))) -> ({[]} Var User "b" -> ({[]} #27bvf (Var User "a") -> ({[#cjfir]} Var User "b")))))))], 
      beMissingDependencies = fromList ["591abd63g644hs5b0nopii3rafpb3t7ol0vibu99un2vp1oof6ffuf0h5634p14jemlfae8rgp56olihvms8hnebnvimtnongm1mfi0"], 
      beWaitingDependents = fromList []
    }),
  ("cnjr30em1beh0nmnf2l4k4d11cg8ngermbrrsikoj2a5lng2ckm67m7p5m9adfil7c0djah2q6am429ec3fbp4sueb52nr17og4qm1g",
    BufferEntry {
      beComponentTargetSize = Nothing, 
      beComponent = fromList [], 
      beMissingDependencies = fromList [], 
      beWaitingDependents = fromList ["k1u16inudtpikvqr1fhf87kvgj1p8v5rdg73bib2k9hl81okf0a7elh5qbh28na62merftkmjr2t7a7mgblckiteilpn1lq6dj8odl8"]
    }),
  ("cvlq9vbafu1cbsc8rds960kln43iijll0bv8q8pet34fd9rfk0j7iruotpqie7tqgp01bjhophtnj8r3sht65h133pe6pg8hb75l2uo",
    BufferEntry {
      beComponentTargetSize = Nothing, 
      beComponent = fromList [], 
      beMissingDependencies = fromList [], 
      beWaitingDependents = fromList ["u036oq1ok77kf7qaov16if5pmoffsdqa1lmhfok1h15t1uuo2ebv6eva2ttu23pdini0euordghjklflt0lg3eusbed395at3nel6kg"]
    }),
  ("ddd5rblfte5h203pgblv2c24scjgogq683bac4tl9lbcmsd1u7613gtodagl7guvhnvuigs7gg0ngmleb0eo7dgkbrokpsev9rot6f0",
    BufferEntry {
      beComponentTargetSize = Just 1, 
      beComponent = fromList [(0,((λ (User "a". (λ (User "cs". (let Ref(#a24n6) (Ref(#qlc8q) (Var User "a")) (Var User "cs") in (User "_"-500003. Con#568rs#0)))))),(User "a". (User "g". Var User "a" -> ({[Var User "g"]} ##Sequence (#27bvf (Var User "a")) -> ({[#cjfir]} #568rs))))))], 
      beMissingDependencies = fromList ["qlc8qs664i00iqsclrckpasf50p30ol81mribt5c02ndpjjhjfcopv2d0dqt95iiqk7qn3mgv4tvf4e9p148ao1qolv2ct00vl7r6d0"], 
      beWaitingDependents = fromList []
    }),
  ("k1u16inudtpikvqr1fhf87kvgj1p8v5rdg73bib2k9hl81okf0a7elh5qbh28na62merftkmjr2t7a7mgblckiteilpn1lq6dj8odl8",
    BufferEntry {
      beComponentTargetSize = Just 1, 
      beComponent = fromList [(0,((λ (User "a". (λ (User "cs". (let Ref(#a24n6) (Ref(#cnjr3) (Var User "a")) (Var User "cs") in (User "_"-550003. Con#568rs#0)))))),(User "a". (User "g". Var User "a" -> ({[Var User "g"]} ##Sequence (#amhb7.0c2 (Var User "a")) -> ({[#amhb7.1c2]} #568rs))))))], 
      beMissingDependencies = fromList ["cnjr30em1beh0nmnf2l4k4d11cg8ngermbrrsikoj2a5lng2ckm67m7p5m9adfil7c0djah2q6am429ec3fbp4sueb52nr17og4qm1g"], 
      beWaitingDependents = fromList []
    }),
  ("mqi5hahfiem4nb3gvlmthmoas4dhtn360831dfpho1k71baaj2sdn5gic1lmfl96aspb2ecbml244s9483uvdp4m1nhaou4av9n2l00",
    BufferEntry {
      beComponentTargetSize = Just 1, 
      beComponent = fromList [(0,((λ (User "a". (λ (User "cs". (let Ref(#a24n6) (Ref(#5mjvk) (Var User "a")) (Var User "cs") in (User "_"-500003. Con#568rs#0)))))),(User "a". (User "g". Var User "a" -> ({[Var User "g"]} ##Sequence (#pqauj.1c2 (Var User "a")) -> ({[#pqauj.0c2]} #568rs))))))], 
      beMissingDependencies = fromList ["5mjvk4b6ufon9o8cb7583h3tnk080d6psmihesasjdqb9agi0g1tgc8qmb5pgfp32o7fnaqh7i6sc34cj0s01j0t270tr3d54hdali0"], 
      beWaitingDependents = fromList []
    }),
  ("qlc8qs664i00iqsclrckpasf50p30ol81mribt5c02ndpjjhjfcopv2d0dqt95iiqk7qn3mgv4tvf4e9p148ao1qolv2ct00vl7r6d0",
    BufferEntry {
      beComponentTargetSize = Nothing, 
      beComponent = fromList [], 
      beMissingDependencies = fromList [], 
      beWaitingDependents = fromList ["ddd5rblfte5h203pgblv2c24scjgogq683bac4tl9lbcmsd1u7613gtodagl7guvhnvuigs7gg0ngmleb0eo7dgkbrokpsev9rot6f0"]
      }),
  ("qr5jn9u7j7s3eu3mhlc03fhgfgnn6puhkpiv2gebmmulmkv62o1u1t1ga71cfs32fe0v7uq5dhrskttg3lah5f4k2336tp8422k9uq8",
    BufferEntry {
      beComponentTargetSize = Nothing, 
      beComponent = fromList [], 
      beMissingDependencies = fromList [], 
      beWaitingDependents = fromList ["80b9dman731i9qp3bl7i073cb09nevteiiaoam0a3pncagb3ad4qt128mrko8lugh9eb52nh959jebd4ppm3615p4v95lr5fb6jkda0"]
      }),
  ("u036oq1ok77kf7qaov16if5pmoffsdqa1lmhfok1h15t1uuo2ebv6eva2ttu23pdini0euordghjklflt0lg3eusbed395at3nel6kg",
    BufferEntry {
      beComponentTargetSize = Just 1, 
      beComponent = fromList [(0,((λ (User "f". (λ (User "b". (λ (User "chan". (let Ref(#cvlq9) (Var User "chan") in (User "a". (case (Var User "f") (Var User "b") (Var User "a") of [MatchCase Constructor #5islt 0 [] Nothing (Var User "b"),MatchCase Constructor #5islt 1 [Var] Nothing (User "b". (Ref(#u036o) (Var User "f") (Var User "b") (Var User "chan")))]))))))))):(User "a". (User "b". (Var User "b" -> (Var User "a" -> #5islt (Var User "b"))) -> Var User "b" -> #amhb7.0c2 (Var User "a") -> ({[#amhb7.1c2]} Var User "b"))),(User "a". (User "b". (Var User "b" -> (({[]} (Var User "a" -> (({[]} #5islt (Var User "b"))))))) -> ({[]} Var User "b" -> ({[]} #amhb7.0c2 (Var User "a") -> ({[#amhb7.1c2]} Var User "b")))))))], 
      beMissingDependencies = fromList ["cvlq9vbafu1cbsc8rds960kln43iijll0bv8q8pet34fd9rfk0j7iruotpqie7tqgp01bjhophtnj8r3sht65h133pe6pg8hb75l2uo"], 
      beWaitingDependents = fromList []})]

And here are the 6 missing definitions and their blocked dependents. The missing dependency is at the top of each group, and blocked dependents are chained below it.

591abd63g644hs5b0nopii3rafpb3t7ol0vibu99un2vp1oof6ffuf0h5634p14jemlfae8rgp56olihvms8hnebnvimtnongm1mfi0
biefqfabbc1977k87v54bt5djuca7k81lms9vps87f79hqan104jkq6pebg3udjthn4vas7tl8fcivkl94ded3er3k3cui8sfu94ogg
mqi5hahfiem4nb3gvlmthmoas4dhtn360831dfpho1k71baaj2sdn5gic1lmfl96aspb2ecbml244s9483uvdp4m1nhaou4av9n2l00
qr5jn9u7j7s3eu3mhlc03fhgfgnn6puhkpiv2gebmmulmkv62o1u1t1ga71cfs32fe0v7uq5dhrskttg3lah5f4k2336tp8422k9uq8
80b9dman731i9qp3bl7i073cb09nevteiiaoam0a3pncagb3ad4qt128mrko8lugh9eb52nh959jebd4ppm3615p4v95lr5fb6jkda0
cnjr30em1beh0nmnf2l4k4d11cg8ngermbrrsikoj2a5lng2ckm67m7p5m9adfil7c0djah2q6am429ec3fbp4sueb52nr17og4qm1g
k1u16inudtpikvqr1fhf87kvgj1p8v5rdg73bib2k9hl81okf0a7elh5qbh28na62merftkmjr2t7a7mgblckiteilpn1lq6dj8odl8
cvlq9vbafu1cbsc8rds960kln43iijll0bv8q8pet34fd9rfk0j7iruotpqie7tqgp01bjhophtnj8r3sht65h133pe6pg8hb75l2uo
u036oq1ok77kf7qaov16if5pmoffsdqa1lmhfok1h15t1uuo2ebv6eva2ttu23pdini0euordghjklflt0lg3eusbed395at3nel6kg
qlc8qs664i00iqsclrckpasf50p30ol81mribt5c02ndpjjhjfcopv2d0dqt95iiqk7qn3mgv4tvf4e9p148ao1qolv2ct00vl7r6d0
ddd5rblfte5h203pgblv2c24scjgogq683bac4tl9lbcmsd1u7613gtodagl7guvhnvuigs7gg0ngmleb0eo7dgkbrokpsev9rot6f0
5mjvk4b6ufon9o8cb7583h3tnk080d6psmihesasjdqb9agi0g1tgc8qmb5pgfp32o7fnaqh7i6sc34cj0s01j0t270tr3d54hdali0
mqi5hahfiem4nb3gvlmthmoas4dhtn360831dfpho1k71baaj2sdn5gic1lmfl96aspb2ecbml244s9483uvdp4m1nhaou4av9n2l00

The un-started components have beComponentTargetSize = Nothing.

aryairani commented 2 years ago

@ChrisPenner If you change that transcript to do an add instead of an update. (You'll have to add in a different namespace though, due to the existing definitions.) You can even then go back and update the new definitions into the original target namespace and that succeeds too.

e.g.

```ucm
.code._distributed.channels2> add
.code._distributed.channels> update


So the issue has got to be something specific to `update`.
ChrisPenner commented 2 years ago

Here's the profile stack-trace for the error:

Encountered Exception: DatabaseIntegrityError (NoObjectForPrimaryHashId (HashId 61447))
CallStack (from HasCallStack):
  error, called at ./U/Codebase/Sqlite/Operations.hs:207:35 in unison-codebase-sqlite-0.0.0-1iJCpUyvMFRIrfgXRSWgib:U.Codebase.Sqlite.Operations
  throwError, called at ./U/Codebase/Sqlite/Operations.hs:255:15 in unison-codebase-sqlite-0.0.0-1iJCpUyvMFRIrfgXRSWgib:U.Codebase.Sqlite.Operations
  liftQ, called at ./U/Codebase/Sqlite/Operations.hs:273:20 in unison-codebase-sqlite-0.0.0-1iJCpUyvMFRIrfgXRSWgib:U.Codebase.Sqlite.Operations
  primaryHashToExistingObjectId, called at ./U/Codebase/Sqlite/Operations.hs:391:29 in unison-codebase-sqlite-0.0.0-1iJCpUyvMFRIrfgXRSWgib:U.Codebase.Sqlite.Operations
  done, called at ./U/Codebase/Sqlite/Operations.hs:378:3 in unison-codebase-sqlite-0.0.0-1iJCpUyvMFRIrfgXRSWgib:U.Codebase.Sqlite.Operations
  c2lPatch, called at ./U/Codebase/Sqlite/Operations.hs:1291:19 in unison-codebase-sqlite-0.0.0-1iJCpUyvMFRIrfgXRSWgib:U.Codebase.Sqlite.Operations
  savePatch, called at ./U/Codebase/Sqlite/Operations.hs:1017:22 in unison-codebase-sqlite-0.0.0-1iJCpUyvMFRIrfgXRSWgib:U.Codebase.Sqlite.Operations
  savePatch', called at ./U/Codebase/Sqlite/Operations.hs:1001:46 in unison-codebase-sqlite-0.0.0-1iJCpUyvMFRIrfgXRSWgib:U.Codebase.Sqlite.Operations
  c2lBranch, called at ./U/Codebase/Sqlite/Operations.hs:991:22 in unison-codebase-sqlite-0.0.0-1iJCpUyvMFRIrfgXRSWgib:U.Codebase.Sqlite.Operations
  saveBranch, called at ./U/Codebase/Sqlite/Operations.hs:1020:34 in unison-codebase-sqlite-0.0.0-1iJCpUyvMFRIrfgXRSWgib:U.Codebase.Sqlite.Operations
  saveChild, called at ./U/Codebase/Sqlite/Operations.hs:1002:46 in unison-codebase-sqlite-0.0.0-1iJCpUyvMFRIrfgXRSWgib:U.Codebase.Sqlite.Operations
  c2lBranch, called at ./U/Codebase/Sqlite/Operations.hs:991:22 in unison-codebase-sqlite-0.0.0-1iJCpUyvMFRIrfgXRSWgib:U.Codebase.Sqlite.Operations
  saveBranch, called at ./U/Codebase/Sqlite/Operations.hs:986:35 in unison-codebase-sqlite-0.0.0-1iJCpUyvMFRIrfgXRSWgib:U.Codebase.Sqlite.Operations
  saveBranch, called at ./U/Codebase/Sqlite/Operations.hs:965:19 in unison-codebase-sqlite-0.0.0-1iJCpUyvMFRIrfgXRSWgib:U.Codebase.Sqlite.Operations
  saveRootBranch, called at src/Unison/Codebase/SqliteCodebase.hs:535:17 in unison-parser-typechecker-0.0.0-6GFzkoMkw4W5u57A5cQFCX:Unison.Codebase.SqliteCodebase
CallStack (from -prof):
  U.Codebase.Sqlite.Operations.throwError (U/Codebase/Sqlite/Operations.hs:207:1-69)
  U.Codebase.Sqlite.Operations.liftQ.\ (U/Codebase/Sqlite/Operations.hs:255:15-51)
  U.Codebase.Sqlite.Operations.liftQ (U/Codebase/Sqlite/Operations.hs:(253,1)-(258,21))
  U.Codebase.Sqlite.Operations.primaryHashToExistingObjectId.\ (U/Codebase/Sqlite/Operations.hs:273:20-66)
  U.Codebase.Sqlite.Operations.primaryHashToExistingObjectId (U/Codebase/Sqlite/Operations.hs:(271,1)-(274,47))
  U.Codebase.Sqlite.Operations.c2lPatch.done (U/Codebase/Sqlite/Operations.hs:(388,5)-(397,24))
  U.Codebase.Sqlite.Operations.c2lPatch (U/Codebase/Sqlite/Operations.hs:(377,1)-(446,39))
  U.Codebase.Sqlite.Operations.savePatch (U/Codebase/Sqlite/Operations.hs:(1290,1)-(1294,57))
  U.Codebase.Sqlite.Operations.saveBranch.savePatch'.\ (U/Codebase/Sqlite/Operations.hs:1017:22-53)
  U.Codebase.Sqlite.Operations.saveBranch.savePatch' (U/Codebase/Sqlite/Operations.hs:(1013,5)-(1018,26))
  Unison.Util.Map.bitraverse (src/Unison/Util/Map.hs:(22,1)-(24,54))
  U.Codebase.Sqlite.Operations.saveBranch.c2lBranch (U/Codebase/Sqlite/Operations.hs:(996,5)-(1002,63))
  U.Codebase.Sqlite.Operations.saveBranch.\ (U/Codebase/Sqlite/Operations.hs:(984,9)-(986,45))
  U.Codebase.Sqlite.Operations.saveBranch (U/Codebase/Sqlite/Operations.hs:(970,1)-(1079,25))
  U.Codebase.Sqlite.Operations.saveRootBranch (U/Codebase/Sqlite/Operations.hs:(963,1)-(967,19))
  Unison.Codebase.SqliteCodebase.runDB (src/Unison/Codebase/SqliteCodebase.hs:(923,1)-(925,63))
  Unison.Codebase.SqliteCodebase.sqliteCodebase.\.\.putRootBranch (src/Unison/Codebase/SqliteCodebase.hs:(530,11)-(538,83))
  Unison.Codebase.SqliteCodebase.sqliteCodebase.\.\.codebase (src/Unison/Codebase/SqliteCodebase.hs:(749,8)-(785,59))
  Unison.Codebase.Type.putRootBranch (src/Unison/Codebase/Type.hs:70:5-17)
  Unison.Codebase.Editor.HandleCommand.commandLine.go (src/Unison/Codebase/Editor/HandleCommand.hs:(105,3)-(230,15))
  Unison.Util.Free.fold (src/Unison/Util/Free.hs:(22,1)-(24,32))
  Unison.Codebase.Editor.HandleCommand.commandLine (src/Unison/Codebase/Editor/HandleCommand.hs:(100,1)-(260,23))
  Unison.CommandLine.Main.main.loop.handleCommand (src/Unison/CommandLine/Main.hs:(187,17)-(197,45))
  Unison.CommandLine.Main.main.loop (src/Unison/CommandLine/Main.hs:(184,11)-(211,31))
  Unison.CommandLine.Main.main (src/Unison/CommandLine/Main.hs:(115,1)-(227,9))
  Main.launch (unison/Main.hs:(310,1)-(330,19))
  Main.main.\.\ (unison/Main.hs:(190,82)-(210,102))
  Control.Concurrent.Async.catchAll (Control/Concurrent/Async.hs:951:1-16)
  Control.Concurrent.Async.concurrently'.\ (Control/Concurrent/Async.hs:(779,24)-(822,16))
  Control.Concurrent.Async.concurrently' (Control/Concurrent/Async.hs:(777,1)-(822,16))
  Control.Concurrent.Async.race (Control/Concurrent/Async.hs:(752,1)-(758,31))
  UnliftIO.Internals.Async.race.\ (src/UnliftIO/Internals/Async.hs:232:34-55)
  Network.Wai.Handler.Warp.WithApplication.withApplicationSettings.\ (Network/Wai/Handler/Warp/WithApplication.hs:(37,36)-(49,25))
  Network.Wai.Handler.Warp.WithApplication.withApplicationSettings (Network/Wai/Handler/Warp/WithApplication.hs:(35,1)-(63,15))
  Unison.Server.CodebaseServer.startServer (src/Unison/Server/CodebaseServer.hs:(243,1)-(267,25))
  Main.main.\ (unison/Main.hs:(188,72)-(210,102))
  Main.getCodebaseOrExit.\ (unison/Main.hs:366:7-19)
  Unison.Codebase.Init.withOpenOrCreateCodebase.\ (src/Unison/Codebase/Init.hs:(91,73)-(92,51))
  UnliftIO.Exception.finally.\.\ (src/UnliftIO/Exception.hs:(403,87)-(412,14))
  UnliftIO.Exception.finally.\ (src/UnliftIO/Exception.hs:(403,45)-(412,14))
  UnliftIO.Exception.finally (src/UnliftIO/Exception.hs:(403,1)-(417,17))
  Unison.Codebase.SqliteCodebase.sqliteCodebase.\.\ (src/Unison/Codebase/SqliteCodebase.hs:(279,24)-(798,53))
  Unison.Codebase.SqliteCodebase.sqliteCodebase.\ (src/Unison/Codebase/SqliteCodebase.hs:(274,43)-(799,22))
  Unison.Codebase.SqliteCodebase.withConnection.\ (src/Unison/Codebase/SqliteCodebase.hs:264:20-27)
  Unison.Codebase.SqliteCodebase.withConnection (src/Unison/Codebase/SqliteCodebase.hs:(260,1)-(264,28))
  Unison.Codebase.SqliteCodebase.sqliteCodebase (src/Unison/Codebase/SqliteCodebase.hs:(272,1)-(799,22))
  Unison.Codebase.SqliteCodebase.withCodebaseOrError.\ (src/Unison/Codebase/SqliteCodebase.hs:171:7-120)
  Unison.Codebase.SqliteCodebase.withCodebaseOrError (src/Unison/Codebase/SqliteCodebase.hs:(167,1)-(171,120))
  Unison.Codebase.SqliteCodebase.init (src/Unison/Codebase/SqliteCodebase.hs:(117,1)-(121,3))
  Unison.Codebase.Init.withOpenCodebase (src/Unison/Codebase/Init.hs:52:5-20)
  Unison.Codebase.Init.withOpenOrCreateCodebase (src/Unison/Codebase/Init.hs:(89,1)-(115,81))
  Main.getCodebaseOrExit (unison/Main.hs:(356,1)-(405,53))
  UnliftIO.Exception.bracket.\.\ (src/UnliftIO/Exception.hs:(345,79)-(360,14))
  UnliftIO.Exception.bracket.\ (src/UnliftIO/Exception.hs:(345,52)-(360,14))
  Control.Monad.IO.Unlift.withRunInIO (src/Control/Monad/IO/Unlift.hs:63:3-30)
  UnliftIO.Exception.bracket (src/UnliftIO/Exception.hs:(345,1)-(366,17))
  Compat.withInterruptHandler (src/Compat.hs:(33,1)-(56,40))
  Main.main (unison/Main.hs:(70,1)-(210,102))
ChrisPenner commented 2 years ago

Here's the slurp result which causes the issue:

SlurpResult {originalFile = TypecheckedUnisonFileId {dataDeclarationsId' = fromList [(User "Channel",(#73mje.0c2,DataDeclaration {modifier = Unique "dfg1movjdr9kbgcneie3tm06fdu4aa4j", annotation = Ann {start = line 16, column 1, end = line 17, column 47}, bound = [User "a"], constructors' = [(Ann {start = line 16, column 13, end = line 16, column 20},User "Channel.Channel",(User "a". #alf3o -> #e5bcj ({[#73mje.1c2]}) -> #73mje.0c2 (Var User "a")))]})),(User "failure.Channel.UnknownChannel",(#uh0at,DataDeclaration {modifier = Unique "enjdm95jmmn58f73o3pqs4156kgf8im3", annotation = Ann {start = line 14, column 1, end = line 14, column 45}, bound = [], constructors' = []}))], effectDeclarationsId' = fromList [(User "Channels",(#73mje.1c2,EffectDeclaration {toDataDecl = DataDeclaration {modifier = Unique "r8qqmrp0064u6hm4oka99vfkmqqcfcnu", annotation = Ann {start = line 19, column 1, end = line 32, column 36}, bound = [], constructors' = [(Ann {start = line 23, column 3, end = line 23, column 13},User "Channels.receiveNow",(User "a". #73mje.0c2 (Var User "a") -> ({[#73mje.1c2]} #5islt (Var User "a")))),(Ann {start = line 24, column 3, end = line 24, column 10},User "Channels.peekNow",(User "a". #73mje.0c2 (Var User "a") -> ({[#73mje.1c2]} #5islt (Var User "a")))),(Ann {start = line 30, column 3, end = line 30, column 7},User "Channels.copy",(User "a". #73mje.0c2 (Var User "a") -> ({[#73mje.1c2]} #73mje.0c2 (Var User "a")))),(Ann {start = line 31, column 3, end = line 31, column 8},User "Channels.close",(User "a". #73mje.0c2 (Var User "a") -> ({[#73mje.1c2]} #568rs))),(Ann {start = line 32, column 3, end = line 32, column 8},User "Channels.clear",(User "a". #73mje.0c2 (Var User "a") -> ({[#73mje.1c2]} #568rs))),(Ann {start = line 26, column 3, end = line 26, column 8},User "Channels.sends",(User "a". ##Sequence (Var User "a") -> #73mje.0c2 (Var User "a") -> ({[#73mje.1c2]} #568rs))),(Ann {start = line 27, column 3, end = line 27, column 19},User "Channels.sendUnconfirmeds",(User "a". ##Sequence (Var User "a") -> #73mje.0c2 (Var User "a") -> ({[#73mje.1c2]} #568rs))),(Ann {start = line 28, column 3, end = line 28, column 11},User "Channels.receives",(User "a". ##Nat -> #73mje.0c2 (Var User "a") -> ({[#73mje.1c2]} #9f58i (Var User "a")))),(Ann {start = line 21, column 3, end = line 21, column 7},User "Channels.size",(User "a". #73mje.0c2 (Var User "a") -> ({[#73mje.1c2]} ##Nat))),(Ann {start = line 22, column 3, end = line 22, column 8},User "Channels.nonce",(User "a". #73mje.0c2 (Var User "a") -> ({[#73mje.1c2]} ##Nat))),(Ann {start = line 29, column 3, end = line 29, column 7},User "Channels.peek",(User "a". #73mje.0c2 (Var User "a") -> ({[#73mje.1c2]} Var User "a"))),(Ann {start = line 20, column 3, end = line 20, column 6},User "Channels.new",(User "a". ({[#73mje.1c2]} #73mje.0c2 (Var User "a")))),(Ann {start = line 25, column 3, end = line 25, column 12},User "Channels.unreceive",(User "a". Var User "a" -> #73mje.0c2 (Var User "a") -> ({[#73mje.1c2]} #568rs)))]}}))], topLevelComponents' = [[(User "Channels.receiveUntil",(λ (User "f". (λ (User "b". (λ (User "chan". (let (Var User "Channels.receive") (Var User "chan") in (User "a". (case (Var User "f") (Var User "b") (Var User "a") of [MatchCase Constructor #5islt 0 [] Nothing (Var User "b"),MatchCase Constructor #5islt 1 [Var] Nothing (User "b". ((Var User "Channels.receiveUntil") (Var User "f") (Var User "b") (Var User "chan")))]))))))))):(User "a". (User "b". (Var User "b" -> (Var User "a" -> #5islt (Var User "b"))) -> Var User "b" -> #73mje.0c2 (Var User "a") -> ({[#73mje.1c2]} Var User "b"))),(User "a". (User "b". (Var User "b" -> (({[]} (Var User "a" -> (({[]} #5islt (Var User "b"))))))) -> ({[]} Var User "b" -> ({[]} #73mje.0c2 (Var User "a") -> ({[#73mje.1c2]} Var User "b"))))))],[(User "Channel.location.modify",(λ (User "f". (λ (User "channel". (case Var User "channel" of [MatchCase Constructor #73mje.0c2 0 [Var,Var] Nothing (User "id". (User "location". (Con#73mje.0c2#0 (Var User "id") ((Var User "f") (Var User "location")))))]))))),(User "g". (User "a". (User "a"-1. (#e5bcj ({[#73mje.1c2]}) -> (({[Var User "g"]} #e5bcj ({[#73mje.1c2]})))) -> ({[]} #73mje.0c2 (Var User "a"-1) -> ({[Var User "g"]} #73mje.0c2 (Var User "a")))))))],[(User "Channel.location.set",(λ (User "location1". (λ (User "channel". (case Var User "channel" of [MatchCase Constructor #73mje.0c2 0 [Var,Unbound] Nothing (User "id". (Con#73mje.0c2#0 (Var User "id") (Var User "location1")))]))))),(User "a". (User "a"-1. #e5bcj ({[#73mje.1c2]}) -> ({[]} #73mje.0c2 (Var User "a"-1) -> ({[]} #73mje.0c2 (Var User "a"))))))],[(User "Channel.location",(λ (User "channel". (case Var User "channel" of [MatchCase Constructor #73mje.0c2 0 [Unbound,Var] Nothing (User "location". (Var User "location"))]))),(User "a". #73mje.0c2 (Var User "a") -> ({[]} #e5bcj ({[#73mje.1c2]}))))],[(User "Channel.id.modify",(λ (User "f". (λ (User "channel". (case Var User "channel" of [MatchCase Constructor #73mje.0c2 0 [Var,Var] Nothing (User "id". (User "location". (Con#73mje.0c2#0 ((Var User "f") (Var User "id")) (Var User "location"))))]))))),(User "g". (User "a". (User "a"-1. (#alf3o -> (({[Var User "g"]} #alf3o))) -> ({[]} #73mje.0c2 (Var User "a"-1) -> ({[Var User "g"]} #73mje.0c2 (Var User "a")))))))],[(User "Channel.id.set",(λ (User "id1". (λ (User "channel". (case Var User "channel" of [MatchCase Constructor #73mje.0c2 0 [Unbound,Var] Nothing (User "location". (Con#73mje.0c2#0 (Var User "id1") (Var User "location")))]))))),(User "a". (User "a"-1. #alf3o -> ({[]} #73mje.0c2 (Var User "a"-1) -> ({[]} #73mje.0c2 (Var User "a"))))))],[(User "Channel.id",(λ (User "channel". (case Var User "channel" of [MatchCase Constructor #73mje.0c2 0 [Var,Unbound] Nothing (User "id". (Var User "id"))]))),(User "a". #73mje.0c2 (Var User "a") -> ({[]} #alf3o)))],[(User "Channels.sendUnconfirmed",(λ (User "a". (λ (User "c". Req#73mje.1c2#6 [Var User "a"] (Var User "c"))))),(User "a". (User "g". Var User "a" -> ({[Var User "g"]} #73mje.0c2 (Var User "a") -> ({[#73mje.1c2]} #568rs)))))],[(User "Channels.broadcast",(λ (User "a". (λ (User "cs". (let Ref(#a24n6) ((Var User "Channels.send") (Var User "a")) (Var User "cs") in (User "_"-550003. Con#568rs#0)))))),(User "a". (User "g". Var User "a" -> ({[Var User "g"]} ##Sequence (#73mje.0c2 (Var User "a")) -> ({[#73mje.1c2]} #568rs)))))],[(User "Channels.send",(λ (User "a". (λ (User "c". Req#73mje.1c2#5 [Var User "a"] (Var User "c"))))),(User "a". (User "g". Var User "a" -> ({[Var User "g"]} #73mje.0c2 (Var User "a") -> ({[#73mje.1c2]} #568rs)))))],[(User "Channels.receive",(λ (User "chan". (case Req#73mje.1c2#7 1 (Var User "chan") of [MatchCase Constructor #9f58i 0 [Var,Unbound] Nothing (User "a". (Var User "a"))]))),(User "a". #73mje.0c2 (Var User "a") -> ({[#73mje.1c2]} Var User "a")))]], watchComponents = [], hashTermsId = fromList [(User "Channel.id",(#daun9,Nothing,(λ (User "channel". (case Var User "channel" of [MatchCase Constructor #73mje.0c2 0 [Var,Unbound] Nothing (User "id". (Var User "id"))]))),(User "a". #73mje.0c2 (Var User "a") -> ({[]} #alf3o)))),(User "Channel.id.modify",(#8neha,Nothing,(λ (User "f". (λ (User "channel". (case Var User "channel" of [MatchCase Constructor #73mje.0c2 0 [Var,Var] Nothing (User "id". (User "location". (Con#73mje.0c2#0 ((Var User "f") (Var User "id")) (Var User "location"))))]))))),(User "g". (User "a". (User "a"-1. (#alf3o -> (({[Var User "g"]} #alf3o))) -> ({[]} #73mje.0c2 (Var User "a"-1) -> ({[Var User "g"]} #73mje.0c2 (Var User "a")))))))),(User "Channel.id.set",(#gnsvq,Nothing,(λ (User "id1". (λ (User "channel". (case Var User "channel" of [MatchCase Constructor #73mje.0c2 0 [Unbound,Var] Nothing (User "location". (Con#73mje.0c2#0 (Var User "id1") (Var User "location")))]))))),(User "a". (User "a"-1. #alf3o -> ({[]} #73mje.0c2 (Var User "a"-1) -> ({[]} #73mje.0c2 (Var User "a"))))))),(User "Channel.location",(#9i9g4,Nothing,(λ (User "channel". (case Var User "channel" of [MatchCase Constructor #73mje.0c2 0 [Unbound,Var] Nothing (User "location". (Var User "location"))]))),(User "a". #73mje.0c2 (Var User "a") -> ({[]} #e5bcj ({[#73mje.1c2]}))))),(User "Channel.location.modify",(#cdlk7,Nothing,(λ (User "f". (λ (User "channel". (case Var User "channel" of [MatchCase Constructor #73mje.0c2 0 [Var,Var] Nothing (User "id". (User "location". (Con#73mje.0c2#0 (Var User "id") ((Var User "f") (Var User "location")))))]))))),(User "g". (User "a". (User "a"-1. (#e5bcj ({[#73mje.1c2]}) -> (({[Var User "g"]} #e5bcj ({[#73mje.1c2]})))) -> ({[]} #73mje.0c2 (Var User "a"-1) -> ({[Var User "g"]} #73mje.0c2 (Var User "a")))))))),(User "Channel.location.set",(#tln8i,Nothing,(λ (User "location1". (λ (User "channel". (case Var User "channel" of [MatchCase Constructor #73mje.0c2 0 [Var,Unbound] Nothing (User "id". (Con#73mje.0c2#0 (Var User "id") (Var User "location1")))]))))),(User "a". (User "a"-1. #e5bcj ({[#73mje.1c2]}) -> ({[]} #73mje.0c2 (Var User "a"-1) -> ({[]} #73mje.0c2 (Var User "a"))))))),(User "Channels.broadcast",(#1j3b1,Nothing,(λ (User "a". (λ (User "cs". (let Ref(#a24n6) (Ref(#sl4v9) (Var User "a")) (Var User "cs") in (User "_"-550003. Con#568rs#0)))))),(User "a". (User "g". Var User "a" -> ({[Var User "g"]} ##Sequence (#73mje.0c2 (Var User "a")) -> ({[#73mje.1c2]} #568rs)))))),(User "Channels.receive",(#8l4lf,Nothing,(λ (User "chan". (case Req#73mje.1c2#7 1 (Var User "chan") of [MatchCase Constructor #9f58i 0 [Var,Unbound] Nothing (User "a". (Var User "a"))]))),(User "a". #73mje.0c2 (Var User "a") -> ({[#73mje.1c2]} Var User "a")))),(User "Channels.receiveUntil",(#kcko8,Nothing,(λ (User "f". (λ (User "b". (λ (User "chan". (let Ref(#8l4lf) (Var User "chan") in (User "a". (case (Var User "f") (Var User "b") (Var User "a") of [MatchCase Constructor #5islt 0 [] Nothing (Var User "b"),MatchCase Constructor #5islt 1 [Var] Nothing (User "b". (Ref(#kcko8) (Var User "f") (Var User "b") (Var User "chan")))]))))))))):(User "a". (User "b". (Var User "b" -> (Var User "a" -> #5islt (Var User "b"))) -> Var User "b" -> #73mje.0c2 (Var User "a") -> ({[#73mje.1c2]} Var User "b"))),(User "a". (User "b". (Var User "b" -> (({[]} (Var User "a" -> (({[]} #5islt (Var User "b"))))))) -> ({[]} Var User "b" -> ({[]} #73mje.0c2 (Var User "a") -> ({[#73mje.1c2]} Var User "b"))))))),(User "Channels.send",(#sl4v9,Nothing,(λ (User "a". (λ (User "c". Req#73mje.1c2#5 [Var User "a"] (Var User "c"))))),(User "a". (User "g". Var User "a" -> ({[Var User "g"]} #73mje.0c2 (Var User "a") -> ({[#73mje.1c2]} #568rs)))))),(User "Channels.sendUnconfirmed",(#hqea8,Nothing,(λ (User "a". (λ (User "c". Req#73mje.1c2#6 [Var User "a"] (Var User "c"))))),(User "a". (User "g". Var User "a" -> ({[Var User "g"]} #73mje.0c2 (Var User "a") -> ({[#73mje.1c2]} #568rs))))))]}, extraDefinitions = SlurpComponent {types = fromList [], terms = fromList []}, adds = SlurpComponent {types = fromList [User "failure.Channel.UnknownChannel"], terms = fromList []}, duplicates = SlurpComponent {types = fromList [], terms = fromList []}, collisions = SlurpComponent {types = fromList [], terms = fromList []}, conflicts = SlurpComponent {types = fromList [], terms = fromList []}, updates = SlurpComponent {types = fromList [User "Channel",User "Channels"], terms = fromList [User "Channel.id",User "Channel.id.modify",User "Channel.id.set",User "Channel.location",User "Channel.location.modify",User "Channel.location.set",User "Channels.broadcast",User "Channels.receiveUntil"]}, termExistingConstructorCollisions = fromList [], constructorExistingTermCollisions = fromList [], termAlias = fromList [], typeAlias = fromList [], defsWithBlockedDependencies = SlurpComponent {types = fromList [], terms = fromList []}}
ChrisPenner commented 2 years ago

After much digging, it seems like at least on issue here is that we're not properly handling the case where an ability constructor is being pullout out into a term by the same name while ALSO updating the ability at the same time.

With this info I should be able to make a smaller reproduction to add as a regression test and then we can go about fixing it 👍🏼

aryairani commented 2 years ago

Thanks @ChrisPenner!

ChrisPenner commented 2 years ago

Here's a more minimalist reproduction, I'll dig into the best way to fix it next.

# Regression test for updates which conflict with an existing ability constructor

https://github.com/unisonweb/unison/issues/2786

```ucm:hide
.builtins> builtins.mergeio
```

First we add an ability to the codebase.
Note that this will create the name `Channels.send` as an ability constructor.

```unison
  unique ability Channels where
    send : a -> {Channels} ()
```

```ucm
.ns> add
```

Now we update the ability, changing the name of the constructor, _but_, we simultaneously
add a new top-level term with the same name as the constructor which is being
removed from Channels.

```unison
unique ability Channels where
  sends : [a] -> {Channels} ()

Channels.send : a -> {Channels} ()
Channels.send a = sends [a]

thing : '{Channels} ()
thing _ = send 1
```

The 'update' will succeed up until it tries to resolve the reference to `send`
within `thing`; because the old send is deleted and the new `send` isn't ever added.

```ucm:error
.ns> update
```

This transcript crashes with:

  Running the provided transcript file...

⚙️   Processing stanza 9 of 9.ucm: DatabaseIntegrityError (NoObjectForPrimaryHashId (HashId 460))
CallStack (from HasCallStack):
  error, called at src/Unison/Codebase/SqliteCodebase.hs:956:29 in unison-parser-typechecker-0.0.0-He2Hp1llokT2nN4MnUfUXz:Unison.Codebase.SqliteCodebase
ChrisPenner commented 2 years ago

Mergify bot is a bit over-eager haha.

aryairani commented 2 years ago

Hehe yeah. Github reacted to the phrase "fix #2786" in the description of #2798, and then blamed mergify bot by virtue of having executed the merge.

aryairani commented 2 years ago

Is this accidentally "Awaiting Review"? or how can I review it? :)

ChrisPenner commented 2 years ago

@aryairani It's waiting for a review on its paired PR: #2814 . 😄

ChrisPenner commented 2 years ago

Resolved in #2814