From 5ecc7dd2fa2cce26137f5553327584dbc43d7957 Mon Sep 17 00:00:00 2001 From: Matthew Jacobson Date: Thu, 11 Jan 2024 15:51:36 -0500 Subject: [PATCH] Alerting: Increase size of kvstore value type for MySQL to LONGTEXT (#80331) * Alerting: Increase size of kvstore value type for MySQL to LONGTEXT alertmanager uses the kvstore to persist its notification log and the current column limit for MySQL (16.7mb) puts the maximum entries at a level that is potentially achievable for heavy alerting users (~40-80k entries). In comparison, the current type for PSQL (TEXT) is effectively unlimited and I believe SQLIte defaults to 2gb which is also plenty of leeway. --- pkg/services/sqlstore/migrations/kv_store_mig.go | 7 +++++++ pkg/services/sqlstore/migrations/migrations.go | 2 ++ 2 files changed, 9 insertions(+) diff --git a/pkg/services/sqlstore/migrations/kv_store_mig.go b/pkg/services/sqlstore/migrations/kv_store_mig.go index 3bdd39335a2..252daf0a134 100644 --- a/pkg/services/sqlstore/migrations/kv_store_mig.go +++ b/pkg/services/sqlstore/migrations/kv_store_mig.go @@ -25,3 +25,10 @@ func addKVStoreMigrations(mg *Migrator) { mg.AddMigration("add index kv_store.org_id-namespace-key", NewAddIndexMigration(kvStoreV1, kvStoreV1.Indices[0])) } + +// addKVStoreMySQLValueTypeLongTextMigration adds a migration to change the column type of kv_store.value to LONGTEXT for +// MySQL to be more inline size-wise with PSQL (TEXT) and SQLite. +func addKVStoreMySQLValueTypeLongTextMigration(mg *Migrator) { + mg.AddMigration("alter kv_store.value to longtext", NewRawSQLMigration(""). + Mysql("ALTER TABLE kv_store MODIFY value LONGTEXT NOT NULL;")) +} diff --git a/pkg/services/sqlstore/migrations/migrations.go b/pkg/services/sqlstore/migrations/migrations.go index 50968f6c378..1fc33893d00 100644 --- a/pkg/services/sqlstore/migrations/migrations.go +++ b/pkg/services/sqlstore/migrations/migrations.go @@ -113,6 +113,8 @@ func (*OSSMigrations) AddMigration(mg *Migrator) { ssosettings.AddMigration(mg) ualert.CreateOrgMigratedKVStoreEntries(mg) + + addKVStoreMySQLValueTypeLongTextMigration(mg) } func addStarMigrations(mg *Migrator) {