MM-33789: Revert fallback to master for GetAllProfilesInChannel (#17119)
* MM-33789: Revert fallback to master for GetAllProfilesInChannel This fixes a regression introduced in https://github.com/mattermost/mattermost-server/pull/16911. It was causing problems with too many invalidations and overloading the writer instance for big installations. Reverting this does not affect correctness at all because it was done out of abundance of caution and the idea at that point was it was to be done for all caches. https://mattermost.atlassian.net/browse/MM-33789 ```release-note NONE ``` * fix gofmt issues
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
145fa97069
Коммит
936540ea58
@@ -289,10 +289,9 @@ func NewLocalCacheLayer(baseStore store.Store, metrics einterfaces.MetricsInterf
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
localCacheStore.user = &LocalCacheUserStore{
|
localCacheStore.user = &LocalCacheUserStore{
|
||||||
UserStore: baseStore.User(),
|
UserStore: baseStore.User(),
|
||||||
rootStore: &localCacheStore,
|
rootStore: &localCacheStore,
|
||||||
userProfileByIdsInvalidations: make(map[string]bool),
|
userProfileByIdsInvalidations: make(map[string]bool),
|
||||||
profilesInChannelInvalidations: make(map[string]bool),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Teams
|
// Teams
|
||||||
|
|||||||
@@ -15,11 +15,9 @@ import (
|
|||||||
|
|
||||||
type LocalCacheUserStore struct {
|
type LocalCacheUserStore struct {
|
||||||
store.UserStore
|
store.UserStore
|
||||||
rootStore *LocalCacheStore
|
rootStore *LocalCacheStore
|
||||||
userProfileByIdsMut sync.Mutex
|
userProfileByIdsMut sync.Mutex
|
||||||
userProfileByIdsInvalidations map[string]bool
|
userProfileByIdsInvalidations map[string]bool
|
||||||
profilesInChannelMut sync.Mutex
|
|
||||||
profilesInChannelInvalidations map[string]bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *LocalCacheUserStore) handleClusterInvalidateScheme(msg *model.ClusterMessage) {
|
func (s *LocalCacheUserStore) handleClusterInvalidateScheme(msg *model.ClusterMessage) {
|
||||||
@@ -37,9 +35,6 @@ func (s *LocalCacheUserStore) handleClusterInvalidateProfilesInChannel(msg *mode
|
|||||||
if msg.Data == ClearCacheMessageData {
|
if msg.Data == ClearCacheMessageData {
|
||||||
s.rootStore.profilesInChannelCache.Purge()
|
s.rootStore.profilesInChannelCache.Purge()
|
||||||
} else {
|
} else {
|
||||||
s.profilesInChannelMut.Lock()
|
|
||||||
s.profilesInChannelInvalidations[msg.Data] = true
|
|
||||||
s.profilesInChannelMut.Unlock()
|
|
||||||
s.rootStore.profilesInChannelCache.Remove(msg.Data)
|
s.rootStore.profilesInChannelCache.Remove(msg.Data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -72,9 +67,6 @@ func (s *LocalCacheUserStore) InvalidateProfilesInChannelCacheByUser(userId stri
|
|||||||
var userMap map[string]*model.User
|
var userMap map[string]*model.User
|
||||||
if err = s.rootStore.profilesInChannelCache.Get(key, &userMap); err == nil {
|
if err = s.rootStore.profilesInChannelCache.Get(key, &userMap); err == nil {
|
||||||
if _, userInCache := userMap[userId]; userInCache {
|
if _, userInCache := userMap[userId]; userInCache {
|
||||||
s.profilesInChannelMut.Lock()
|
|
||||||
s.profilesInChannelInvalidations[key] = true
|
|
||||||
s.profilesInChannelMut.Unlock()
|
|
||||||
s.rootStore.doInvalidateCacheCluster(s.rootStore.profilesInChannelCache, key)
|
s.rootStore.doInvalidateCacheCluster(s.rootStore.profilesInChannelCache, key)
|
||||||
if s.rootStore.metrics != nil {
|
if s.rootStore.metrics != nil {
|
||||||
s.rootStore.metrics.IncrementMemCacheInvalidationCounter("Profiles in Channel - Remove by User")
|
s.rootStore.metrics.IncrementMemCacheInvalidationCounter("Profiles in Channel - Remove by User")
|
||||||
@@ -86,9 +78,6 @@ func (s *LocalCacheUserStore) InvalidateProfilesInChannelCacheByUser(userId stri
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *LocalCacheUserStore) InvalidateProfilesInChannelCache(channelID string) {
|
func (s *LocalCacheUserStore) InvalidateProfilesInChannelCache(channelID string) {
|
||||||
s.profilesInChannelMut.Lock()
|
|
||||||
s.profilesInChannelInvalidations[channelID] = true
|
|
||||||
s.profilesInChannelMut.Unlock()
|
|
||||||
s.rootStore.doInvalidateCacheCluster(s.rootStore.profilesInChannelCache, channelID)
|
s.rootStore.doInvalidateCacheCluster(s.rootStore.profilesInChannelCache, channelID)
|
||||||
if s.rootStore.metrics != nil {
|
if s.rootStore.metrics != nil {
|
||||||
s.rootStore.metrics.IncrementMemCacheInvalidationCounter("Profiles in Channel - Remove by Channel")
|
s.rootStore.metrics.IncrementMemCacheInvalidationCounter("Profiles in Channel - Remove by Channel")
|
||||||
@@ -103,15 +92,6 @@ func (s *LocalCacheUserStore) GetAllProfilesInChannel(ctx context.Context, chann
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If it was invalidated, then we need to query master.
|
|
||||||
s.profilesInChannelMut.Lock()
|
|
||||||
if s.profilesInChannelInvalidations[channelId] {
|
|
||||||
ctx = sqlstore.WithMaster(ctx)
|
|
||||||
// And then remove the key from the map.
|
|
||||||
delete(s.profilesInChannelInvalidations, channelId)
|
|
||||||
}
|
|
||||||
s.profilesInChannelMut.Unlock()
|
|
||||||
|
|
||||||
userMap, err := s.UserStore.GetAllProfilesInChannel(ctx, channelId, allowFromCache)
|
userMap, err := s.UserStore.GetAllProfilesInChannel(ctx, channelId, allowFromCache)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user