MySQL Replication stuck at ‘preparing’

innodbmariadbMySQLreplication

My MariaDB replication stuck at 'preparing'.
This happend after an update and restart of the server yesterday. Since then, replication is not working.

Setup: 2 MariaDB servers with master-master replication. Version: 10.4 (Upgraded few weeks ago from 10.1 – replication has worked after upgrade)

Since the output of both servers for SHOW SLAVE STATUS is similar, i am posting only from my first server:

MariaDB [(none)]> show slave status\G;
*************************** 1. row ***************************
                Slave_IO_State: NULL
                   Master_Host: data2
                   Master_User: replusr
                   Master_Port: 3306
                 Connect_Retry: 60
               Master_Log_File: mariadb-bin.018865
           Read_Master_Log_Pos: 14137515
                Relay_Log_File: relay-bin.017274
                 Relay_Log_Pos: 4
         Relay_Master_Log_File: mariadb-bin.018865
              Slave_IO_Running: Preparing
             Slave_SQL_Running: Yes
               Replicate_Do_DB:
           Replicate_Ignore_DB:
            Replicate_Do_Table:
        Replicate_Ignore_Table:
       Replicate_Wild_Do_Table:
   Replicate_Wild_Ignore_Table: 
                    Last_Errno: 0
                    Last_Error:
                  Skip_Counter: 0
           Exec_Master_Log_Pos: 14137515
               Relay_Log_Space: 768
               Until_Condition: None
                Until_Log_File:
                 Until_Log_Pos: 0
            Master_SSL_Allowed: No
            Master_SSL_CA_File:
            Master_SSL_CA_Path:
               Master_SSL_Cert:
             Master_SSL_Cipher:
                Master_SSL_Key:
         Seconds_Behind_Master: NULL
 Master_SSL_Verify_Server_Cert: No
                 Last_IO_Errno: 0
                 Last_IO_Error:
                Last_SQL_Errno: 0
                Last_SQL_Error:
   Replicate_Ignore_Server_Ids:
              Master_Server_Id: 2
                Master_SSL_Crl:
            Master_SSL_Crlpath:
                    Using_Gtid: No
                   Gtid_IO_Pos:
       Replicate_Do_Domain_Ids:
   Replicate_Ignore_Domain_Ids:
                 Parallel_Mode: conservative
                     SQL_Delay: 0
           SQL_Remaining_Delay: NULL
       Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it
              Slave_DDL_Groups: 0
Slave_Non_Transactional_Groups: 0
    Slave_Transactional_Groups: 0
1 row in set (0.000 sec)

ERROR: No query specified

Logs aren't showing anything and binaries are exploding since they cannot be rotated because the replication won't continue.

I've never seen something like that. Any ideas?

EDIT – How to downgrade to previous version:
This seems to be a bigger problem. See: https://downloads.mariadb.org/mariadb/10.4.6/

For all the others who have the same problem, follow these steps to downgrade (I'll give an example for 10.4.6, since this was my case):
Find the version you have used before and the related source: https://downloads.mariadb.org/mariadb/10.4.6/

After that, add it to your /etc/apt/sources.list:

deb [arch=amd64,ppc64el,arm64] http://mirrors.n-ix.net/mariadb/mariadb-10.4.6/repo/ubuntu/ xenial main

Downgrade:

apt install mariadb-server=1:10.4.6+maria~xenial mariadb-server-10.4=1:10.4.6+maria~xenial mariadb-client=1:10.4.6+maria~xenial mariadb-client-10.4=1:10.4.6+maria~xenial mariadb-server-core-10.4=1:10.4.6+maria~xenial mariadb-client-core-10.4=1:10.4.6+maria~xenial mysql-common=1:10.4.6+maria~xenial mariadb-client=1:10.4.6+maria~xenial libmariadb3=1:10.4.6+maria~xenial

Hold packages from upgrade, until fix is published:

apt-mark hold mariadb-server*

The steps are also explained here: https://jira.mariadb.org/browse/MDEV-20247?focusedCommentId=132114&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-132114

Best Answer

I also had the same issue using Mariadb 10.4 master-slave replication. I was using the setting innodb_thread_concurrency in the config file with a non-zero value. I updated it to:

innodb_thread_concurrency = 0

And now it's working again.