SQLStore: Prevent concurrent migrations (#44101)
* SQLStore: Prevent concurrent migrations * Hide behind a feature toggle * Configurable locking attempt timeout * Update docs/sources/administration/configuration.md Co-authored-by: Igor Suleymanov <radiohead@users.noreply.github.com> Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>
This commit is contained in:
co-authored by
Igor Suleymanov
achatterjee-grafana
parent
163b570f5d
commit
d718ee1918
@@ -7,6 +7,11 @@ import (
|
||||
"xorm.io/xorm"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrLockDB = fmt.Errorf("failed to obtain lock")
|
||||
ErrReleaseLockDB = fmt.Errorf("failed to release lock")
|
||||
)
|
||||
|
||||
type Dialect interface {
|
||||
DriverName() string
|
||||
Quote(string) string
|
||||
@@ -53,6 +58,13 @@ type Dialect interface {
|
||||
IsUniqueConstraintViolation(err error) bool
|
||||
ErrorMessage(err error) string
|
||||
IsDeadlock(err error) bool
|
||||
Lock(LockCfg) error
|
||||
Unlock(LockCfg) error
|
||||
}
|
||||
|
||||
type LockCfg struct {
|
||||
Session *xorm.Session
|
||||
Timeout int
|
||||
}
|
||||
|
||||
type dialectFunc func(*xorm.Engine) Dialect
|
||||
@@ -288,3 +300,11 @@ func (b *BaseDialect) TruncateDBTables() error {
|
||||
func (b *BaseDialect) UpsertSQL(tableName string, keyCols, updateCols []string) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (b *BaseDialect) Lock(_ LockCfg) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *BaseDialect) Unlock(_ LockCfg) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user