UNDO and REDO database

2020 first blog, ha ha ha

Undo logging a value before the data is modified, it can be used to rollback (rollback) if the transaction fails;

Redo the modified value is a logging data block, the data can be used to restore the data file is not written in the transaction have been successfully updated.

By Undo / Redo operations may be implemented undo and redo process interface operation.

Undo changes will be restored before the user step by doing the operation of the program due to the changes, while Redo operation refers to re-implement this change.

Implementation Undo / Redo operations fall into two categories: data recording and recording operations.

Data recording means when the information editing window is open, save the original data, and recording the result every time the user operation data, data information editing here refers to all the data window changes may occur. When doing the procedure will undo the previous operation before the data passed to user information edit window corresponding controls . This approach is based on all of the data may change the space for time, in the end user does not have to consider what data has changed, anyway, every time replacement. When the amount of data stored in each relatively small, this is a more convenient, but if the amount of data, including such as graphics, video and other information, this method is more the cost of memory.

Recording operation refers to the information editing window is open, the recording operation of each user, including the specific operation and the operation to change the operation data, the data here means data restore operation can repeat both operations. Do undo operation program according to a user operation reverse recording process , the information editing window changes, and to do the operation redo procedures are repeated when the user's operation according to a user operation record . This approach is based on exchange space of time, the program information recorded fewer, each user only needs to record the type of operation and the associated operational data (such as the user to edit which control what content before and after editing controls are), other data unrelated to the operation need not be recorded. This approach than the recorded data will certainly be complex, but better than thrift memory.

Before recovery strategy system failure, multiple Undo if there was an operation, you need to restore data to the first failed transaction, if the forward scan log files, can not achieve this goal, so to echo scan log files; after a Redo for operation with a number of data need to recover data to the last successful transaction, so it should forward scan log files. Undo can not guarantee the success of the firm has submitted operations are canceled, and Redo can guarantee that the firm has successfully submitted the operations are complete, so the combination of the two ensures transaction atomicity ( or operations do or not do ); Redo can guarantee that the transaction as long as the submitted change must be permanently implemented Redo it can ensure the sustainability of the transaction ( a transaction once submitted, changes to the database will be permanent ).

Published 143 original articles · won praise 78 · views 40000 +

Guess you like

Origin blog.csdn.net/KK_2018/article/details/103793045