Problem deleting channel with CLI


we are using Mattermost Team Edition 5.37.7.
We have a channel with a lot of messages that we want to delete physically. I tried to use the CLI, but it does not work:

-bash-4.2$ cd /opt/mattermost/bin/ -bash-4.2$ ./mattermost channel delete sjk5gkba9tbef8ffajbcwqfyhr Are you sure you want to delete the channels specified? All data will be permanently deleted? (YES/NO): YES
after 25 minutes, I got:
Unable to delete channel 'cve' error: PermanentDeleteChannel: Unable to delete the posts by channel., failed to delete Posts with channelId=sjk5gkba9tbef8ffajbcwqfyhr: pq: canceling statement due to user request

From the message, I would assume, that the database received a timeout (from the client?) and performs a rollback.
Can anyone help me understanding this issue and how to permanently delete the channel and the messages?

Thanks in advance, Rainer

Yes, the query timed out because it exceeded the SqlSettings.QueryTimeout setting. Can you mention the value you have set?

I checked the config/config.json - is the mattermost client using this settings?:

    "SqlSettings": {
        "DriverName": "postgres",
        "DataSource": "postgres://mattermost:XXX@\u0026connect_timeout=10",
        "DataSourceReplicas": [],
        "DataSourceSearchReplicas": [],
        "MaxIdleConns": 20,
        "ConnMaxLifetimeMilliseconds": 3600000,
        "ConnMaxIdleTimeMilliseconds": 300000,
        "MaxOpenConns": 300,
        "Trace": false,
        "AtRestEncryptKey": "jksksj85pzbomhs3ockhrzynpgh8ox34",
        "QueryTimeout": 30,
        "DisableDatabaseSearch": false,
        "ReplicaLagSettings": []

Yes, the client uses those settings. I’d suggest to bump your QueryTimeout to 300 for the time being. See if you can delete the channel, and then reduce it back. I am guessing the channel has a lot of posts which is taking a lot of time to scan through.

1 Like

Many thanks, increasing the timeout to 300 solved my problem and the command has now finished successfully.