Ad Widget

Collapse

ERROR: duplicate key value violates unique constraint "sysmaps_elements_pkey"

Collapse
This topic has been answered.
X
X
 
  • Time
  • Show
Clear All
new posts
  • riyadamine
    Junior Member
    • Sep 2023
    • 1

    #1

    ERROR: duplicate key value violates unique constraint "sysmaps_elements_pkey"

    Dears;

    Please can anyone for this issue, i get an error when i try to add item to new map or existed map for Zabbix 5.4 using PostgresDB??


    May 25 12:24:04 zabbix-server postgres[81683]: [7-1] 2023-05-25 12:24:04.184 CET [81683] ERROR: duplicate key value violates unique constraint "sysmaps_elements_pkey"
    May 25 12:24:04 zabbix-server postgres[81683]: [7-2] 2023-05-25 12:24:04.184 CET [81683] DETAIL: Key (selementid)=(1000) already exists.
    May 25 12:24:04 zabbix-server postgres[81683]: [7-3] 2023-05-25 12:24:04.184 CET [81683] STATEMENT: INSERT INTO sysmaps_elements (selementid,elementtype,iconid_off,label,label_loc ation,x,y,use_iconmap,evaltype,sysmapid) VALUES ('1000','4','151','New element','-1','341','86','1','0','27')


    Best Regards.
    Riyad.​
  • Answer selected by riyadamine at 09-10-2023, 19:19.
    cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4806

    Code:
    update ids set nextid = 1399 where table_name= 'sysmaps_elements';
    or something like that...

    Comment


    • riyadamine
      riyadamine commented
      Editing a comment
      cyber many thanks for your help
  • vijayk
    Senior Member
    • May 2023
    • 305

    #2
    Error shows that Key is already in used in same template or host.
    DETAIL: Key (selementid)=(1000) already exists.

    Please check the items.

    Comment


    • riyadamine
      riyadamine commented
      Editing a comment
      Please how can I check the items? can you help me? Do you mean I check it on the Database
  • vijayk
    Senior Member
    • May 2023
    • 305

    #3
    No, you have to check it in template which you assigned to host.

    Comment

    • cyber
      Senior Member
      Zabbix Certified SpecialistZabbix Certified Professional
      • Dec 2006
      • 4806

      #4
      Originally posted by vijayk
      No, you have to check it in template which you assigned to host.
      OP has issues with adding an element to map and you suggest to look for items in template? Can you just stop talking nonsense? If you give advice, at least follow it and elaborate, what should be looked up and what for?

      Comment

      • vijayk
        Senior Member
        • May 2023
        • 305

        #5
        Originally posted by cyber

        OP has issues with adding an element to map and you suggest to look for items in template? Can you just stop talking nonsense? If you give advice, at least follow it and elaborate, what should be looked up and what for?
        My bad. I'm giving support to another queries and I have open multiple tabs to might be placing wrong talk here. Thanks cyber for correct.

        Comment

        • vijayk
          Senior Member
          • May 2023
          • 305

          #6
          Originally posted by riyadamine
          Dears;

          Please can anyone for this issue, i get an error when i try to add item to new map or existed map for Zabbix 5.4 using PostgresDB??


          May 25 12:24:04 zabbix-server postgres[81683]: [7-1] 2023-05-25 12:24:04.184 CET [81683] ERROR: duplicate key value violates unique constraint "sysmaps_elements_pkey"
          May 25 12:24:04 zabbix-server postgres[81683]: [7-2] 2023-05-25 12:24:04.184 CET [81683] DETAIL: Key (selementid)=(1000) already exists.
          May 25 12:24:04 zabbix-server postgres[81683]: [7-3] 2023-05-25 12:24:04.184 CET [81683] STATEMENT: INSERT INTO sysmaps_elements (selementid,elementtype,iconid_off,label,label_loc ation,x,y,use_iconmap,evaltype,sysmapid) VALUES ('1000','4','151','New element','-1','341','86','1','0','27')


          Best Regards.
          Riyad.​
          cyber could you please help here?

          Comment

          • cyber
            Senior Member
            Zabbix Certified SpecialistZabbix Certified Professional
            • Dec 2006
            • 4806

            #7
            I can only guess... There can be mismatch in DB. There is a table called "ids", which contains different used ID-s for different tables and fields.
            Code:
            select nextid from ids where table_name= 'sysmaps_elements';
            this should return the same value as
            Code:
            select selementid from sysmaps_elements order by selementid desc limit 1;
            If not, then you might try to update that ids table manually and set correct value there... but I am just guessing here.

            Comment


            • riyadamine
              riyadamine commented
              Editing a comment
              I checked as you suggested but the value was not the same

              zabbix=# select nextid from ids where table_name= 'sysmaps_elements';
              nextid
              --------
              999
              (1 row)

              zabbix=# select selementid from sysmaps_elements order by selementid desc limit 1;
              selementid
              ------------
              1399
              (1 row)


              How can I update it manually and if there is a risk to do that?

            • riyadamine
              riyadamine commented
              Editing a comment
              cyber could you please help here?

            • riyadamine
              riyadamine commented
              Editing a comment
              cyber can you help me please ?
          • cyber
            Senior Member
            Zabbix Certified SpecialistZabbix Certified Professional
            • Dec 2006
            • 4806

            #8
            Code:
            update ids set nextid = 1399 where table_name= 'sysmaps_elements';
            or something like that...

            Comment

          • frankt
            Junior Member
            • Mar 2024
            • 2

            #9
            Hi,

            We had a similar issue. I've written a script to check/repair the issue. You can find it in this post: https://www.zabbix.com/forum/zabbix-...or-key-primary

            Regard,
            /Frank

            Comment

            Working...