From 34af6b68f0458c086c13c1c87026f168eb9d935a Mon Sep 17 00:00:00 2001 From: Cyril Galibern Date: Tue, 9 Jun 2026 17:08:00 +0200 Subject: [PATCH 1/2] [cdb:svcactions] Increase `status_log` column size to `MEDIUMTEXT` and update truncation logic - Changed `status_log` column type from `TEXT` to `MEDIUMTEXT` for handling larger logs. - Introduced new constant `MediumTextMax` for updated truncation limits in `InsertSvcAction` and `UpdateSvcAction` methods. --- cdb/constants.go | 3 ++- cdb/db_actions.go | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/cdb/constants.go b/cdb/constants.go index 70fc681..1f60758 100644 --- a/cdb/constants.go +++ b/cdb/constants.go @@ -1,5 +1,6 @@ package cdb const ( - TextMax = 65535 + TextMax = 65535 + MediumTextMax = 16777215 ) diff --git a/cdb/db_actions.go b/cdb/db_actions.go index 38f8803..77544a2 100644 --- a/cdb/db_actions.go +++ b/cdb/db_actions.go @@ -18,7 +18,7 @@ type ( `begin` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `end` datetime DEFAULT NULL, `hostid` varchar(30) DEFAULT NULL, - `status_log` text CHARACTER SET latin1 COLLATE latin1_swedish_ci DEFAULT NULL, + `status_log` mediumtext CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, `pid` varchar(32) DEFAULT NULL, `id` int(11) NOT NULL AUTO_INCREMENT, `ack` tinyint(4) DEFAULT NULL, @@ -256,10 +256,10 @@ func (oDb *DB) InsertSvcAction(ctx context.Context, a SvcAction) (int64, error) placeholders := "?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?" statusLogLen := len(a.StatusLog) - if statusLogLen > TextMax { + if statusLogLen > MediumTextMax { // Fix end svc action failed: Error 1406 (22001): Data too long for column 'status_log' at row 1 // TODO: add metrics svcactions status_log truncated with len / TextMax - a.StatusLog = a.StatusLog[:TextMax] + a.StatusLog = a.StatusLog[:MediumTextMax] } if runes := []rune(a.Command); len(runes) > maxCommandLen { @@ -306,10 +306,10 @@ func (oDb *DB) InsertSvcAction(ctx context.Context, a SvcAction) (int64, error) func (oDb *DB) UpdateSvcAction(ctx context.Context, a SvcAction) error { const query = `UPDATE svcactions SET end = ?, status = ?, time = TIMESTAMPDIFF(SECOND, begin, ?), status_log = ? WHERE id = ?` statusLogLen := len(a.StatusLog) - if statusLogLen > TextMax { + if statusLogLen > MediumTextMax { // Fix end svc action failed: Error 1406 (22001): Data too long for column 'status_log' at row 1 // TODO: add metrics svcactions status_log truncated with len / TextMax - a.StatusLog = a.StatusLog[:TextMax] + a.StatusLog = a.StatusLog[:MediumTextMax] } result, err := oDb.ExecContext(ctx, query, a.EndAt, a.Status, a.EndAt, a.StatusLog, a.ID) if err != nil { From 32dc4474caacf1cf6e2db9f22c4a21ac246a4b78 Mon Sep 17 00:00:00 2001 From: Cyril Galibern Date: Tue, 9 Jun 2026 17:08:35 +0200 Subject: [PATCH 2/2] [cdb:resinfo] Increase `res_key` column size to 255 characters - Updated `res_key` column in `resinfo` table schema from `varchar(40)` to `varchar(255)` to allow longer keys. --- 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 d84a9b2..d092aab 100644 --- a/cdb/db_resources.go +++ b/cdb/db_resources.go @@ -111,7 +111,7 @@ type ( // CREATE TABLE `resinfo` ( // `id` int(11) NOT NULL AUTO_INCREMENT, // `rid` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, - // `res_key` varchar(40) DEFAULT '', + // `res_key` varchar(255) DEFAULT '', // `res_value` varchar(255) DEFAULT NULL, // `updated` timestamp NOT NULL DEFAULT current_timestamp(), // `topology` varchar(20) DEFAULT 'failover',