[ZBX-16955] History syncers lock each other when updating ids during maintenance Created: 2019 Nov 20  Updated: 2024 Apr 10  Resolved: 2019 Nov 22

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Server (S)
Affects Version/s: None
Fix Version/s: 4.0.15rc2, 4.4.2rc2, 5.0.0alpha1, 5.0 (plan)

Type: Problem report Priority: Trivial
Reporter: Vladislavs Sokurenko Assignee: Vladislavs Sokurenko
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by ZBX-16130 Zabbix 4.0.7 - History syncers slow w... Closed
Team: Team A
Sprint: Sprint 58 (Nov 2019)
Story Points: 0.125

 Description   

Steps:
History syncer A insert suppression for a problem and to do that it performs update of ids for table name "event_suppress".

When history syncer B will attempt to do the same it must wait for History syncer A to finish it's transaction which can take long time especially if some other syncer also is waiting, this result in error below:

[Z3005] query failed: [1205] Lock wait timeout exceeded; try restarting transaction [update ids set nextid=nextid+1 where table_name='event_suppress' and field_name='event_suppressid']
slow query: 51.120500 sec, "update ids set nextid=nextid+1 where table_name='event_suppress' and field_name='event_suppressid'"

This makes Zabbix server unusable during maintenance, ids should be cached in order to let history syncers to work in parallel.

diff --git a/src/libs/zbxdbcache/dbcache.c b/src/libs/zbxdbcache/dbcache.c
index 5614882097..5c76707418 100644
--- a/src/libs/zbxdbcache/dbcache.c
+++ b/src/libs/zbxdbcache/dbcache.c
@@ -57,7 +57,7 @@ static size_t		sql_alloc = 64 * ZBX_KIBIBYTE;
 
 extern unsigned char	program_type;
 
-#define ZBX_IDS_SIZE	8
+#define ZBX_IDS_SIZE	9
 
 #define ZBX_HC_ITEMS_INIT_SIZE	1000
 
diff --git a/src/libs/zbxdbhigh/db.c b/src/libs/zbxdbhigh/db.c
index f20676750d..8b2f51e2c4 100644
--- a/src/libs/zbxdbhigh/db.c
+++ b/src/libs/zbxdbhigh/db.c
@@ -723,7 +723,8 @@ zbx_uint64_t	DBget_maxid_num(const char *tablename, int num)
 			0 == strcmp(tablename, "dhosts") ||
 			0 == strcmp(tablename, "alerts") ||
 			0 == strcmp(tablename, "escalations") ||
-			0 == strcmp(tablename, "autoreg_host"))
+			0 == strcmp(tablename, "autoreg_host") ||
+			0 == strcmp(tablename, "event_suppress"))
 		return DCget_nextid(tablename, num);
 
 	return DBget_nextid(tablename, num);


 Comments   
Comment by Vladislavs Sokurenko [ 2019 Nov 20 ]

Fixed in:

  • pre-4.0.15rc2 3de0d33f843
  • pre-4.4.2rc2 0a1a75ff246
  • pre-5.0.0alpha1 (master) bd31f68b9e6
Comment by Aaron Whiteman [ 2019 Nov 20 ]

Oleksii, will this change also be applied to 4.2.x (I saw 4.0, 4.4, and 5.0)

Comment by Oleksii Zagorskyi [ 2019 Nov 20 ]

No, 4.2 branch is not supported anymore.
The patch is pretty trivial, I believe it can be applied to 4.2 code, if needed.

Comment by richlv [ 2019 Nov 26 ]

(1) Typo in release notes (and probably also the changelog) - "positioing".

vso thanks , this ChangeLog is however for ZBX-16815

<richlv> Oops, sorry about the mixup - got a bit lost in the open browser tabs

Generated at Sat Apr 04 06:46:11 EEST 2026 using Jira 10.3.13#10030013-sha1:56dd970ae30ebfeda3a697d25be1f6388b68a422.