Fix locking code on error path.
update
Verify we never write an empty page.