简体   繁体   中英

why can't detect the change of ibd file on Manjaro?

My mother language isn't English. Sorry: :(

Question BackGround

I want to see the change of the ibd file when I insert record into table of mysql database. So I do some action like this:

  1. First, I install MariaDB on my manjaro system and create a demo table like this
CREATE TABLE demo1 (c1 varchar) charset=ascii;
  1. Secondary, I install Imhex to open ibd file and want to see the hex data of ibd file.

The step 2 had permission problem, because /var/lib/mysql can't access throught normal user. So I exec sudo chmod -R mysql.mysql /var/lib/mysql* and add my login user to mysql group by usermod -a -G mysql huang (huang is my login user name).

Question

When I open idb file by Imhex, I insert four record into demo1

insert into demo1 values('aaa'),('bbb'), ('ccc'), ('ddd');

But I doesn't found any change of ibd file. However, when I exec systemctl stop mysqld , the Ibd file change immediately.

在此处输入图像描述

I already check innodb-flush-log-at-trx-commit and sync_binlog , they are 1 . And I check autocommit is on , and I exec flush tables after insert. But doesn't work:(

This question doesn't happen when I use window system. I do this with mysql and Imhex on window, and I can see the change immediately after insert without stop mysql server.

It make me confuse,., I'm guessing it's a permissions issue with the Linux system, If someone know the reason. Please tell me , thanks!

When you insert or update rows in an InnoDB table, InnoDB flushes the record of the change to the redo log ( ib_logfile[12] ) immediately, but it does not necessarily flush the rows to the tablespace (the .ibd file corresponding to the tablespace). It keeps a copy of the changed page in RAM, in the InnoDB buffer pool. This will be flushed to disk in time, as InnoDB gets around to it.

When you do a clean shutdown of mysqld, all buffered pages are flushed to their respective tablespaces. This is why it might take a long time to shutdown mysqld depending on how much traffic your database has had; there might be a lot of modified pages to flush. Until this happens, it's up to InnoDB to copy the changed pages to the tablespace.

I don't recommend poking around in the .ibd file with a hex editor unless you know what you're doing. It's surprisingly complex, and usually not necessary to use InnoDB. Questions about these internals are beyond the scope of the type of questions that are encouraged on Stack Overflow.

You might like to read the blogs of Jeremy Cole. He spent many months studying the InnoDB code and he produced a series of blog articles about the internal structure of InnoDB files: https://blog.jcole.us/innodb/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM