A Framework of Transaction Management in Distributed Database System Environment
A Framework of Transaction Management in Distributed Database System Environment
A Framework of Transaction Management in Distributed Database System Environment
Abstract: The main objective of the paper is to determine the transaction management
techniques in DDBMS for present time business applications. Distributed database systems
(DDBS) poses different problems when accessing distributed and replicated databases.
Particularly, access control and transaction management in DDBS require different
mechanism to monitor data retrieval and update to databases. It primarily concentrates on
the description of the used commit protocols in distributed database. Current trends in multi-
tier client/server networks make DDBS an appropriated solution to provide access to and
control over localized databases. Oracle, as a leading Database Management System
(DBMS) vendor employs the two-phase commit technique to maintain consistent state for
the database. There is an example given that demonstrate the steps involved in executing
the two-phase commit protocol. This transaction protocol will be beneficial for the
organizations to manage the enterprise data resource in DDBS environments efficiently.
Key words: Transaction management, two-phase commit, distributed database systems,
atomic commitment protocol (ACP) and Enhanced three phase commit (E3PC) etc.
*Assistant Professor, Adama Science & Technology University, Adama (OROMIA), Ethiopia
(Africa).
INTRODUCTION:
Distributed database systems are systems that have their data distributed and replicated
over several locations, not like the centralized database system, where one copy of the data
is stored. Data may be replicated over a network using horizontal and vertical fragmentation
similar to projection and selection operations in Structured Query Language (SQL). In other
words, Distributed database as a collection of multiple, logically interrelated databases
distributed over a computer network. A distributed database management system (DDBMS)
is then defined as the software system that permits the management of the distributed
database and makes the distribution transparent to the users. Sometimes “distributed
database system” (DDBS) is used to refer jointly to the distributed database and the
distributed DBMS. Both types of database share the same problems of access control and
transaction management, such as user concurrent access control and deadlock detection
and resolution. On the other hand, however, DDBS must also cope with different problems.
Access control and transaction management in DDBS require different rules to monitor data
retrieval and update to distributed and replicated databases. Oracle, as a leading Database
Management Systems (DBMS) employs the two-phase commit technique to maintain a
consistent state for the databases. The objective of this paper is to explain transaction
management in DDBMS and how Oracle implements this technique. To assist in
understanding this process, an example is given in the last section. It is hoped that this
understanding will encourage organizations to use and academics to discuss DDBS and to
successfully capitalize on this feature of Oracle. It provide discussions on the fundamentals
of transaction management, two-phase commit, Oracle’s implementation of the two phase
commit, and, finally, an example on how the two phases commit works.
FUNDAMENTALS OF TRANSACTION MANAGEMENT
Transaction Management deals with the problems of keeping the database in a consistent
state even when concurrent accesses and failures occurs, [1].
Transaction:
A transaction consists of a series of operations performed on a database. The important
issue in transaction management is that if a database was in a consistent state prior to the
initiation of a transaction, then the database should return to a consistent state after the
transaction is completed. This should be done irrespective of the fact that transactions were
successfully executed simultaneously or there were failures during the execution [2]. A
transaction is a sequence of operations that takes the database from a consistent state to
another consistent state. It represents a complete and correct computation.
Two types of transactions are allowed in our environment: query transactions and update
transactions. Query transactions consist only of read operations that access data objects
and return their values to the user. Thus, query transactions do not modify the database
state. Two transactions conflict if the read-set of one transaction intersects with the write-
set of the other transaction. During the voting process, Update transactions consist of both
read and write operations. Transactions have their time-stamps constructed by adding 1 to
the greater of either the current time or the highest time-stamp of their base variables.
Thus; a transaction is a unit of consistency and reliability. Each transaction has to terminate.
The outcome of the termination depends on the success or failure of the transaction. When
a transaction starts executing, it may terminate with one of two possibilities:
1.The transaction aborts if a failure occurred during its execution
2. The transaction commits if it was completed successfully example of a transaction that
aborts during process 2 (P2). On the other hand, an example of a transaction that commits,
since all of its processes are successfully completed [3].
Properties of Transactions
A Transaction has four properties that lead to the consistency and reliability of a distributed
data base. These are Atomicity, Consistency, Isolation, and Durability, [1, 3].
Atomicity
This refers to the fact that a transaction is treated as a unit of operation. Consequently, it
dictates that either all the actions related to a transaction are completed or none of them is
carried out. For example, in the case of a crash, the system should complete the remainder
of the transaction, or it will undo all the actions pertaining to this transaction. The recovery
of the transaction is split into two types corresponding to the two types of failures: the
transaction recovery, which is due to the system terminating one of the transactions
because of deadlock handling; and the crash recovery, which is done after a system crash or
a hardware failure.
Consistency
Referring to its correctness, this property deals with maintaining consistent data in a
database system. Consistency falls under the subject of concurrency control. For example,
“dirty data” is data that has been modified by a transaction that has not yet committed.
Thus, the job of concurrency control is to be able to disallow transactions from reading or
updating ‘dirty data’.
Isolation
According to this property, each transaction should see a consistent database at all times.
Consequently, no other transaction can read or modify data that is being modified by
another transaction. If this property is not maintained, one of two things could happen to
the data base. a. Lost Updates: this occurs when transaction (T2) updates the same data
being modified by the transaction (T1) in such a manner that T2 reads the value prior to the
writing of T1 thus creating the problem of loosing this update.
b. Cascading Aborts: this problem occurs when the first transaction (T1) aborts, then the
transactions that had read or modified data that has been used by T1 will also abort.
Durability
This property ensures that once a transaction commits, its results are permanent and
cannot be erased from the database. This means that whatever happens after the COMMIT
of a transaction, whether it is a system crash or aborts of other transactions, the results
already committed are not modified or undone.
1. DISTRIBUTED TRANSACTION MANAGEMENT
This section provides general background on the atomic commit problem and protocols.
1.1. Problem Definition
A distributed transaction is composed of several sub-transactions, each running on a
different site. The database manager at each site can unilaterally decide to abort the local
sub- transaction, in which case the entire transaction must be aborted. If all the
participating sites agree to commit their sub-transaction (vote Yes on the transaction) and
no failures occur, the transaction should be committed. I assume that the local database
server at each site can atomically execute the sub-transaction once it has agreed to commit
it. In order to ensure that all the sub-transactions are consistently committed or aborted,
the sites run an atomic commitment protocol such as two phases commit. The requirements
of atomic commitment [7]) are as follows:
AC1: Uniform Agreement: All the sites that reach a decision reach the same one.
AC2: A site cannot reverse its decision after it has reached one.
AC3: Validity: The commit decision can be reached only if all sites voted Yes.
AC4: Non-triviality: If there are no failures and all sites voted Yes, then the decision will be
to commit.
AC5: Termination: At any point in the execution of the protocol, if all existing failures are
repaired and no new failures occur for sufficiently long, then all sites will even- tually reach
a decision.
The Prepare and Commit Phases
Prepare Phase
The first phase in committing a distributed transaction is the prepare phase in which the
commit of the transaction is not actually carried out. Instead, all nodes referenced in a
distributed transaction (except one, known as the commit point site) are told to prepare (to
commit). By preparing, a node records enough information so that it can subsequently
either commit or abort the transaction (in which case, a rollback will be performed),
regardless of intervening failures. Prepare phase; the global coordinator (initiating node)
asks participants to prepare (to promise to commit or rollback the transaction, even if there
is a failure).
Commit phase; if all participants respond to the coordinator that they are prepared, the
coordinator asks all nodes to commit the transaction. If any participants cannot prepare, the
coordinator asks all nodes to roll back the transaction.
When a node responds to its requestor that it has prepared, the prepared node has made a
promise to be able to either commit or roll back the transaction later and not to make a
unilateral decision on whether to commit or roll back the transaction [6].
Queries that start after a node has prepared cannot access the associated locked data until
all phases are complete (an insignificant amount of time unless a failure occurs). When a
node is told to prepare, it can respond with one of three responses:
Prepare Phase Actions by Nodes
To complete the prepare phase, each node performs the following actions:
Again, this enforces the primary rule of a distributed transaction. All nodes involved in the
transaction either all commit or all roll back the transaction at the same logical time.
Commit Phase
The second phase in committing a distributed transaction is the commit phase. Before this
phase occurs, all nodes referenced in the distributed transaction have guaranteed that they
have the necessary resources to commit the transaction. That is, they are all prepared.
Therefore, the commit phase consists of the following steps [6]:
1. The global coordinator sends a message to all nodes telling them to commit the
transaction.
2. At each node, Oracle commits the local portion of the distributed transaction (releasing
locks) and records an additional redo entry in the local redo log, indicating that the
transaction has committed. When the commit phase is complete, the data on all nodes of
the distributed system are consistent with one another. A variety of failure cases, caused by
network or system failures, are possible during both the prepare phase and the commit
phase.
1.2. Two Phase Commit
The simplest and most renowned atomic commitment protocol (ACP) is two phases commit
[7]. Several variations of 2PC have been suggested (e.g., presume abort and presume
commit); the simplest version is centralized; one of the sites is designated as the
coordinator. The coordinator sends a transaction (or request to prepare to commit) to all
the participants. Each site answers by a Yes (“ready to commit'') or by a No (“abort'')
message. If any site votes No, all the sites abort.
The 2-phase commit (2PC) protocol is a distributed algorithm to ensure the consistent
termination of a transaction in a distributed environment. Thus, via 2PC a unanimous
decision is reached and enforced among multiple participating servers whether to commit
or abort a given transaction, thereby guaranteeing atomicity. The protocol proceeds in two
phases, namely the prepare and the commit phase, which explains the protocol‘s name. The
protocol is executed by a coordinator process, while the participating servers are called
participants. When the transaction‘s initiator issues a request to commit the transaction,
the coordinator starts the first phase of the 2PC protocol by querying—via prepare
messages—all participants whether to abort or to commit the transaction The master
initiates the first phase of the protocol by sending PREPARE (to commit) messages in parallel
to all the cohorts. Each cohort that is ready to commit first force-writes a prepare log record
to its local stable storage and then sends a YES vote to the master. At this stage, the cohort
has entered a prepared state wherein it cannot unilaterally commit or abort the transaction
but has to wait for the final decision from the master. On the other hand, each cohort that
decides to abort force-writes an abort log record and sends a NO vote to the master. Since a
NO vote acts like a veto, the cohort is permitted to unilaterally abort the transaction
without waiting for a response from the master. After the master receives the votes from all
the cohorts, it initiates the second phase of the protocol. If all the votes are YES, it moves to
a committing state by force writing a commit log record and sending COMMIT messages to
all the cohorts. Each cohort after receiving a COMMIT message moves to the committing
state, force-writes a commit log record, and sends an ACK message to the master. If the
master receives even one NO vote, it moves to the aborting state by force-writing an abort
log record and sends ABORT messages to those cohorts that are in the prepared state.
These cohorts, after receiving the ABORT message, move to the aborting state, force write
an abort log record and send an ACK message to the master [8].
Finally, the master, after receiving acknowledgements from all the prepared cohorts, writes
an end log record and then ―forgets‖ the transaction. The 2PC may be carried out with one
of the following methods: Centralized 2PC, Linear 2PC, and Distributed 2PC, [3].
1.3. The Centralized Two-Phase Commit Protocol
In the Centralized 2PC shown in Figure 3, communication is done through the coordinator‘s
process only, and thus no communication between subordinates is allowed. The coordinator
is responsible for transmitting the PREPARE message to the subordinates, and, when the
votes of all the subordinates are received and evaluated, the coordinator decides on the
course of action: either abort or COMMIT. This method has two phases:
1. First Phase: In this phase, when a user wants to COMMIT a transaction, the coordinator
issues a PREPARE message to all the subordinates, (Mohan et al., 1986). When a
subordinate receives the PREPARE message, it writes a PREPARE log and, if that subordinate
is willing to COMMIT, sends a YES VOTE, and enters the PREPARED state; or, it writes an
abort record and, if that subordinate is not willing to COMMIT, sends a NO VOTE. A
subordinate sending a NO VOTE doesn‘t need to enter a PREPARED state since it knows that
the coordinator will issue an abort. In this case, the NO VOTE acts like a veto in the sense
that only one NO VOTE is needed to abort the transaction. The following two rules apply to
the coordinator‘s decision, *3].
a. If even one participant votes to abort the transaction, the coordinator has to reach a
global abort decision.
b. If all the participants vote to COMMIT, the coordinator has to reach a global COMMIT
decision.
2. Second Phase: After the coordinator reaches a vote, it has to relay that vote to the
subordinates. If the decision is COMMIT, then the coordinator moves into the committing
state and sends a COMMIT message to all the subordinates informing them of the COMMIT.
When the subordinates receive the COMMIT message, they, in turn, move to the
committing state and send an acknowledge (ACK) message to the coordinator. When the
coordinator receives the ACK messages, it ends the transaction. If, on the other hand, the
coordinator reaches an ABORT decision, it sends an ABORT message to all the subordinates.
Here, the coordinator doesn‘t need to send an ABORT message to the subordinate(s) that
gave a NO VOTE.
1.4. The Linear Two-Phase Commit Protocol
In the linear 2PC, as depicted in Figure 4, subordinates can communicate with each other.
The sites are labeled 1 to N, where the coordinator is numbered as site 1. Accordingly, the
propagation of the PREPARE message is done serially. As such, the time required to
complete the transaction is longer than centralized or distributed methods. Finally, node N
is the one that issues the Global COMMIT. The two phases are discussed below, [3]:
First Phase: The coordinator sends a PREPARE message to participant 2. If participant 2 is
not willing to COMMIT, then it sends a VOTE ABORT (VA) to participant 3 and the
transaction is aborted at this point. If participant 2, on the other hand, is willing to commit,
it sends a VOTE COMMIT (VC) to participant 3 and enters a READY state. In turn, participant
3 sends its vote till node N is reached and issues its vote.
Second Phase: Node N issues either a GLOBAL ABORT (GA) or a GLOBAL COMMIT (GC) and
sends it to node N-1. Subsequently, node N-1 will enter an ABORT or COMMIT state. In turn,
node N-1 will send the GA or GC to node N-2, until the final vote to commit or abort reaches
the coordinator, node .
site is in a committable state only if it knows that all the sites have agreed to proceed with
the trans-action. The rest of the states are non-committable. The only committable state in
2PC is the commit state. The second dimension distinguishes between final and non-final
states. The final states are the ones in which a decision has been made and no more state
transitions are possible. The final states in 2PC are commit and abort, [7].
The Commit Point Site
The job of the commit point site is to initiate a commit or roll back as instructed by the
global coordinator. The system administrator always designates one node to be the commit
point site in the session tree by assigning all nodes commits point strength. The node
selected as commit point site should be that node that stores the most critical data (the
data most widely used) The commit point site is distinct from all other nodes involved in a
distributed transaction with respect to the following two issues:
1. The commit point site never enters the prepared state. This is potentially advantageous
because if the commit point site stores the most critical data, this data never remains in-
doubt, even if a failure situation occurs. (In failure situations, failed nodes remain in a
prepared state, holding necessary locks on data until in-doubt transactions are resolved.)
2. In effect, the outcome of a distributed transaction at the commit point site determines
whether the transaction at all nodes is committed or rolled back. The global coordinator
ensures that all nodes complete the transaction the same way that the commit point site
does. A distributed transaction is considered to be committed once all nodes are prepared
and the transaction has been committed at the commit point site (even though some
participating nodes may still be only in the prepared state and the transaction not yet
actually committed). The commit point site’s redo log is updated as soon as the distributed
transaction is committed at that node, [6]. Likewise, a distributed transaction is considered
not committed if it has not been committed at the commit point site.
Failures that Interrupt Two-Phase Commit
The user program that commits a distributed transaction is informed of a problem by one of
the following error messages:
ORA-02050: transaction ID rolled back,
some remote dbs may be in-doubt
ORA-02051: transaction ID committed,
example, to set the time-out interval for an instance to 30 seconds, include the following
line in the associated parameter file:
DISTRIBUTED_LOCK_TIMEOUT=30
With the above time-out interval, the time-out errors discussed in the previous section
occur if a transaction cannot proceed after 30 seconds of waiting for unavailable resources.
1.6. Quorums
In order to reduce the extent of blocking in replication and atomic commit protocols,
majority votes or quorums are often used. A quorum system is a generalization of the
majority concept. Enhanced three phase commit (E3PC), like Skeen's quorum-based three
phase commit protocol , uses a quorum system to decide when a group of connected sites
may resolve the transaction. To enable maximum flexibility the quorum system may be
elected in a variety of ways (e.g., weighted voting). The quorum system is static; it does not
change in the course of the protocol. The predicate Q(S) is true for a given subset S of the
sites iff S is a quorum. The requirement from this predicate is that for any two sets of sites S
and S’ such that S⋂S’=Φ, at most one of Q(S) and Q(S’) holds, i.e., every pair of quorums
intersect. For example, in the simple majority quorum system Q(S) is true iff |S|>n/2, where
n is the total number of sites running the protocol. Numerous quorum systems that fulfill
these criteria were suggested. An analysis of the availability of different quorum systems
may be found in, [9].
For further flexibility, it is possible to set different quorums for commit and abort (this idea
was presented in [7]). In this case, a commit quorum of connected sites is required in order
to commit a transaction, and an abort quorum is required to abort. For example, to increase
the probability of commit in the system, one can assign smaller quorums for commit and
larger ones for abort. In this case, the quorum system consists of two predicates: QC(G) is
true for a given group of sites G iff G is a commit quorum, and QA(G) is true iff G is an abort
quorum. The requirement from these predicates is that for any two groups of sites G and G’
such that G&G’=Φ, at most one of QC(G) and QA(G’) holds, i.e., every commit quorum
intersects every abort quorum.
1.7. The Extent of Blocking in Commit Protocols
The 2PC protocol is an example of a blocking protocol,[7]: operational sites sometimes wait
on the recovery of failed sites.
Locks must be held in the database while the transaction is blocked. Even though blocking
preserves consistency, it is highly undesirable because the locks acquired by the blocked
transaction cannot be relinquished, render- ing the data inaccessible by other requests.
Consequently, the availability of data stored in reliable sites can be limited by the availability
of the weakest component in the distributed system; [7] proved that there exists no non-
blocking protocol resilient to network partitioning. When a partition occurs, the best
protocols allow no more than one group of sites to continue while the remaining groups
block. Skeen suggested the quorum-based three phase commit protocol, which maintains
consistency in spite of network partitions. This protocol is blocking in case of partitions; it is
possible for an operation site to be blocked until a failure is mended. In case of failures, the
algorithm uses a quorum (or majority)-based recovery procedure that allows a quorum to
resolve the transaction. If failures cascade, however, a quorum of sites can become
connected and still remain blocked.
Since completely non-blocking recovery is impossible to achieve, further research in this
area concentrated on minimizing the number of blocked sites when partitions occur. define
optimal termination protocols (recovery procedures) in terms of the average number of
sites that are blocked when a partition occurs. The average is over all the possible partitions
and all the possible states in the protocol in which the partitions occur. The analysis deals
only with states in the basic commit protocol and ignore the possibility for cascading failures
(failures that occur during the recovery procedure). It is proved that any ACP with optimal
recovery procedures takes at least three phases and that the quorum-based recovery
procedures are optimal. I construct an ACP that always allows a connected majority to
proceed, regardless of past failures. To our knowledge, no other ACP with this feature was
suggested. The ACP suggested in uses a reliable replication service as a building block and is
mainly suitable for replicated database systems. In this paper, I present a novel commitment
protocol, enhanced three phase commit, which always allows a connected majority to
resolve the transaction (if it remains connected for sufficiently long). E3PC does not require
complex building blocks, and is more adequate for partially replicated or non replicated
distributed database systems; it is based on the quorum-based three phase commit, [7].
AN EXAMPLE OF A DISTRIBUTED DATABASE SYSTEM
Fig. 2 illustrates the steps homogenous distributed database performs in order to PREPARE,
Select the COMMIT Point Site, and COMMIT. The example in the figure depicts a company
that has several branches located in different cities numbered A to G. Each site has to have
access to most of the data in the company in order to check on the status of purchase
orders, material acquisition, and several other issues. Since new projects are awarded and
older projects are completed, project sites tend to change locations. Also, depending on the
size and duration of a project, different COMMIT point strength can be assigned and thus, in
the same area, different COMMIT point sites can be chosen, for a given location, over a
period of time. In this example, City E is the head office and thus posses the highest
COMMIT point strength. The other sites are assigned the COMMIT point strength based on
the rupee volume of the project. Higher monetary value for a project requires more
resource allocation, and as such, will lead to more transactions executed against the data
for that project. Since the amount of data involved is large, each site will have the portion of
the database pertaining to its operations replicated and stored on a local server. Any
transaction will at least affect the database at the head office and one of the sites. If, for
example, a material rate, description of an item, accomplished progress, or purchase order
is entered, a transaction is initiated that will affect the database at the head office and the
database at the concerned site, [3].
hoped that this paper to will assist organization in the implementation of distributed
databases when installing homogenous DBMS, or give confidence organizations to journey
from centralized to distribute DBMS, [7]. Organizations could also contribute to this process
by having graduates with the knowledge of homogeneous DBMS capability.
This paper demonstrates, how the commit protocols can be made more efficient and simply
by maintaining two additional counters and by changing the decision rule and defines the
distributed transaction management in efficient way with others necessary factors. The new
protocol, E3PC, always allows a quorum of connected sites to resolve a transaction: At any
point in the execution of the protocol, if a group G of sites becomes connected and this
group contains a quorum of the sites, and no subsequent failures occur for sufficiently long,
then all the members of G eventually reach to a decision.
REFERENCES
[1] Ozsu, Tamer M., and Valduriez, Patrick [1991], Principles of Distributed Database
Systems,
Prentice Hall.
*2+ Ghazi Alkhatib and Ronny S. Labban “Transaction Management in Distributed
Database
Systems: the Case of Oracle’s Two-Phase Commit” Journal of Information Systems
Education, Vol. 13(2)
[3] Ashish Srivastava1, Udai Shankar2, Sanjay Kumar Tiwari3, “ Transaction
Management in
Homogenous Distributed Real-Time Replicated Database Systems”, Volume 2, Issue
6,
June 2012.
[4] S. Ceri, M.A.W. Houtsma, A.M. Keller, P. Samarati: A Classification of Update
Methods for
Replicated Databases, via Internet, May 5, 1994.
[5] D. Agrawal, A.El. Abbadi: The Tree Quorum Protocol: An Efficient Approach for
Managing
Replicated Data. in Proc. of VLDB Conf. pp 243-254, 1990.
[6] Oracle8 Server Distributed Database Systems [1997], Oracle, 3-1 – 3-35
*7+ Idit Keidar and Danny Dolev, “Increasing the Resilience of Distributed and
Replicated Database Systems”, Journal of Computer and System Sciences 57, 309-324
(1998).
*8+ Khake Asha, Gojamgunde Ashwini, Shastri Ashlesha and Biradar Usha, “Transaction
Management in Distributed Database”, BIOINFO Transactions on Database Systems
Volume 1, Issue 1, 2011, pp-01-06.
[9] D. Peleg and A. Wool, Availability of quorum systems, Inform. Comput. 123 (1995),
210-223.