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 { 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',