tidwall / redcon

Redis compatible server framework for Go
MIT License
2.19k stars 158 forks source link

fix: race condition in initialisation of server #62

Closed tomarrell closed 1 year ago

tomarrell commented 1 year ago

During the initialisation of the server, there are unprotected writes. If the server is closed quickly enough, the writes will race against the closing reads.

This PR acquires locks before writing to the server during initialisation.

This appears rarely and on slow, single core runners such as CI. https://github.com/tomarrell/miniqueue/actions/runs/3968262794/jobs/6801201158

tomarrell commented 1 year ago

I've also intentionally locked only the assignments, as the returned serve(...) call also acquires the same lock.

tidwall commented 1 year ago

LGTM. Thanks :)