Fixing behavior of Replicas and SearchReplicas in canary environments (#14576)
* Fixing behavior of Replicas and SearchReplicas in canary environments
* Trying to fix tests
* Revert "Trying to fix tests"
This reverts commit 3531da961844f5cb8557efcd3b570b06f362c6df.
* Revert "Fixing behavior of Replicas and SearchReplicas in canary environments"
This reverts commit 0c05901c843e4ccd60c8320fb4e0123b1bacf430.
* Revert "Disable read/search db replicas in TE/E0 (#14400)"
This reverts commit ef5ac519d9.
* Making the store aware of the license
* Readding the unit tests
* Fixing sqlstor supplier tests
* Adding mutex to ensure license write consistency and fixing tests
* Fixing tests
* Fixing tests
* Shuting down server properly during tests
* Trying to fix tests
* Trying to fix the tests
* Skipping flaky tests
Co-authored-by: mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
553af3a694
Коммит
ae328153d5
@@ -11,6 +11,7 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
@@ -113,6 +114,8 @@ type SqlSupplier struct {
|
||||
settings *model.SqlSettings
|
||||
lockedToMaster bool
|
||||
context context.Context
|
||||
license *model.License
|
||||
licenseMutex sync.Mutex
|
||||
}
|
||||
|
||||
type TraceOnAdapter struct{}
|
||||
@@ -327,6 +330,10 @@ func (ss *SqlSupplier) GetMaster() *gorp.DbMap {
|
||||
}
|
||||
|
||||
func (ss *SqlSupplier) GetSearchReplica() *gorp.DbMap {
|
||||
if ss.license == nil {
|
||||
return ss.GetMaster()
|
||||
}
|
||||
|
||||
if len(ss.settings.DataSourceSearchReplicas) == 0 {
|
||||
return ss.GetReplica()
|
||||
}
|
||||
@@ -336,7 +343,7 @@ func (ss *SqlSupplier) GetSearchReplica() *gorp.DbMap {
|
||||
}
|
||||
|
||||
func (ss *SqlSupplier) GetReplica() *gorp.DbMap {
|
||||
if len(ss.settings.DataSourceReplicas) == 0 || ss.lockedToMaster {
|
||||
if len(ss.settings.DataSourceReplicas) == 0 || ss.lockedToMaster || ss.license == nil {
|
||||
return ss.GetMaster()
|
||||
}
|
||||
|
||||
@@ -1178,6 +1185,12 @@ func (ss *SqlSupplier) CheckIntegrity() <-chan store.IntegrityCheckResult {
|
||||
return results
|
||||
}
|
||||
|
||||
func (ss *SqlSupplier) UpdateLicense(license *model.License) {
|
||||
ss.licenseMutex.Lock()
|
||||
defer ss.licenseMutex.Unlock()
|
||||
ss.license = license
|
||||
}
|
||||
|
||||
type mattermConverter struct{}
|
||||
|
||||
func (me mattermConverter) ToDb(val interface{}) (interface{}, error) {
|
||||
|
||||
Ссылка в новой задаче
Block a user