Fixes for the issues identified by the thread sanitiser
Created by: mattclarke
Issue
Found as part of DM-1616
Description of work
While trying to work out what is causing the issue seen in DM-1616, we tried running the thread sanitiser to see if it showed anything. This PR fixes the issues flagged by that, I have pulled them out of the DM-1616 branch as they don't appear to be anything to do with that problem.
Nominate for Group Code Review
-
Nominate for code review