@@ -59,18 +59,59 @@ xb_pid=`cat $pid_file`
5959echo " backup pid is $job_pid "
6060
6161run_inserts &
62-
63- # ER_IB_MSG_LOG_WRITER_WAIT_ON_CONSUMER
64- while ! grep -q " Redo log writer is waiting for" ${MYSQLD_ERRFILE} ; do
62+ inserts_pid=$!
63+
64+ # Wait for backpressure: with 8M capacity and the registered PXB/MEB
65+ # consumer pinned at the catch-up LSN, the server cannot reclaim redo
66+ # files. Exit on the first of: a consumer-lagging warning anchored on
67+ # the consumer name (avoids false matches from the prior backup's
68+ # log_checkpointer warnings), or PFS reporting >= 3 redo files (proof
69+ # we're past 8M with the consumer holding it back). Bound the wait so
70+ # MTR fails with diagnostics instead of Jenkins killing the job.
71+ max_wait_s=60
72+ for (( i= 1 ; i<= max_wait_s; i++ )) ; do
73+ if grep -qE " (Redo log writer is waiting for (PXB|MEB) redo log consumer|'(PXB|MEB)' consumer still lagging behind)" \
74+ ${MYSQLD_ERRFILE} ; then
75+ vlog " consumer-lagging warning observed in mysql error file"
76+ break
77+ fi
78+
79+ n_files=$( $MYSQL $MYSQL_ARGS -Ns -e \
80+ " SELECT COUNT(*) FROM performance_schema.innodb_redo_log_files" \
81+ 2> /dev/null || echo 0)
82+ if [ " ${n_files:- 0} " -ge 3 ] ; then
83+ vlog " redo log accumulated ${n_files} files;" \
84+ " consumer is holding the server back as expected"
85+ break
86+ fi
87+
88+ vlog " waiting for redo log backpressure" \
89+ " (#files=${n_files:- ?} , ${i} /${max_wait_s} s)"
6590 sleep 1
66- vlog " waiting for redo log writer message in mysql error file"
6791done
6892
93+ if [ ${i} -gt ${max_wait_s} ] ; then
94+ vlog " ERROR: timed out waiting for redo log backpressure"
95+ vlog " performance_schema.innodb_redo_log_files at timeout:"
96+ $MYSQL $MYSQL_ARGS -t -e \
97+ " SELECT file_id, start_lsn, end_lsn, is_full FROM performance_schema.innodb_redo_log_files ORDER BY file_id" \
98+ >&2 || true
99+ vlog " tail of mysqld error file ${MYSQLD_ERRFILE} :"
100+ tail -100 ${MYSQLD_ERRFILE} >&2 || true
101+ kill ${inserts_pid} 2> /dev/null || true
102+ kill -SIGCONT ${xb_pid} 2> /dev/null || true
103+ die " redo_log_consumer: timeout waiting for backpressure"
104+ fi
105+
69106# Resume the xtrabackup process
70107vlog " Resuming xtrabackup"
71108kill -SIGCONT $xb_pid
72109run_cmd wait $job_pid
73110
111+ # Stop background inserts before stop_server to avoid ERROR 2002 spam.
112+ kill ${inserts_pid} 2> /dev/null || true
113+ wait ${inserts_pid} 2> /dev/null || true
114+
74115xtrabackup --prepare --target-dir=$topdir /backup
75116
76117# PXB-3147 - register redo log consumer fails with ANSI_QUOTES
0 commit comments