what exactly happen when transaction commit but database crash

Viewed 214

A client sends a transaction to database like this:

begin transaction
sql1
sql2
sql3
...
end transaction (commit)

From my point of view, the database will follow the steps below:

  • Step1: receive commands one by one
  • Step2: execute commands one by one in memory
  • Step3: save result from memory into disk (redo log)
  • Step4: add commit flag in log when receive commit command
  • Step5: response success ack to client

My questions:

  • Is the description above right and accurate?
  • If it's right and accurate, what will happen when that database crashes between step4 and step5? In this situation, transaction commits successly but client receives no commit success ack. So client can't tell whether transaction commits successly.
0 Answers
Related