Steps to reproduce
Centos 8.2, 4 cores, 16Gb of Ram, ssd storage
Mattermost 6.1
Server version: 8.0.21
18+ million records in Posts (27Gb)
Baisc message deletion procedure from client or web
Expected behavior
As it was before v6 upgrade.
Observed behavior
Users cant post new messages during someones deletion.
Mysql process list show following qeury during more than 120 sec:
UPDATE Posts SET DeleteAt = 1637998911684, UpdateAt = 1637998911684, Props = JSON_SET(Props, ‘$.deleteBy’, ‘buqskqrwmjnhfuqskqrwmjn4ca’) Where Id = ‘c3gazo74m3rkjps71qbtso6twc’ OR RootId = ‘c3gazo74m3rkjps71qbtso6twc’
PS: Looks like dropping index idx_posts_root_id during v6 migration was a bad idea, because there is a huge time difference between query with RootId and without it. I have tried to execute same UPDATE without “OR RootId = ‘c3gazo74m3rkjps71qbtso6twc’” and got result instantly. As temporary solution i have to restrict DELETE method on nginx for /api/v4/posts/ URL.
Is it safe to recreate idx_posts_root_id by myself?
Is there some plans not to search by RootId on UPDATE next server versions?
@dmittr - Would you be able to run this command and let us know how long it takes:
UPDATE Posts FORCE INDEX (primary) SET DeleteAt = 1637998911684, UpdateAt = 1637998911684, Props = JSON_SET(Props, ‘$.deleteBy’, ‘buqskqrwmjnhfuqskqrwmjn4ca’) Where Id = ‘c3gazo74m3rkjps71qbtso6twc’ OR RootId = ‘c3gazo74m3rkjps71qbtso6twc’
@dmittr - Ignore, my last comment, I have another query for you to try:
UPDATE Posts SET DeleteAt = 1637998911684, UpdateAt = 1637998911684, Props = JSON_SET(Props, ‘$.deleteBy’, ‘buqskqrwmjnhfuqskqrwmjn4ca’) Where Id = ‘c3gazo74m3rkjps71qbtso6twc’ OR RootId = ‘c3gazo74m3rkjps71qbtso6twc’ ORDER BY Id
it works. “ORDER BY Id” makes query as fast as before update.
time mysql mattermost -e 'UPDATE Posts SET DeleteAt = 1640251149684, UpdateAt = 1640251149684, Props = JSON_SET(Props, "$.deleteBy", "buqskqrwmjnhfuqskqrwmjn4ca") Where Id = "pzdhmmdwnfg85nimnseepjuy1y" OR RootId = "pzdhmmdwnfg85nimnseepjuy1y" ORDER BY Id'
real 0m0.016s
user 0m0.007s
sys 0m0.004s