[release-12.3.1] Chore: Run annotation data migration in batches (#115136)

* Chore: Run annotation data migration in batches (#113589)

* run annotation data migration in batches

* how could i miss it

* run in the background, starting from newest annotations

* update tests

* optionally pass batch size via env

(cherry picked from commit 95e65e2588)

* update mysql query

---------

Co-authored-by: Serge Zaitsev <serge.zaitsev@grafana.com>
This commit is contained in:
grafana-delivery-bot[bot]
2025-12-15 12:12:31 +01:00
committed by GitHub
co-authored by Serge Zaitsev
parent 1214d51a42
commit 0e38140bd9
3 changed files with 101 additions and 31 deletions
@@ -105,10 +105,16 @@ func triggerAlwaysOnMigrations(cfg *setting.Cfg, l log.Logger, db db.DB) {
l.Debug("skipped dashboard UID startup migration")
return
}
err := migrations.RunDashboardUIDMigrations(db.GetEngine().NewSession(), db.GetEngine().DriverName())
if err != nil {
l.Error("failed to populate dashboard_uid for annotations", "error", err)
}
// Run migration in a background goroutine to avoid blocking service startup
go func() {
l.Info("Starting annotation dashboard_uid migration in background")
err := migrations.RunDashboardUIDMigrations(db.GetEngine().NewSession(), db.GetEngine().DriverName(), l)
if err != nil {
l.Error("failed to populate dashboard_uid for annotations", "error", err)
} else {
l.Info("Annotation dashboard_uid migration completed successfully")
}
}()
}
func (r *xormRepositoryImpl) Type() string {