Method and system to efficiently abort a database transaction
Disclosed is an approach to autonomously abort a lower priority transaction that is blocking a higher priority transaction, where the lower priority transaction is holding a lock on a resource for which there is contention. Some approaches also provide an efficient way to implement identification of a blocker transaction, which drastically reduces the response time to abort the blocker transaction.
1 . A computer implemented method executed in a computerized database system to abort a database transaction, the computer-implemented method comprising:
configuring a first transaction priority level for a first database transaction comprising one or more computer operations executable in the computerized database system;
configuring a second transaction priority level for a second database transaction comprising one or more computer operations executable in the computerized database system, the first and second database transactions both requiring the same one or more rows within a table of a database of the computerized database system;
identifying that the first database transaction is blocking the second database transaction, wherein the first database transaction, by execution of a computer operation of the computerized database system, at least partially executes and is blocking the second database transaction from executing by holding a lock on the one or more rows within the table of the database;
determining if an abort condition of the second transaction priority level is higher than the first transaction priority level is met; and
aborting the first database transaction based at least in part on the abort condition being met, wherein aborting the first database transaction comprises executing a computer operation in the computerized database system that releases the lock held by the first database transaction to the one or more rows in the database table.
2 . The computer-implemented method of claim 1 , wherein the abort condition is based upon a time wait target for the second transaction priority level, wherein the abort condition is met upon expiration of the time wait target.
3 . The computer-implemented method of claim 1 , wherein a priority level for a database transaction is imposed by configuring the priority level for a session including the database transaction, and the priority level is inherited by the database transaction that is within the session.
4 . The computer-implemented method of claim 1 , wherein the first transaction priority level and the second transaction priority level are automatically configured based at least upon at least one of a service characteristic, a user characteristic, a data characteristic, or a query characteristic.
5 . The computer-implemented method of claim 1 , wherein blocker transaction identification is performed by at least one of querying a lock manager of the database system or checking a transaction table of the database system.
6 . The computer-implemented method of claim 1 , wherein a rule manager of the database system is consulted to determine whether the abort condition is met, the abort condition corresponding to a rule managed by the rule manager.
7 . The method of claim 1 , wherein the first database transaction is aborted by performing at least one computer operation to execute a session kill, a transaction abort, a voluntary abort, or a forced abort.
8 . The computer-implemented method of claim 1 , wherein the second database transaction subsequently accesses a row that was previously locked by the lock held by the first database transaction.
9 . The computer-implemented method of claim 1 , wherein the database comprises a relational database, and computer operations are executed using structured query language (SQL).
10 . The computer-implemented method of claim 6 , wherein rules managed by the rule manager govern when a blocking database transaction can be autonomously aborted in favor of higher priority database transaction.
11 . The computer-implemented method of claim 1 , wherein the first database transaction self-aborts based at least in part on the abort condition of the second transaction priority level being higher than the first transaction priority level being met.
12 . The computer-implemented method of claim 1 , the database of the computerized database system comprising a transactions table comprising respective columns for respective transaction entries identifying respective priority levels for respective transactions.
13 . A non-transitory computer program product embodied on a computer usable medium, the non-transitory computer readable medium having stored thereon a sequence of instructions which, when executed by a processor causes the processor to execute actions in a computerized database system to abort a database transaction, the actions comprising:
configuring a first transaction priority level for a first database transaction comprising one or more computer operations executable in the computerized database system;
configuring a second transaction priority level for a second database transaction comprising one or more computer operations executable in the computerized database system, the first and second database transactions both requiring the same one or more rows within a table of a database of the computerized database system;
identifying that the first database transaction is blocking the second database transaction, wherein the first database transaction, by execution of a computer operation of the computerized database system, at least partially executes and is blocking the second database transaction from executing by holding a lock on the one or more rows within the table of the database;
determining if an abort condition of the second transaction priority level is higher than the first transaction priority level is met; and
aborting the first database transaction based at least in part on the abort condition being met, wherein aborting the first database transaction comprises executing a computer operation in the computerized database system that releases the lock held by the first database transaction to the one or more rows in the database table.
14 . The non-transitory computer program product of claim 13 , wherein the abort condition is based upon a time wait target for the second transaction priority level, wherein the abort condition is met upon expiration of the time wait target.
15 . The non-transitory computer program product of claim 13 , wherein a priority level for a database transaction is imposed by configuring the priority level for a session including the database transaction, and the priority level is inherited by the database transaction that is within the session.
16 . The non-transitory computer program product of claim 13 , wherein the first transaction priority level and the second transaction priority level are automatically configured based at least upon at least one of a service characteristic, a user characteristic, a data characteristic, or a query characteristic.
17 . The non-transitory computer program product of claim 13 , wherein blocker transaction identification is performed by at least one of querying a lock manager of the database system or checking a transaction table of the database system.
18 . The non-transitory computer program product of claim 13 , wherein a rule manager of the database system is consulted to determine whether the abort condition is met, the abort condition corresponding to a rule managed by the rule manager.
19 . The non-transitory computer program product of claim 13 , wherein the first database transaction is aborted by performing at least one computer operation to execute a session kill, a transaction abort, a voluntary abort, or a forced abort.
20 . The non-transitory computer program product of claim 13 , wherein the second database transaction subsequently accesses a row that was previously locked by the lock held by the first database transaction.
21 . A computer-based system, comprising:
a computer processor to execute a set of program code instructions;
a memory to hold the program code instructions, in which the program code instructions comprises program code for executing a process to abort a database transaction by
configuring a first transaction priority level for a first database transaction comprising one or more computer operations executable in the computerized database system;
configuring a second transaction priority level for a second database transaction comprising one or more computer operations executable in the computerized database system, the first and second database transactions both requiring the same one or more rows within a table of a database;
identifying that the first database transaction is blocking the second database transaction, wherein the first database transaction, by execution of a computer operation of the computerized database system, at least partially executes and is blocking the second database transaction from executing by holding a lock on the one or more rows within the table of the database of the computerized database system;
determining if an abort condition of the second transaction priority level is higher than the first transaction priority level is met; and
aborting the first database transaction based at least in part on the abort condition being met, wherein aborting the first database transaction comprises executing a computer operation in the computerized database system that releases the lock held by the first database transaction to the one or more rows in the database table.
22 . The computer-based system of claim 21 , wherein the abort condition is based upon a time wait target for the second transaction priority level, wherein the abort condition is met upon expiration of the time wait target.
23 . The computer-based system of claim 21 , wherein a priority level for a database transaction is imposed by configuring the priority level for a session including the database transaction, and the priority level is inherited by the database transaction that is within the session.
24 . The computer-based system of claim 21 , wherein the first transaction priority level and the second transaction priority level are automatically configured based at least upon at least one of a service characteristic, a user characteristic, a data characteristic, or a query characteristic.
25 . The computer-based system of claim 21 , wherein blocker transaction identification is performed by at least one of querying a lock manager of the database system or checking a transaction table of the database system.
26 . The computer-based system of claim 21 , wherein a rule manager of the database system is consulted to determine whether the abort condition is met, the abort condition corresponding to a rule managed by the rule manager.
27 . The computer-based system of claim 21 , wherein the first database transaction is aborted by performing at least one computer operation to execute a session kill, a transaction abort, a voluntary abort, or a forced abort.
28 . The computer-based system of claim 21 , wherein the second database transaction subsequently accesses a row that was previously locked by the lock held by the first database transaction.