3

Is there any way to suppress a specific warning in the postgresql log output?

Basically, I have an application that often does a spurious commit before beginning database operations, and it's leading to thousands of messages in the output of:

2018-12-02 01:37:22 PST [5147-152] <user>@<database> WARNING:  there is no transaction in progress

I realize this isn't an ideal situation, but everything seems to be working otherwise, but the logs are getting hugely cluttered with this specific warning.

How can I prevent postgresql from emitting this one, specific warning? I don't want to disable warnings entirely, because I do like to check for any other warnings.

1
3

There is no way to suppress a specific message. You can change "log_min_messages" to suppress logging of the entire class of WARNING messages, which you pointed out you don't want to do. But you can target a bit more specifically by using ALTER USER ... IN DATABASE ... SET LOG_MIN_MESSAGES ... to do this just for one specific user and database, if that helps you.

If you want to target more finely than that, and you are willing to compile your own PostgreSQL to do it, you could easily modify the source code to demote this specific message from a WARNING to a NOTICE (or lower), but that is a pretty heavy-handed approach. There are two different places in the source that produce this message for COMMIT, and I'm not sure which one would apply to you.

Other than that, using log mining tools which can be configured to ignore these messages may be your best option.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.