When an error occurred, the log would be written to the database, but the transaction would then be rolled back, causing the log to disappear. This adds explicit commit to the log when handling error cases. This fixes #6538