I think I've traced this down to be simpler than expected... We're currently using a file lock on ContainersConfig.json after opening it, so we can get into a situation where we:
1. Open file for writing (clears file)
2. Lock file
3. Open file for reading (so it's an empty file)
4. Wait for file to unlock
5. Write finishes - unlock file
6. Read unblocked, still has an empty file
The solution seems to be to attempt to reopen the file if we don't successfully get the lock.
I think I've traced this down to be simpler than expected... We're currently using a file lock on ContainersConfi g.json after opening it, so we can get into a situation where we:
1. Open file for writing (clears file)
2. Lock file
3. Open file for reading (so it's an empty file)
4. Wait for file to unlock
5. Write finishes - unlock file
6. Read unblocked, still has an empty file
The solution seems to be to attempt to reopen the file if we don't successfully get the lock.