From 5609489e86882e92bfcb26b3b1dc026ed057fe1d Mon Sep 17 00:00:00 2001 From: Agniva De Sarker Date: Thu, 20 Mar 2025 11:46:44 +0530 Subject: [PATCH] MM-62900: Avoid redundant query for channelID while indexing file (#30289) The file already has the ChannelID field. Therefore, we avoid querying the database again. This sometimes causes errors in customer environments where there is noticeable replication lag, causing files not to be indexed entirely. https://mattermost.atlassian.net/browse/MM-62900 ```release-note NONE ``` Co-authored-by: Mattermost Build --- server/channels/store/searchlayer/file_info_layer.go | 9 --------- 1 file changed, 9 deletions(-) diff --git a/server/channels/store/searchlayer/file_info_layer.go b/server/channels/store/searchlayer/file_info_layer.go index c5af4569741..6d8b37287cf 100644 --- a/server/channels/store/searchlayer/file_info_layer.go +++ b/server/channels/store/searchlayer/file_info_layer.go @@ -26,15 +26,6 @@ func (s SearchFileInfoStore) indexFile(rctx request.CTX, file *model.FileInfo) { return } channelId := file.ChannelId - if file.PostId != "" { - post, postErr := s.rootStore.Post().GetSingle(rctx, file.PostId, false) - if postErr != nil { - rctx.Logger().Error("Couldn't get post for file for SearchEngine indexing.", mlog.String("post_id", file.PostId), mlog.String("search_engine", engineCopy.GetName()), mlog.String("file_info_id", file.Id), mlog.Err(postErr)) - return - } - channelId = post.ChannelId - } - if channelId == "" { rctx.Logger().Error("Couldn't associate file with a channel for file for SearchEngine indexing.", mlog.String("search_engine", engineCopy.GetName()), mlog.String("file_info_id", file.Id)) return