Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Tutorial on the methods of MySQL Innodb recovery

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces the "MySQL Innodb recovery method tutorial". In the daily operation, I believe that many people have doubts about the MySQL Innodb recovery method tutorial. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "MySQL Innodb recovery method tutorial"! Next, please follow the editor to study!

MySQL engine characteristics InnoDB crash recovery process

Enum {SRV_FORCE_IGNORE_CORRUPT = 1, / *! < let the server run even if it detects a corrupt page * / SRV_FORCE_NO_BACKGROUND = 2, / *! < prevent the main thread from running: if a crash would occur in purge, this prevents it * / SRV_FORCE_NO_TRX_UNDO = 3 / *! < do not run trx rollback after recovery * / SRV_FORCE_NO_IBUF_MERGE = 4, / *! < prevent also ibuf operations: if they would cause a crash, better not do them * / SRV_FORCE_NO_UNDO_LOG_SCAN = 5 / *! < do not look at undo logs when starting the database: InnoDB will treat even incomplete transactions as committed * / SRV_FORCE_NO_LOG_REDO = 6 / *! < do not do the log roll-forward in connection with recovery * /}

3 lsn in innodb

Innodb's lsn, like oracle's scn, is an important concept. such as

It is a condition for using low lsn as a linked list in flush list

Refer to lsn_t oldest_modification in buf_page_t

What is recorded in checkpoint is also lsn.

Reference macro

# define LOG_CHECKPOINT_NO 0#define LOG_CHECKPOINT_LSN 8#define LOG_CHECKPOINT_OFFSET 16#define LOG_CHECKPOINT_LOG_BUF_SIZE 24

Refresh lsn at the end of each block in the physical file

Reference macro FIL_PAGE_LSN

Lsn is also used as the standard when writing logs and setting down the disk.

Reference function log_write_up_to

In fact, lsn is the number of bytes of log volume, which is a cumulative value, which is shown in 5.7as follows:

/ * Type used for all log sequence number storage and arithmetics * / typedef ib_uint64_t lsn_t

And an 8-byte non-negative integer. The maximum value and the 64th power of 2. With this physical concept, lsn can easily be converted to the offset of the current log.

The following describes several lsn related to checkpoints

Lsn (flush lsn) in the first block FIL of ibdata: the next 8 bytes of ibdata are updated when innodb is cleanly closed, and will not be written if it is not closed properly (FIL_PAGE_FILE_FLUSH_LSN)

The lsn: redolog MLOG_CHECKPOINT lsn of MLOG_CHECKPOINT in redolog is written synchronously every time checkpoint. Clean shutdown will update.

Lsn in redolog header: is written asynchronously every time checkpoint is written after MLOG_CHECKPOINT write. Clean shutdown will update.

We express it as lsn1/lsn2/lsn3.

Normally close 3 lsn is equal, if not normally close innodb,lsn1 will not update, so lsn3 must not be equal to lsn1, then determine the need for carsh recovery.

If (checkpoint_lsn! = flush_lsn) {. If (! recv_needed_recovery) {ib::info ()

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report