gwillen / herring

Modern Django and ReactJS based web application for puzzlehunt team management!
MIT License
7 stars 4 forks source link

Race condition when creating round with puzzles / multiple puzzles at once #24

Open gwillen opened 3 years ago

gwillen commented 3 years ago

At least, I suspect a race condition. If you try, the puzzle channel will not be created (n=1). Later channels in the same round work fine.

Presumably cleanup_channels would fix this, but since it's a wildly destructive operation I can't safely run it. Perhaps we need a safe version, which only ever creates channels, and does not delete them?

(Of course it should probably also retry creation if it fails.)

Zahariel commented 3 years ago

I pushed a fix for this to zahariel/master, maybe. It's not very straightfoward to test right now, if it ever was.

If you're nervous about cleanup_channels it does have a dry run mode that just tells you that it plans to do anything potentially destructive, instead of actually doing it.

gwillen commented 3 years ago

Editing this to reflect my current understanding, but there is definitely still some kind of race or issue (and for whatever reason it doesn't necessarily even seem to retry when it should.)

I was able to repro by creating a round with four puzzles in it -- puzzles 2 and 4 worked, 1 and 3 did not (the puzzles were created in the database, but the channels AND THE SHEET were not created.)

This is pretty bad, since it's easyish to fix missing channels, but fixing a missing sheet is very hard, and entering multiple puzzles at once is very typical for us.