Mmctl export create fails with 'Limit exceeded for paging'

Summary

While trying to create an export, mmctl export create fails with:

exportAllPosts: Limit exceeded for paging., failed to find Posts

Steps to reproduce

  1. On the Mattermost server, create an export:
    cd /opt/mattermost/
    bin/mmctl --local export create
    
  2. Check the logs:
    tail -f /opt/mattermost/logs/mattermost.log
    

Mattermost version 10.7.0

Expected behaviour

Create a full export of the server, including messages.

Observed behaviour

No user messages are in the resulting export. The file itself is only 8 kb.

The export job fails with:

{"timestamp":"2025-06-25 14:02:26.690 +01:00","level":"error","msg":"SimpleWorker: job execution error","caller":"jobs/base_workers.go:86","worker_name":"ExportProcess","job_id":"16444px4epretb4b37yeowqsga","job_type":"export_process","job_create_at":"Jun 25 13:02:19.193","error":"exportAllPosts: Limit exceeded for paging., failed to find Posts: Error 1305 (42000): FUNCTION mattermost.JSON_ARRAYAGG does not exist"}

Full log available in the bug report:

Hi @awky! Have you by any chance tried updating MySQL to see if that might fix the issue? Alternatively, I’d also recommend checking out this doc around software/hardware requirements to see if might help surface any additional clues: Software and hardware requirements - Mattermost documentation

Hello, thanks for the reply! Now I’m looking at the docs it looks like MariaDB is even less supported than MySQL (the reason for us starting this migration :grin:)
This is our MariaDB / MySQL version:

mysql --version
mysql  Ver 15.1 Distrib 10.3.39-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2

And this is our Debian version:

cat /etc/issue       
Debian GNU/Linux 10 \n \l

Do you recommend upgrading MySQL before attempting an export?
We’ve already got a functional Debian 12 + Postgres Mattermost ready to import. Cheers :slight_smile:

Thanks for the update, @awky! Given that MariaDB 10.3 is quite outdated and lacks support for JSON functions like JSON_ARRAYAGG, I’d definitely recommend completing the switch to MySQL 8+ or PostgreSQL before running the export. Sounds like your Debian 12 + Postgres setup is right on track! :blush:

1 Like

Thanks for the help! Using a newer version of MariaDB solved my problem.

For the benefit of future readers:

The problem

MariaDB versions before 10.5.0 do no support JSON_ARRAYAGG [source]. This is required for mmctl export to work.

The solution

Temporarily switch Mattermost to a newer MariaDB. You could upgrade in-place, but that seemed dangerous to me.

Set up a new MariaDB server

I created a Debian 12 server, which is new enough to install MariaDB 10.11.11.

  1. Install MariaDB on a new server:
    # root@new-server
    apt update
    apt install mariadb-server
    
  2. Configure it to listen to remote connections: Edit /etc/mysql/mariadb.conf.d/50-server.cnf
      # Instead of skip-networking the default is now to listen only on
      # localhost which is more compatible and is not less secure.
    - bind-address            = 127.0.0.1
    + bind-address            = 0.0.0.0
    
  3. Restart MariaDB:
    service mariadb restart
    
  4. If using a firewall you might need to open the MariaDB port, for example:
    ufw allow 3306/tcp
    ufw reload
    
  5. Prepare the Mattermost database (you need to use the same DB user password as your original instance, replace ‘db_user_password’)
    # root@new-server
    mysql
    
    CREATE DATABASE mattermost;
    CREATE USER 'mattermost'@'%' IDENTIFIED BY 'db_user_password';
    GRANT ALL PRIVILEGES ON mattermost.* TO 'mattermost'@'%';
    

Copy the data across

  1. On the old server, perform a database dump:
    # root@old-server
    mysqldump mattermost > mattermost_dump.sql
    
  2. Copy the mattermost_dump.sql file to the new server.
  3. On the new server, restore the data:
    # Note: I'm logging in with the 'mattermost' database user and requesting a password
    # prompt with '-p'. This isn't strictly necessary ('mysql mattermost' would work) but
    # it's a nice test that the user has the right permissions.
    cat mattermost_dump.sql | mysql -u mattermost -p mattermost
    

Switch Mattermost to the new MariaDB server

  1. On the old server, edit the Mattermost config /opt/mattermost/config/config.json – replacing ‘db_user_password’ and ‘my_db_ip_address’.
    "SqlSettings": {
        "DriverName": "mysql",
    -   "DataSource": "mattermost:db_user_password@tcp(localhost:58103)/mattermost?charset=utf8mb4,utf8\u0026readTimeout=30s\u0026writeTimeout=30s",
    +   "DataSource": "mattermost:db_user_password@tcp(my_db_ip_address:58103)/mattermost?charset=utf8mb4,utf8\u0026readTimeout=30s\u0026writeTimeout=30s",
        "DataSourceReplicas": [],
    
  2. Restart Mattermost:
    service mattermost restart
    

Final result

At this point your set up looks like this:

And you are free to run mmctl export create :slight_smile: