CA-106403: A timed out connection on writedb must be closed too

Also contains another fix related to redo_log: The DB should be locked before being flushed on redo_log.