Avoid calling the user count query in future if we get a count > 0 (#23545)

* Avoid calling the user count query in future if we get a count > 0

* re-adding mock session to avoid adding the old mitigation in future

* adjustments based on feedback
Этот коммит содержится в:
Ben Cooke
2023-05-30 21:34:01 -04:00
коммит произвёл GitHub
родитель 14fcc8a22e
Коммит 427635a96f
3 изменённых файлов: 36 добавлений и 28 удалений

Просмотреть файл

@@ -49,10 +49,11 @@ type PlatformService struct {
sessionCache cache.Cache
sessionPool sync.Pool
asymmetricSigningKey atomic.Value
clientConfig atomic.Value
clientConfigHash atomic.Value
limitedClientConfig atomic.Value
asymmetricSigningKey atomic.Value
clientConfig atomic.Value
clientConfigHash atomic.Value
limitedClientConfig atomic.Value
fetchUserCountForFirstUserAccountCheck atomic.Bool
logger *mlog.Logger
notificationsLogger *mlog.Logger
@@ -126,6 +127,9 @@ func New(sc ServiceConfig, options ...Option) (*PlatformService, error) {
additionalClusterHandlers: map[model.ClusterEvent]einterfaces.ClusterMessageHandler{},
}
// Assume the first user account has not been created yet. A call to the DB will later check if this is really the case.
ps.fetchUserCountForFirstUserAccountCheck.Store(true)
// Step 1: Cache provider.
// At the moment we only have this implementation
// in the future the cache provider will be built based on the loaded config