Fix concurrency bug in MemoryCommandStateProvider