Merge "Add sanity check to getScopedLockAndFlush() for pending writes"