pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tomas Vondra <tv@fuzzy.cz>
To: tigran.mkrtchyan@desy.de
Cc: Tomas Vondra <tv@fuzzy.cz>
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #6300: duplicate key value violates unique constraint
Date: Fri, 18 Nov 2011 21:52:33 +0100
Message-ID: <f6ebad3e6abf5376532df2784aec4bc6.squirrel@sq.gransy.com> (raw)
In-Reply-To: <CAGue13rJxCjN1+jamnL4qBGopN=hP6nj4SG5tVgVhvTxz1UH4g@mail.gmail.com>
References: <201111181642.pAIGgaLY007885@wwwmaster.postgresql.org>
	<2e0d250ae01ece58a2c387f52f3121fc.squirrel@sq.gransy.com>
	<CAGue13rJxCjN1+jamnL4qBGopN=hP6nj4SG5tVgVhvTxz1UH4g@mail.gmail.com>

On 18 Listopad 2011, 20:38, Tigran Mkrtchyan wrote:
> On Fri, Nov 18, 2011 at 6:52 PM, Tomas Vondra <tv@fuzzy.cz> wrote:
>> On 18 Listopad 2011, 17:42, Tigran Mkrtchyan wrote:
>>>
>>> The following bug has been logged online:
>>>
>>> Bug reference:      6300
>>> Logged by:          Tigran Mkrtchyan
>>> Email address:      tigran.mkrtchyan@desy.de
>>> PostgreSQL version: 9.0.4
>>> Operating system:   Linux x86_64
>>> Description:        duplicate key value violates unique constraint
>>> Details:
>>>
>>> Hi,
>>>
>>> our application uses PostgreSQL as a backend and heavily
>>> relays on transactions. We never check constrains in our application as
>>> DB
>>> does is better than we can an in an atomic way. This works very-very
>>> good!
>>> Nevertheless the logfiles are full of 'duplicate key value violates
>>> unique
>>> constraint'. I have two questions:
>>
>> If it's a question, then why have you submitted it as a bug?
>
> Then let me re-phrase it:
>
> I think it's a bug to log with level ERROR absolute valid SQL
> statement. You have error code returned to the client to handle it. If
> I want to log statements then I can turned that on.  This is client
> appication debuggging and to error handling.

The SQL command may be syntactically correct, but breaking a UNIQUE
constraint is an error condition and therefore it's handled like an error
condition - the user receives an exception and a message with ERROR level
is written to the log.

If you don't want to see those messages in the log, there are ways to do
that correctly - e.g. by using database sequences. I personally think that
an application that generates significant amount of "duplicate values"
during normal operation is somehow broken.

Anyway this definitely is not a bug, so if you want to discuss it further
(and how to fix you application), use pgsql-general mailing list.

Tomas




view thread (14+ messages)  latest in thread

Message-ID: <f6ebad3e6abf5376532df2784aec4bc6.squirrel@sq.gransy.com>
Permalink:  ../f6ebad3e6abf5376532df2784aec4bc6.squirrel@sq.gransy.com/
Also on:    postgresql.org/message-id/f6ebad3e6abf5376532df2784aec4bc6.squirrel@sq.gransy.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tv@fuzzy.cz, tigran.mkrtchyan@desy.de
  Subject: Re: BUG #6300: duplicate key value violates unique constraint
  In-Reply-To: <f6ebad3e6abf5376532df2784aec4bc6.squirrel@sq.gransy.com>
  References: <201111181642.pAIGgaLY007885@wwwmaster.postgresql.org> <2e0d250ae01ece58a2c387f52f3121fc.squirrel@sq.gransy.com> <CAGue13rJxCjN1+jamnL4qBGopN=hP6nj4SG5tVgVhvTxz1UH4g@mail.gmail.com> <f6ebad3e6abf5376532df2784aec4bc6.squirrel@sq.gransy.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox