backend: Fix data race #322