From fd78a8ebed24ed02f2056fcf0dfee9d25214788d Mon Sep 17 00:00:00 2001 From: Cyril Galibern Date: Sat, 26 Sep 2026 01:58:01 +0200 Subject: [PATCH 1/2] [worker] Fix hbmon_log_last end extension query HBLogLastExtend built an invalid query: the IN list was missing its opening parenthesis. Its args slice was also created with length 3*len(l) and then appended to, so 3*len(l) nil values came before the real values. Without the fix, the hbmon_log_last end timestamp was never extended. --- cdb/db_heartbeat.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cdb/db_heartbeat.go b/cdb/db_heartbeat.go index 4160af78..65911b85 100644 --- a/cdb/db_heartbeat.go +++ b/cdb/db_heartbeat.go @@ -224,8 +224,8 @@ func (oDb *DB) HBLogLastExtend(ctx context.Context, l ...*DBHeartbeatLog) error } placeholders := strings.Repeat("(?,?,?),", len(l)-1) + "(?,?,?)" - query := fmt.Sprintf("UPDATE `hbmon_log_last` SET `end` = NOW() WHERE (`node_id`,`peer_node_id`,`name`) IN %s)", placeholders) - args := make([]any, 3*len(l)) + query := fmt.Sprintf("UPDATE `hbmon_log_last` SET `end` = NOW() WHERE (`node_id`,`peer_node_id`,`name`) IN (%s)", placeholders) + args := make([]any, 0, 3*len(l)) for _, v := range l { args = append(args, v.NodeID, v.PeerNodeID, v.Name) } From 3d1e66a04fdbd9496cd8bb146f4d8525133c8ed9 Mon Sep 17 00:00:00 2001 From: Cyril Galibern Date: Sat, 26 Sep 2026 01:58:30 +0200 Subject: [PATCH 2/2] [worker] Don't reassign resmon unique key columns on duplicate ResmonUpdate's ON DUPLICATE KEY UPDATE reassigned svc_id, node_id, vmname and rid. The duplicate can only come from uk_resmon_1, which is made of these columns, so they already match. Drop the redundant assignments. --- cdb/db_resources.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdb/db_resources.go b/cdb/db_resources.go index f162fcfe..5f4a0cd7 100644 --- a/cdb/db_resources.go +++ b/cdb/db_resources.go @@ -415,7 +415,7 @@ func (oDb *DB) ResmonUpdate(ctx context.Context, l ...*DBInstanceResource) error insertColList = "(`svc_id`,`node_id`,`vmname`,`rid`,`res_status`,`res_type`,`res_log`,`res_desc`,`res_optional`,`res_disable`,`res_monitor`, `changed`, `updated`)" valueList = "(?,?,?,?,?,?,?,?,?,?,?,?,NOW())" onDuplicateAssignment = "" + - "`svc_id`=VALUES(`svc_id`), `node_id`=VALUES(`node_id`), `vmname`=VALUES(`vmname`), `rid`=VALUES(`rid`), `res_status`=VALUES(`res_status`)," + + "`res_status`=VALUES(`res_status`)," + "`res_type`=VALUES(`res_type`), `res_log`=VALUES(`res_log`), `res_desc`=VALUES(`res_desc`), `res_optional`=VALUES(`res_optional`)," + "`res_disable`=VALUES(`res_disable`), `res_monitor`=VALUES(`res_monitor`),`changed`=VALUES(`changed`),`updated`=VALUES(`updated`)" )