From 580b410e8c2462a552dd28133e8d193bb9fb17d0 Mon Sep 17 00:00:00 2001 From: Ryan McKinley Date: Wed, 25 Jun 2025 10:41:51 +0300 Subject: [PATCH] DualWriter: Minor cleanup (#107028) --- pkg/storage/legacysql/dualwrite/sql_mig.go | 25 ---------------------- pkg/storage/legacysql/dualwrite/types.go | 18 ++++++++-------- 2 files changed, 9 insertions(+), 34 deletions(-) delete mode 100644 pkg/storage/legacysql/dualwrite/sql_mig.go diff --git a/pkg/storage/legacysql/dualwrite/sql_mig.go b/pkg/storage/legacysql/dualwrite/sql_mig.go deleted file mode 100644 index ce7a6f3f876..00000000000 --- a/pkg/storage/legacysql/dualwrite/sql_mig.go +++ /dev/null @@ -1,25 +0,0 @@ -package dualwrite - -import "github.com/grafana/grafana/pkg/services/sqlstore/migrator" - -// Not yet used... but you get the idea -func AddUnifiedStatusMigrations(mg *migrator.Migrator) { - resourceStorageStatus := migrator.Table{ - Name: "resource_storage_status", - Columns: []*migrator.Column{ - {Name: "group", Type: migrator.DB_NVarchar, Length: 190, Nullable: false}, - {Name: "resource", Type: migrator.DB_NVarchar, Length: 190, Nullable: false}, - {Name: "write_legacy", Type: migrator.DB_Bool, Nullable: false, Default: "TRUE"}, - {Name: "write_unified", Type: migrator.DB_Bool, Nullable: false, Default: "TRUE"}, - {Name: "read_unified", Type: migrator.DB_Bool, Nullable: false}, - {Name: "migrating", Type: migrator.DB_BigInt, Nullable: false}, // Timestamp Actively running a migration (start timestamp) - {Name: "migrated", Type: migrator.DB_BigInt, Nullable: false}, // Timestamp job finished - {Name: "runtime", Type: migrator.DB_Bool, Nullable: false, Default: "TRUE"}, - {Name: "update_key", Type: migrator.DB_BigInt, Nullable: false}, // optimistic lock key -- required for update - }, - Indices: []*migrator.Index{ - {Cols: []string{"group", "resource"}, Type: migrator.UniqueIndex}, - }, - } - mg.AddMigration("create resource_storage_status table", migrator.NewAddTableMigration(resourceStorageStatus)) -} diff --git a/pkg/storage/legacysql/dualwrite/types.go b/pkg/storage/legacysql/dualwrite/types.go index bd1f2fa4415..8ba6ddc9cbd 100644 --- a/pkg/storage/legacysql/dualwrite/types.go +++ b/pkg/storage/legacysql/dualwrite/types.go @@ -10,26 +10,26 @@ import ( // For *legacy* services, this will indicate if we have transitioned to Unified storage yet type StorageStatus struct { - Group string `json:"group" xorm:"group"` - Resource string `json:"resource" xorm:"resource"` - WriteLegacy bool `json:"write_legacy" xorm:"write_legacy"` - WriteUnified bool `json:"write_unified" xorm:"write_unified"` + Group string `json:"group"` + Resource string `json:"resource"` + WriteLegacy bool `json:"write_legacy"` + WriteUnified bool `json:"write_unified"` // Unified is the primary source (legacy may be secondary) - ReadUnified bool `json:"read_unified" xorm:"read_unified"` + ReadUnified bool `json:"read_unified"` // Timestamp when a migration finished - Migrated int64 `json:"migrated" xorm:"migrated"` + Migrated int64 `json:"migrated" ` // Timestamp when a migration *started* this should be cleared when finished // While migrating all write commands will be unavailable - Migrating int64 `json:"migrating" xorm:"migrating"` + Migrating int64 `json:"migrating"` // When false, the behavior will not change at runtime - Runtime bool `json:"runtime" xorm:"runtime"` + Runtime bool `json:"runtime"` // UpdateKey used for optimistic locking -- requests to change the status must match previous value - UpdateKey int64 `json:"update_key" xorm:"update_key"` + UpdateKey int64 `json:"update_key"` } func (status *StorageStatus) validate() bool {