From e8d431ee7c7ca3557a45a1607e10d0b3de70d95f Mon Sep 17 00:00:00 2001 From: Ashish Bhate Date: Thu, 13 Aug 2020 14:33:26 +0000 Subject: [PATCH] [MM-26837] attempt at fixing flaky test on mysql-5.6 (#15110) Summary - Attempt at fixing the AutocompleteInTeam/empty_string test which is flaky on MySQL-5.6. This is likely an index_merge_intersection optimization issue. See https://community.mattermost.com/core/pl/uzgygwa9e3d4pns14ayfs7mobw for more discussion. The fix here simply modifies the where clause to change the query plan so index_merge_intersection is not used, while also not introducing a temporary table or a filesort. Ticket Link - https://mattermost.atlassian.net/browse/MM-26837 --- store/sqlstore/channel_store.go | 4 ++-- store/storetest/channel_store.go | 5 +---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/store/sqlstore/channel_store.go b/store/sqlstore/channel_store.go index c5b8c8c74e..bcc4c90567 100644 --- a/store/sqlstore/channel_store.go +++ b/store/sqlstore/channel_store.go @@ -2584,7 +2584,7 @@ func (s SqlChannelStore) GetMembersForUserWithPagination(teamId, userId string, } func (s SqlChannelStore) AutocompleteInTeam(teamId string, term string, includeDeleted bool) (*model.ChannelList, *model.AppError) { - deleteFilter := "AND c.DeleteAt = 0" + deleteFilter := "AND Channels.DeleteAt = 0" if includeDeleted { deleteFilter = "" } @@ -2597,7 +2597,7 @@ func (s SqlChannelStore) AutocompleteInTeam(teamId string, term string, includeD JOIN PublicChannels c ON (c.Id = Channels.Id) WHERE - c.TeamId = :TeamId + Channels.TeamId = :TeamId ` + deleteFilter + ` %v LIMIT ` + strconv.Itoa(model.CHANNEL_SEARCH_DEFAULT_LIMIT) diff --git a/store/storetest/channel_store.go b/store/storetest/channel_store.go index 392da2fef4..5b9f6516e9 100644 --- a/store/storetest/channel_store.go +++ b/store/storetest/channel_store.go @@ -78,8 +78,8 @@ func TestChannelStore(t *testing.T, ss store.Store, s SqlSupplier) { t.Run("GetMemberCount", func(t *testing.T) { testGetMemberCount(t, ss) }) t.Run("GetMemberCountsByGroup", func(t *testing.T) { testGetMemberCountsByGroup(t, ss) }) t.Run("GetGuestCount", func(t *testing.T) { testGetGuestCount(t, ss) }) - t.Run("SearchInTeam", func(t *testing.T) { testChannelStoreSearchInTeam(t, ss, s) }) t.Run("SearchMore", func(t *testing.T) { testChannelStoreSearchMore(t, ss) }) + t.Run("SearchInTeam", func(t *testing.T) { testChannelStoreSearchInTeam(t, ss, s) }) t.Run("SearchForUserInTeam", func(t *testing.T) { testChannelStoreSearchForUserInTeam(t, ss) }) t.Run("SearchAllChannels", func(t *testing.T) { testChannelStoreSearchAllChannels(t, ss) }) t.Run("GetMembersByIds", func(t *testing.T) { testChannelStoreGetMembersByIds(t, ss) }) @@ -5114,9 +5114,6 @@ func testChannelStoreSearchInTeam(t *testing.T, ss store.Store, s SqlSupplier) { } { for _, testCase := range testCases { t.Run(name+"/"+testCase.Description, func(t *testing.T) { - if name == "AutocompleteInTeam" && testCase.Description == "empty string" && s.DriverName() == model.DATABASE_DRIVER_MYSQL { - t.Skip("Skip test for MySQL. TODO: Understand why this test fails in mysql 5.6 in the CI") - } channels, err := search(testCase.TeamId, testCase.Term, testCase.IncludeDeleted) require.Nil(t, err)