From 385b144735307b4d57d2b44549644cd9397039d8 Mon Sep 17 00:00:00 2001 From: "xingying.1024" Date: Wed, 16 Oct 2024 22:00:41 +0800 Subject: [PATCH] PS-9462: The trx_sys->max_trx_id maintained during the startup phase of InnoDB may be incorrect. 1. Reading max_trx_id from page [0,5] may before page application. In this way, the read max_trx_id may be smaller than the true value. 2. This may cause the trx_id in the data record to be greater than trx_sys->max_trx_id. In the debug version, it will crash in ReadView::check_trx_id_sanity. --- storage/innobase/srv/srv0start.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc index e206b73e2f2d..ec988e400c21 100644 --- a/storage/innobase/srv/srv0start.cc +++ b/storage/innobase/srv/srv0start.cc @@ -2581,8 +2581,6 @@ innobase_start_or_create_for_mysql(void) if (err != DB_SUCCESS) return(srv_init_abort(err)); - purge_queue = trx_sys_init_at_db_start(); - if (srv_force_recovery < SRV_FORCE_NO_LOG_REDO) { /* Apply the hashed log records to the respective file pages, for the last batch of @@ -2591,9 +2589,13 @@ innobase_start_or_create_for_mysql(void) recv_apply_hashed_log_recs(TRUE); DBUG_PRINT("ib_log", ("apply completed")); + purge_queue = trx_sys_init_at_db_start(); + if (recv_needed_recovery) { trx_sys_print_mysql_binlog_offset(); } + } else { + purge_queue = trx_sys_init_at_db_start(); } if (recv_sys->found_corrupt_log) {