What is Rollback and How Does It Work

June 6, 2018 at 7:16 pm by admin | Posted in Uncategorized

What is the role of rollback in database management system?

A rollback is a commonly used term in computer science for database management system. A database is used to store large amount of data. Data can be inserted, deleted, changed or modified in a database. There are various sets of instructions that are used in database to perform various operations; rollback is one of them. It means to undo a certain operation.

The process of rollback involves cancelling a set of transactions or a transaction and brings the database to its previous state before those particular transactions were performed. Rollbacks are usually done manually by the user but it can also be performed automatically by the device if it is programmed to do so in particular cases.

The rollback process can be controlled by companies that are engaged in cloud consulting, big data analytics consulting and product engineering services.

How does the concept of rollback work in database management system?

Let us say a database user has inserted a data in the database but hasn’t saved it yet. This data is temporarily available for the user to see. If the user saves the data, then it will be permanently stored in database and rollback cannot be performed in it. A commit operation will permanently save this data.

But after analyzing the data being inserted the user might change his or her mind regarding it and decide to delete the data. In that case, the rollback command is used. This rollback operation will eliminate any unsaved data entered by the user in the database and roll the database back to its previous state.

Rollbacks also take place automatically if a system crashes suddenly. Rollbacks happen automatically in case of a server crash, database crash or a sudden power loss. When the system is being restarted, all the logged transactions are analyzed; all the half-made entries in the database are rolled back so that the user can start afresh.

Pros of rollback in database management system:

Using rollback in database has its own advantages. Handling huge databases is quite complex as it contains lots of tables. Changes made in one table might affect the other one so if a slight change is being done in a particular table then subsequent changes needs to be done in related tables. After so many changes if the input inserted or the changes made are not plausible or appropriate then rolling back the database to its previous state is necessary. This brings the database back to a state where all the data inserted or changed till now are plausible and appropriate. There are no unsaved and inappropriate data in the database after rollback operation is being performed.

Cons of rollback in database management system:

So far we have seen that rollback brings a database back to its previous state at which all its previously inserted datum was committed that is stored permanently. Now if someone made some changes in a database and forgets to commit it, the unsaved data might get rolled back and the user will lose all of its newly inserted data. This is one small disadvantage. Once a database is rolled back there is no coming back from that.

Another disadvantage of rollbacks is cascading rollbacks. Suppose T1 is a transaction which is rolled back due to some reason, say failure. Now there is another transaction T2 which depends upon transaction T1. Since T1 is being rolled back so T2 also needs to be rolled back. Now if some other transaction depends upon T2 then that transaction also needs to be rolled back and so on, these leads to cascades of rollbacks. Cascading rollback incurs huge amount of overhead, time and energy. Databases with cascading rollbacks are always avoided.

In general, database recovery procedure yields cascade less rollbacks to eliminate cascading rollbacks.

What is roll forward in database management system?

Whenever a sudden system failure takes place, it shuts down temporarily. This results in loss of data in a database. As a result of which you might end up losing all the unsaved data. This is when roll forward comes into play. Whenever a system restarts from after a sudden system crash, roll forward takes control of the transaction logs and applies changes to the database of the particular transaction log in question. Basically what happens is roll forward operation tries to restore the state of the database before the system crash by restoring data from an old backup done previously. Since there can be millions of data in a huge database, roll forward operation might take a lot of time to complete its operation. However, if there is no back up of the database done previously then roll forward won’t have any old data to restore and you might lose all your unsaved data after the system restarts.

So, roll forward basically recovers the database from sudden failures and restores its previous state. The active transactions during the time system failure are all aborted.

Leave a Reply

Your email address will not be published. Required fields are marked *