Re: Can we exclude errors of some particular text in Postgres log file? - Mailing list pgsql-admin

From Keith
Subject Re: Can we exclude errors of some particular text in Postgres log file?
Date
Msg-id CAHw75vsYG8XM=Peg0Pz17dacDKgdSRhPq0p0kyy8bpGuHNzeTg@mail.gmail.com
Whole thread Raw
In response to Re: Can we exclude errors of some particular text in Postgres logfile?  (pavan95 <pavan.postgresdba@gmail.com>)
Responses Re: Can we exclude errors of some particular text in Postgres logfile?
List pgsql-admin


On Sat, Sep 1, 2018 at 6:14 AM, pavan95 <pavan.postgresdba@gmail.com> wrote:
Hi Team,

Can we exclude errors of a particular type from the postgres log file ?

For example:
ERROR:  duplicate key value violates unique constraint "table_uniq"
DETAIL:  Key (column1, column2, column3)=(value0, value1, 1) already exists.

If yes, how can we exclude this errors from the pg_log files. Suggest me an
approach.

Thanks in Advance.

Regards,
Pavan





--
Sent from: http://www.postgresql-archive.org/PostgreSQL-admin-f2076596.html



I suggest upgrading to at least PostgreSQL 9.5 if you haven't already and look into the INSERT...ON CONFLICT feature (also called UPSERT). With it you can define what happens if an insert would violate a defined constraint and instead update the given row, do nothing or a wide variety of other operations.


If this doesn't fit the model that is causing your duplicate key errors, you may want to look into using a function to do your writes instead and catch the given error in an exception block and then just ignore it.

Keith

pgsql-admin by date:

Previous
From: Tom Lane
Date:
Subject: Re: pg_dump and disk full
Next
From: "David G. Johnston"
Date:
Subject: Re: Can we exclude errors of some particular text in Postgres log file?