pinano-discord / Pinano-Discord-Bot

A Discord bot for the Pinano guild
MIT License
9 stars 11 forks source link

BUG: race condition in VC auto-creation can cause unregistered room to linger #46

Closed pianiststickman closed 5 years ago

pianiststickman commented 5 years ago

We've seen this twice since the auto-creation code made it into the bot. The first time I put the code into a mutex, but that doesn't seem to have worked.

Basically the issue is that due to asynchronicity, one voiceStateUpdate event handler may call into the DB to read the list of practice rooms. Before it has a chance to create the room and update the list of practice rooms, however, another voiceStateUpdate event handler may fire and start creating a room. It now reads the DB to read the list of practice rooms. Now both event handlers add their newly created room to the list and write it back to the DB. The later update squashes the former, since both event handlers added a new room to the original list.

Difficult to get a repro on demand. Workaround is to have staff remove the rogue room, or to register it with p!settings practice_channels add and the bot will remove it when unneeded.

pianiststickman commented 5 years ago

7 April 2019: bumping the hit counter to 3.

pianiststickman commented 5 years ago

8 April 2019: hit = 4

pianiststickman commented 5 years ago

Fixed in #72