From: akuzm (@akuzm) <noreply+akuzm@github.com>
To: pgaudit/pgaudit <noreply+pgaudit-pgaudit@github.com>
Subject: Re: [pgaudit/pgaudit] issue #300: Severe performance degradation when enabling pgaudit (ddl,role only) under high insert load
Date: Mon, 10 Aug 2026 14:56:02 +0000
Message-ID: <gh-pgaudit-pgaudit-300-c5241983952@github.com> (raw)
In-Reply-To: <gh-pgaudit-pgaudit-300@github.com>
References: <gh-pgaudit-pgaudit-300@github.com>
> > unless pgaudit goes first in the hook call sequence
>
> It doesn't expect to run first, it just expects the hook chain to be honored.
But what does this mean exactly? The errors in question happen when another extension calls ExecCheckPermission from its ProcessUtility hook, without calling the pgaudit ProcessUtility hook first. I don't understand what protocol could avoid this, save for calling pgaudit first. "Honoring the call chain" sounds too generic, e.g. calling the pgaudit ProcessUtility hook last doesn't prevent the error. TimescaleDB doesn't call it at all, because it's unclear how to chain an alternative implementation of COPY to some other hooks, but that's not the immediate cause of this problem.
> That said, the improvements in the linked PR may help as long as pgAudit is not configured to audit anything that requires the ExecCheckPermissions hook. We were not planning to back patch this but if you can demonstrate that it prevents conflicts with other extensions (e.g. TimescaleDB) then we'll likely reconsider.
In my testing, the PR https://github.com/pgaudit/pgaudit/pull/325 avoids the error with `pgaudit.log = 'ddl, role'`, so I think backporting it could improve the situation. Not sure if it's worth the effort by itself, because the case with `pgaudit.log = write` would still need another workaround.
On TimescaleDB side, I'm considering to make the hook order depend on the order in `shared_preload_libraries`. At least this will give an easy workaround, because at the moment our hook always ends up first. Unfortunately this change is not very clear-cut since it's a multi-library extension with dynamic loading.