Why does MySQL need double-write buffer if there is redo log and undo log?
I read other posts that answer why MySQL needs double write buffer. They point to this article. http://dimitrik.free.fr/blog/archives/2011/01/mysql-performance-innodb-double-write-buffer-redo-log-size-impacts-mysql-55.html
and it will be impossible to repair it from the redo log as there are only changes saved within redo and not a whole page
That article states the above. But I still don't understand why.
Each page's block contains the LSN that was applied to it. Doesn't it? So, even if only some of the blocks of the page were written to disk due to a partial page write, I can look at the LSN associated with each block and detect if it was a partial write. If it was a partial write, I will replay the redo record for that LSN. The replay will give me the updated set of bytes to patch into the given offset range and I'll apply it to the blocks where the LSN wasn't applied previously.
Won't this work? Why do I need the double-write buffer?
Let's say the above does not work. But I can still use the undo log right? I could see that the page was partially updated, get the old value from the undo log and apply it to essentially rollback the transaction.
How does the redo log guarantee that a single log record is not partially written to disk if it crosses a block boundary?
Actually what I cannot figure out is that since a single redo log record can cross a block boundary, what mechanism does the redo log use to detect that the redo record was not fully written and truncate the log to the last known full log record instead of applying a partial log record?