Storage: Add support for sortBy selector (#80680)

* add support for sortBy field selector

* use label selectors instead of field selectors

* set entity_labels on create & update

* make entity server integration tests work

* test fixes

* be more consistent with handling of empty body, meta or status

* workaround for database is locked errors during migration

* fix double import of sqlite3

* rename functions and tidy up

* refactor update

* disable integration tests until we can fix the database locking issue
This commit is contained in:
Dan Cech
2024-02-07 15:05:10 -05:00
committed by GitHub
parent bb6db46ecc
commit 1f1461734c
13 changed files with 429 additions and 202 deletions
+9 -1
View File
@@ -1,13 +1,14 @@
package migrator
import (
"errors"
"fmt"
"time"
_ "github.com/go-sql-driver/mysql"
"github.com/golang-migrate/migrate/v4/database"
_ "github.com/lib/pq"
_ "github.com/mattn/go-sqlite3"
"github.com/mattn/go-sqlite3"
"go.uber.org/atomic"
"xorm.io/xorm"
@@ -208,6 +209,13 @@ 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) {
mg.Logger.Debug("Database locked, sleeping then retrying", "error", err, "sql", sql)
time.Sleep(100 * time.Millisecond)
err = mg.exec(m, sess)
}
if err != nil {
mg.Logger.Error("Exec failed", "error", err, "sql", sql)
record.Error = err.Error()