[ZBX-11358] Cannot create new value map Created: 2016 Oct 14 Updated: 2017 May 30 Resolved: 2016 Oct 18 |
|
Status: | Closed |
Project: | ZABBIX BUGS AND ISSUES |
Component/s: | Frontend (F) |
Affects Version/s: | 3.2.0 |
Fix Version/s: | None |
Type: | Incident report | Priority: | Major |
Reporter: | Fred Blaise | Assignee: | Unassigned |
Resolution: | Incomplete | Votes: | 0 |
Labels: | valuemapping | ||
Remaining Estimate: | Not Specified | ||
Time Spent: | Not Specified | ||
Original Estimate: | Not Specified | ||
Environment: |
Centos 7, postgreSQL |
Description |
Hi, I am trying to add a valuemap, and it fails because of a duplicate key error. Below the UI's error. pg_query(): Query failed: ERROR: duplicate key value violates unique constraint "valuemaps_pkey" DETAIL: Key (valuemapid)=(19) already exists. [adm.valuemapping.php:108 ? CFrontendApiWrapper->create() ? CApiWrapper->__call() ? CFrontendApiWrapper->callMethod() ? CApiWrapper->callMethod() ? CFrontendApiWrapper->callClientMethod() ? CLocalApiClient->callMethod() ? call_user_func_array() ? CValueMap->create() ? DB::insertBatch() ? DBexecute() ? pg_query() in include/db.inc.php:530] Error in query [INSERT INTO valuemaps (name,valuemapid) VALUES ('test','19')] [ERROR: duplicate key value violates unique constraint "valuemaps_pkey" DETAIL: Key (valuemapid)=(19) already exists.] SQL statement execution has failed "INSERT INTO valuemaps (name,valuemapid) VALUES ('test','19')". Effectively, looking at the table: zabbix=# select * from valuemaps order by valuemapid;; valuemapid | name ------------+---------------------------------------- 1 | Service state 2 | Host availability 3 | Windows service state 4 | APC Battery Replacement Status 5 | APC Battery Status 6 | HP Insight System Status 7 | Dell Open Manage System Status 8 | SNMP interface status (ifOperStatus) 9 | SNMP device status (hrDeviceStatus) 10 | Zabbix agent ping status 11 | SNMP interface status (ifAdminStatus) 12 | VMware VirtualMachinePowerState 13 | VMware status 14 | Maintenance status 15 | Value cache operating mode 16 | Windows service startup type 17 | HTTP response status code 18 | 0:No, 1:Yes 19 | NetAppCfSetting 20 | NetAppCfState 21 | NetAppFcpTgtStatus 22 | NetAppFsStatus 23 | NetAppGlobalStatus 24 | NetAppLunOnline 25 | NetAppNvramBatteryStatus 26 | NetAppOverTemp 27 | NetAppRaidStatus 28 | NetAppSpareStatus 29 | NetAppVolStatus 30 | Server HP Fan 31 | Server HP Health 32 | RSS Feed 33 | SNMP Ilo 4 - Fan status 34 | SNMP Ilo 4 - Raid status 35 | SNMP Ilo 4 - Disk negotiated link rate 36 | SNMP Ilo 4 - Disk status 37 | SNMP Ilo 4 - Power supply 38 | FgVpnState 39 | fgHwSensorEntAlarmStatus 40 | F5 ltmPoolStatusAvailState 41 | NetAppcfInterconnectStatus 42 | NetAppcfPartnerStatus (42 rows) I don't know why it tries to allocate ID 19 for my new value map. I can try to update the current ID 19 to 43, and see what happens, but I am bit afraid of breaking other things while doing that. Thank you for your help. |
Comments |
Comment by Glebs Ivanovskis (Inactive) [ 2016 Oct 14 ] |
Seems like someone before you was adding value mappings into DB directly. |
Comment by Fred Blaise [ 2016 Oct 14 ] |
Any "quick" fix possible? |
Comment by dimir [ 2016 Oct 14 ] |
Looks like someone was adding valuemaps manually into the database. This is not a good idea, it's better to use Frontend or API. Could you please run select nextid from ids where table_name='valuemaps' and field_name='valuemapid'; The fix would be: update ids set nextid=(select max(valuemapid) from valuemaps) where table_name='valuemaps' and field_name='valuemapid'; |
Comment by Fred Blaise [ 2016 Oct 17 ] |
Hi, Sorry for the delay – on holidays. zabbix=# select nextid from ids where table_name='valuemaps' and field_name='valuemapid'; nextid -------- 18 (1 row) I applied your update statement; sure enough, it worked. Thank you. I don't know who would have messed up with that though... quite odd :-/ Thanks! |