Ad Widget

Collapse

Zabbix DB update error - Duplicate entry

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • markfree
    Senior Member
    • Apr 2019
    • 868

    #1

    Zabbix DB update error - Duplicate entry

    I was upgrading a Zabbix 5.0 Server to 5.4 and, while upgrading the MySQL 8 DB, I got the error bellow.

    Code:
    24405:20211130:094557.302 Starting Zabbix Server. Zabbix 5.4.8 (revision 65b505c463).
    24405:20211130:094557.302 ****** Enabled features ******
    24405:20211130:094557.302 SNMP monitoring: YES
    24405:20211130:094557.302 IPMI monitoring: NO
    24405:20211130:094557.302 Web monitoring: YES
    24405:20211130:094557.302 VMware monitoring: YES
    24405:20211130:094557.302 SMTP authentication: YES
    24405:20211130:094557.302 ODBC: NO
    24405:20211130:094557.302 SSH support: YES
    24405:20211130:094557.302 IPv6 support: YES
    24405:20211130:094557.302 TLS support: YES
    24405:20211130:094557.302 ******************************
    24405:20211130:094557.302 using configuration file: /usr/local/etc/zabbix_server.conf
    24405:20211130:094557.347 current database version (mandatory/optional): 05000000/05000004
    24405:20211130:094557.347 required mandatory version: 05040000
    24405:20211130:094557.347 optional patches were found
    24405:20211130:094557.347 starting automatic database upgrade
    24405:20211130:094557.413 completed 0% of database upgrade
    24405:20211130:094557.551 completed 1% of database upgrade
    24405:20211130:094557.615 completed 2% of database upgrade
    24405:20211130:094557.715 completed 3% of database upgrade
    24405:20211130:094557.805 completed 4% of database upgrade
    24405:20211130:094557.918 completed 5% of database upgrade
    24405:20211130:094557.996 completed 6% of database upgrade
    24405:20211130:094558.083 completed 7% of database upgrade
    24405:20211130:094558.190 completed 8% of database upgrade
    24405:20211130:094558.273 completed 9% of database upgrade
    24405:20211130:094558.409 completed 10% of database upgrade
    24405:20211130:094558.598 completed 11% of database upgrade
    24405:20211130:094558.778 completed 12% of database upgrade
    24405:20211130:094559.174 completed 13% of database upgrade
    24405:20211130:094559.363 completed 14% of database upgrade
    24405:20211130:094559.712 completed 15% of database upgrade
    24405:20211130:094559.910 completed 16% of database upgrade
    24405:20211130:094600.495 completed 17% of database upgrade
    24405:20211130:094600.981 completed 18% of database upgrade
    24405:20211130:094601.160 completed 19% of database upgrade
    24405:20211130:094601.449 completed 20% of database upgrade
    24405:20211130:094601.676 completed 21% of database upgrade
    24405:20211130:094601.817 completed 22% of database upgrade
    24405:20211130:094602.150 completed 23% of database upgrade
    24405:20211130:094602.513 completed 24% of database upgrade
    24405:20211130:094602.725 completed 25% of database upgrade
    24405:20211130:094602.914 completed 26% of database upgrade
    24405:20211130:094603.215 completed 27% of database upgrade
    24405:20211130:094603.308 completed 28% of database upgrade
    24405:20211130:094604.009 completed 29% of database upgrade
    24405:20211130:094604.685 completed 30% of database upgrade
    24405:20211130:094606.022 completed 31% of database upgrade
    24405:20211130:094607.076 completed 32% of database upgrade
    24405:20211130:094608.301 completed 33% of database upgrade
    24405:20211130:094609.032 completed 34% of database upgrade
    24405:20211130:094609.531 completed 35% of database upgrade
    24405:20211130:094609.760 completed 36% of database upgrade
    24405:20211130:094609.960 completed 37% of database upgrade
    24405:20211130:094610.219 completed 38% of database upgrade
    24405:20211130:094610.382 completed 39% of database upgrade
    24405:20211130:094610.515 completed 40% of database upgrade
    24405:20211130:094610.752 completed 41% of database upgrade
    24405:20211130:094610.920 completed 42% of database upgrade
    24405:20211130:094611.385 [Z3005] query failed: [1062] Duplicate entry '110-false' for key 'valuemap_mapping.valuemap_mapping_1' [insert into valuemap_mapping (valuemap_mappingid,valuemapid,value,newvalue) values
    (...)
    (2013,109,'25','newLogDrvKeyRekeyRequestReceived') ,
    (2014,110,'False','0'),
    (2015,110,'false','0'),
    (2016,110,'True','1'),
    (2017,110,'true','1'),
    (2018,111,'1','ok'),
    (...)
    Any idea how to solve that?
    Last edited by markfree; 30-11-2021, 16:23.
  • markfree
    Senior Member
    • Apr 2019
    • 868

    #2
    I ran a check but there was no issues.
    Code:
    # mysqlcheck --auto-repair=true -u -p [zabbix_db]
    OK

    When I select valuemap table, it shows empty sets, but valuemaps.
    Code:
    mysql> select * from valuemap;
    Empty set (0.00 sec)
    
    mysql> select * from valuemap_mapping;
    Empty set (0.00 sec)
    
    mysql> select * from valuemaps;
    +------------+-----------------------------------------------------------------+
    | valuemapid | name |
    +------------+-----------------------------------------------------------------+
    | 4 | APC Battery Replacement Status |
    | 5 | APC Battery Status |
    | 77 | Boolean |
    (...)
    +------------+-----------------------------------------------------------------+
    91 rows in set (0.00 sec)

    I think the issue might be related to this value mapping
    Boolean
    False ⇒ 0
    false ⇒ 0
    true ⇒ 1
    True ⇒ 1

    Comment

    • tim.mooney
      Senior Member
      • Dec 2012
      • 1427

      #3
      You are correct, the issue is related to those. It's not a database corruption issue, it's with older values that do not comply with your updated schema.

      In some collations, including utf8_bin, they are the same. Hence the duplicate entry.

      I'm not sure where the two sets of value maps for true/True and false/False came from, but if you have an idea what items might have been using them, you probably need to decide which pair you get rid of (either True and False or true and false). I don't know where they came from, so it's hard to advise which ones should be deleted, but my suspicious is that it doesn't really matter which ones you get rid of.

      If you're afraid to get rid of them, what you could do instead is rename one set of them, to something like "Duplicate_False" and "Duplicate_True". You'll have to find a way to uniquely identify them, but it looks like there might be a unique id you can use to select them.

      Comment


      • markfree
        markfree commented
        Editing a comment
        I haven't figured out how to identify these values yet, but I'm looking into this.
    Working...