15.6. An Overview of a Page ChangeWe ask a lot of RDBMSs. We want them to be big and fast but to always ensure that the data is in a consistent state. To accomplish the speed requirement, they've got to keep lots of things in memory, but to ensure the integrity requirement, they've got to be very careful. It's difficult to juggle knives without cutting off a finger or two. Figure 15-4. Anatomy of a page changePlease refer to Figure 15-4 throughout this section. It shows that there are four main storage areas of an RDBMS. There is the datafile itself, the rollback log, the transaction log, and shared memory. Shared memory is further divided into the data buffer, the rollback log buffer, and the transaction log buffer. (Other elements could be in shared memory as well. Only relevant elements are listed here.) Not all RDBMSs work exactly this way, but they are all similar. What happens when a user enters a transaction? Before anything happens, the transaction and what it's going to change is recorded in the transaction log. Then, for each page that needs to be changed, the following steps are taken (note that the list's numbers relate to the numbers in the figure):
At some point, the transaction is committed. This fact is immediately recorded in the transaction log. That way, the system knows that the entire transaction completed, and should redo it in case of a system crash. This process ensures that no matter what time the system crashes (and it will crash), the system will remain in a consistent state. |