当前位置:网站首页>MySQL transaction submission process

MySQL transaction submission process

2022-06-23 17:33:00 User 7353950

Yes binlog Of CR The way ( The key point is !!): Yes binlog Under the circumstances ,commit When the action begins , There will be one. Redo XID The action record of is written as redo, Then write data To binlog,binlog After writing successfully , Will binlog Of filename, Log write location position Write again redo(position I'll also write about pos In the document ), This indicates that the transaction is completed (committed). If only XID, There is no back filename and position, Means that the transaction is prepare state . technological process : commit; --> write XID to redo. --> write data to Binlog. --> write filename,postsion of binlog to redo. --> commited.

Record Binlog Is in InnoDB engine Prepare( namely Redo Log Write to disk ) after , This is crucial .

If the transaction crashes at different stages ,recovery Shi Huifa ——

crash The occurrence stage

State of affairs

Transaction results

When the transaction is prepare Stage crash

The transaction was not written to Binary log, The engine layer does not write redo To disk .

This transaction rollback.

When the transaction is binlog Writing stage crash

At this point, the engine layer redo Disk has been written , but Binlog The log has not been successfully written to disk .

This transaction rollback.

When the transaction is binlog After the log is written to the disk crash, But the engine layer didn't have time commit

At this point, the engine layer redo Disk has been written ,server layer binlog Disk has been written , but redo Transaction state in did not end correctly .

read out binlog Medium xid, And notify the engine layer to submit these XID The business of . After the engine submits these , Other transactions will be rolled back , Make the engine layer redo and binlog Logs are always consistent on transactions . Business passes through recovery Automatically complete the submission .

To sum up, if a transaction is in prepare Successful drop in stage , And in MySQL Server Layer. binlog Also write success , Then this matter must be commit success .

(redolog Write a successful && binlog Write a successful == commit, Be short of one cannot .)

原网站

版权声明
本文为[User 7353950]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/174/202206231642463987.html