mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Storage: Watch tests (#85496)
* basic watch tests working * refactor to read previous event within poller * add watch test files * cleanup * watch tests passing * debug cleanup * special handling for canceled context * cleanup * fix wire * fix sqlite_sequence cleanup issue * move watch tests to integration, wait for provisioned dashboards * handle context deadline exceeded and eof errors * add comment about sleep
This commit is contained in:
@@ -210,7 +210,9 @@ func (mg *Migrator) run() (err error) {
|
||||
err := mg.InTransaction(func(sess *xorm.Session) error {
|
||||
err := mg.exec(m, sess)
|
||||
// if we get an sqlite busy/locked error, sleep 100ms and try again
|
||||
if errors.Is(err, sqlite3.ErrLocked) || errors.Is(err, sqlite3.ErrBusy) {
|
||||
cnt := 0
|
||||
for cnt < 3 && (errors.Is(err, sqlite3.ErrLocked) || errors.Is(err, sqlite3.ErrBusy)) {
|
||||
cnt++
|
||||
mg.Logger.Debug("Database locked, sleeping then retrying", "error", err, "sql", sql)
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
err = mg.exec(m, sess)
|
||||
|
||||
@@ -122,7 +122,11 @@ func (db *SQLite3) TruncateDBTables(engine *xorm.Engine) error {
|
||||
}
|
||||
}
|
||||
if _, err := sess.Exec("UPDATE sqlite_sequence SET seq = 0 WHERE name != 'dashboard_acl';"); err != nil {
|
||||
return fmt.Errorf("failed to cleanup sqlite_sequence: %w", err)
|
||||
// if we have not created any autoincrement columns in the database this will fail, the error is expected and we can ignore it
|
||||
// we can't discriminate based on code because sqlite returns a generic error code
|
||||
if err.Error() != "no such table: sqlite_sequence" {
|
||||
return fmt.Errorf("failed to cleanup sqlite_sequence: %w", err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ func newSQLStore(cfg *setting.Cfg, engine *xorm.Engine,
|
||||
// Has to be done in a second phase (after initialization), since other services can register migrations during
|
||||
// the initialization phase.
|
||||
func (ss *SQLStore) Migrate(isDatabaseLockingEnabled bool) error {
|
||||
if ss.dbCfg.SkipMigrations {
|
||||
if ss.dbCfg.SkipMigrations || ss.migrations == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user