Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cdb/constants.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package cdb

const (
TextMax = 65535
TextMax = 65535
MediumTextMax = 16777215
)
10 changes: 5 additions & 5 deletions cdb/db_actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion cdb/db_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Loading