The pg_dbms_errlog v2.4 extension has been released, providing PostgreSQL with DBMS_ERRLOG compatibility. This extension allows DML operations to continue after encountering errors by logging them to an error table, avoiding full rollbacks. It relies on pg_statement_rollback or manual SAVEPOINT management, and uses dynamic shared memory and a background worker to queue and write errors asynchronously.
Key changes in v2.3 and v2.4:
- PostgreSQL 18 and 19 support: The extension is now compatible with the latest PostgreSQL versions.
- Two major bug fixes: Detailed in the changelog, these fix critical issues that could cause crashes or data corruption under certain workloads.
- New GUC
pg_dbms_errlog.synchronous: Controls error logging mode – can beoff(default, asynchronous via background worker) oron(synchronous, registered at query level or at transaction end). This gives developers flexibility between performance and immediate error persistence. - Configuration requirement:
max_worker_processesmust be set high enough to accommodate up topg_dbms_errlog.max_workersdynamic background workers plus one fixed worker.
For developers, these updates ensure the extension works with the latest PostgreSQL releases and addresses stability concerns. The new synchronous logging option is particularly valuable for applications that require error logs to be committed within the same transaction, simplifying debugging and data consistency. By enabling graceful error handling in batch DML operations, pg_dbms_errlog reduces the need for complex error-handling logic in application code. Always check the full changelog for migration steps, as the bug fixes may affect existing setups.
Source: https://www.postgresql.org/about/news/pg_dbms_errlog-v24-released-3331/