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
This commit is contained in:
Serge Zaitsev
2025-12-02 17:10:22 +01:00
committed by GitHub
parent f2694ce72f
commit 95e65e2588
3 changed files with 100 additions and 30 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 {