Prevent race condition in memstore.