A customer is seeing this error come up when they try to delete a channel using mmctl or the inbuilt cli:
```
{"level":"error","ts":1609946082.091247,"caller":"mlog/log.go:229","msg":"Unable to delete the posts by channel.","path":"/api/v4/channels/kknpcbkdafg7uchk8i34jercrw","request_id":"1i71xpj5m7fwfbrotqd7nonxww","ip_addr":"xxx","user_id":"hx9inobaef8wuruqgiwc3bbzsr","method":"DELETE","err_where":"PermanentDeleteChannel","http_code":500,"err_details":"failed to get a thread: resource: Thread id: 8phskmna5bn13k4axbamhsmnja"}
```
This is happening on 5.29.1
The issue seems to be fixed in 5.30 (https://github.com/mattermost/mattermost-server/pull/16091).
PermanentDeleteUser is also affected by the same issue:
https://community-daily.mattermost.com/core/pl/5g7hjjcmt3bj9ruhnans5pgdbo
-successfully deleted users and channels with mmctl
-no error
does this impact users transitioning to use collapsed reply threads?
I am hitting this same issue in my customer's environment using user delete [ID]. This seems related to posts that have RootID and ParentID configured. We deleted all rows associated with the UserID that had Root/Parent IDs and it resolved the delete issue.
Bug seems to be introduced by https://github.com/mattermost/mattermost-server/pull/15571/files .
Fix should work for all versions (current and any cherrypick for a dot release we might want to do on previous versions).
PR here:
Tested and passed on v5.31.1-rc1
QA Note: added done-5.31 label, leaving open to test on v5.32
Tested and passed on v5.32
QA Note: PR labelled. Closing.