Ad Widget

Collapse

PostgreSQL Duplicate key violates unique constraint error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • c.efrein
    Junior Member
    • Nov 2012
    • 1

    #1

    PostgreSQL Duplicate key violates unique constraint error

    CentOS 6.2 64bit Server
    PostgreSQL 8.4.9 installed via yum

    I am seeing errors from time to time in PostgreSQL's logs about the table called Events.

    Zabbix is the only application using PostgreSQL.

    Here is the error:

    Code:
    INSTRUCTION :  insert into events (eventid,source,object,objectid,clock,ns,value,value_changed) values (6393428,2,3,38,1353354000,0,1,0)
    ERROR:  duplicate key violates unique constraint « events_pkey »
    There is no sequence associated with the table events

    Here is the table structure for events

    Code:
    			   Table « public.events »
    Colonne    |  Type   |          Modificateurs           | Stockage | Description 
    ---------------+---------+----------------------------------+----------+-------------
    eventid       | bigint  | non NULL                         | plain    | 
    source        | integer | non NULL Par défaut, 0           | plain    | 
    object        | integer | non NULL Par défaut, 0           | plain    | 
    objectid      | bigint  | non NULL Par défaut, (0)::bigint | plain    | 
    clock         | integer | non NULL Par défaut, 0           | plain    | 
    value         | integer | non NULL Par défaut, 0           | plain    | 
    acknowledged  | integer | non NULL Par défaut, 0           | plain    | 
    ns            | integer | non NULL Par défaut, 0           | plain    | 
    value_changed | integer | non NULL Par défaut, 0           | plain    | 
    Index :
    "events_pkey" PRIMARY KEY, btree (eventid)
    "events_1" btree (object, objectid, eventid)
    "events_2" btree (clock)
    Référencé par :
    TABLE "acknowledges" CONSTRAINT "c_acknowledges_2" FOREIGN KEY (eventid) REFERENCES events(eventid) ON DELETE CASCADE
    TABLE "alerts" CONSTRAINT "c_alerts_2" FOREIGN KEY (eventid) REFERENCES events(eventid) ON DELETE CASCADE
    Question

    What steps can I take to resolve this error?

    On Stackexchange, I have been told to add a sequence to Events, what effect would that have?

    Code:
    ALTER TABLE events ALTER COLUMN eventid TYPE bigserial;
  • Colttt
    Senior Member
    Zabbix Certified Specialist
    • Mar 2009
    • 878

    #2
    dou you create a Bugreport?!

    i think this is abug
    Debian-User

    Sorry for my bad english

    Comment

    Working...