Fix cache management when an error occurs during initialization.
Add regression test for log_to_postgres function.