Assertion failure `m_status == DA_ERROR`
This assertion is observed only when both slave_transaction_retries and slave_preserve_commit_order is enabled on the replica server and is more likely to happen when slave_transaction_retries is set to a lower value.
In general, if a replication applier thread fails to execute a transaction because of an InnoDB deadlock or because the transaction's execution time exceeded InnoDB's innodb_lock_wait_timeout, it automatically retries slave_transaction_retries times before stopping with an error.
And when slave_preserve_commit_order is enabled, the replica server ensures that transactions are externalized on the replica in the same order as they appear in the replica's relay log, and prevents gaps in the sequence of transactions that have been executed from the relay log. If a thread's execution is completed before its preceding thread, then the executing thread waits until all previous transactions are committed before committing.
Similarly, when the waiting thread has locked the rows which are needed by the thread executing the preivous transaction, then the innodb deadlock detection algorithm kicks in and the preceding thread asks the waiting thread to rollback (only if its sequence number is lesser than that of the waiting thread).
When this happens, the waiting thread wakes up from the cond_wait and it gets to know that It was asked to roll back by the other transaction as it was holding a lock that is needed by the other transaction to progress, and goes ahead with retrying the transaction.
But just before the transaction is retried, the worker checks if it encountered any errors during its execution. If there is no error, it simulates ER_LOCK_DEADLOCK error in order for it to be considered as a temporary error so that the worker thread retries the transaction.
However, when the retries are exhausted, the worker thread logs an error into the error log by accessing the thread's diagnostic_area by calling `thd->get_stmt_da()->mysql_errno()`. If the error had been simulate (not called through `my_error` function call), the diagnostic_area would still be empty and thus making the assertion `DBUG_ASSERT(m_status == DA_ERROR);` to fail.