Concurrency Control 18.1: Schedules By Cancheevaram Kuppuswamy JaiSarvanan ID: 209.
Published byModified over 4 years ago
Presentation on theme: "Concurrency Control 18.1: Schedules By Cancheevaram Kuppuswamy JaiSarvanan ID: 209."— Presentation transcript:
Concurrency Control 18.1: Schedules By Cancheevaram Kuppuswamy JaiSarvanan ID: 209
Agenda What is Concurrency control? –What are Transactions? –Need for transactions? –How do they operate? Need for concurrency control? Schedules –Serial –Serializable Notation for Transactions and Schedules
Concurrency control The purpose of assuring that transactions preserve consistency when executing simultaneously is called concurrency control. The major theme of concurrency control is methods for forcing transactions to execute concurrently only in ways that make them appear to run one-at-a-time.
Transactions Transactions prevents the database state from becoming inconsistent. Serializability: one function executes completely before any other function begins. Atomicity: either all operations are done or neither is done. A transaction is a collection of one or more operations on the database that must be executed atomically and in serializable manner.
How transactions operate? 1.For a transaction to read a database element, that element must first be brought to a main-memory buffer(s), it is not already there. This is performed by the Buffer Manager. 2.Then, the contents of the buffer(s) can be read by the transaction into its own address space. 3.Writing of a new value for a database element by a transaction follows the reverse route.
Notation 1.INPUT(X): Copy database element X to a memory buffer. 2.READ(X,t): Assign the value of X (present in the memory buffer) to local variable t. 3.WRITE(X,t): Copy the value of t to X in the buffer. Note: If X is not present in the memory buffer, then INPUT is executed before performing READ or WRITE 4. OUTPUT(X): Copy the block containing X from its buffer to disk.
Need for concurrency control? Though transactions individually preserve the correctness of the state, Interactions among transactions can cause the state of the database to become inconsistent. When transactions run concurrently with other transactions, the correctness principle does not apply. Correctness principle: If a transaction executes in the absence of any other transactions, and it starts with the database in a consistent state, then the database is also in a consistent state when the transaction ends.
Schedules A schedule is a time-ordered sequence of the important read and write actions that takes place in the main- memory buffer. Operation: As transactions request reads and writes of database element, these requests are passed to the scheduler. Scheduler calls the buffer manager if the desired element is not in the buffer, either immediately or delay the request. Since different transactions can access a single memory buffer, when considering concurrency, only the READ and WRITE actions and their orders are important and we shall ignore the INPUT and OUTPUT actions.
Example: Consistency constraint is A=B T1T2 READ(A,t)READ(A,s) t := t + 100s := s*2 WRITE(A,t)WRITE(A,s) READ(B,t)READ(B,s) t := t + 100s := s*2 WRITE(A,t)WRITE(A,s)
Notation: –The transactions can be written as T1: r1(A); w1(A); r1(B); w1(B); T2: r2(A); w2(A); r2(B); w2(B); –The serializable schedule of T1 and T2 can be written as r1(A); w1(A); r2(A); w2(A); r1(B); w1(B); r2(B); w2(B);