Fixes race condition in case session list is modified during its write into file by CachedMemoryStorage