Computer Science Engineering (CSE) Exam  >  Computer Science Engineering (CSE) Tests  >  Test: Transactions & Concurrency Control- 1 - Computer Science Engineering (CSE) MCQ

Test: Transactions & Concurrency Control- 1 - Computer Science Engineering (CSE) MCQ


Test Description

20 Questions MCQ Test - Test: Transactions & Concurrency Control- 1

Test: Transactions & Concurrency Control- 1 for Computer Science Engineering (CSE) 2024 is part of Computer Science Engineering (CSE) preparation. The Test: Transactions & Concurrency Control- 1 questions and answers have been prepared according to the Computer Science Engineering (CSE) exam syllabus.The Test: Transactions & Concurrency Control- 1 MCQs are made for Computer Science Engineering (CSE) 2024 Exam. Find important definitions, questions, notes, meanings, examples, exercises, MCQs and online tests for Test: Transactions & Concurrency Control- 1 below.
Solutions of Test: Transactions & Concurrency Control- 1 questions in English are available as part of our course for Computer Science Engineering (CSE) & Test: Transactions & Concurrency Control- 1 solutions in Hindi for Computer Science Engineering (CSE) course. Download more important topics, notes, lectures and mock test series for Computer Science Engineering (CSE) Exam by signing up for free. Attempt Test: Transactions & Concurrency Control- 1 | 20 questions in 60 minutes | Mock test for Computer Science Engineering (CSE) preparation | Free important questions MCQ to study for Computer Science Engineering (CSE) Exam | Download free PDF with solutions
Test: Transactions & Concurrency Control- 1 - Question 1

Consider the following transactions with data items P and Q initialized to zero:

Any non-serial interleaving of T1 and T2 for concurrent execution leads to

Test: Transactions & Concurrency Control- 1 - Question 2

Which of the following concurrency control protocols ensure both conflict serialzability and freedom from deadlock?
I. 2-phase locking
II. Time-stamp ordering

Detailed Solution for Test: Transactions & Concurrency Control- 1 - Question 2

2 Phase Locking (2PL) is a concurrency control method that guarantees serializability. The protocol utilizes locks, applied by a transaction to data, which may block (interpreted as signals to stop) other transactions from accessing the same data during the transaction’s life. 2PL may be lead to deadlocks that result from the mutual blocking of two or more transactions. See the following situation, neither T3 nor T4 can make progress.

Timestamp-based concurrency control algorithm is a non-lock concurrency control method. In Timestamp based method, deadlock cannot occur as no transaction ever waits.

1 Crore+ students have signed up on EduRev. Have you? Download the App
Test: Transactions & Concurrency Control- 1 - Question 3

Consider the following schedule for transactions T1, T2 and T3:

Q. Which one of the schedules below is the correct serialization of the above?

Detailed Solution for Test: Transactions & Concurrency Control- 1 - Question 3

T1 can complete before T2 and T3 as there is no conflict between Write(X) of T1 and the operations in T2 and T3 which occur before Write(X) of T1 in the above diagram.
T3 should can complete before T2 as the Read(Y) of T3 doesn’t conflict with Read(Y) of T2. Similarly, Write(X) of T3 doesn’t conflict with Read(Y) and Write(Y) operations of T2.
Another way to solve this question is to create a dependency graph and topologically sort the dependency graph. After topologically sorting, we can see the sequence T1, T3, T2.

Test: Transactions & Concurrency Control- 1 - Question 4

Consider the following four schedules due to three transactions (indicated by the subscript) using read and write on a data item x, denoted by r(x) and w(x) respectively. Which one of them is conflict serializable.

Detailed Solution for Test: Transactions & Concurrency Control- 1 - Question 4

CONCEPT

A schedule is called conflict serializable if it can be transformed into a serial schedule by swapping non-conflicting operations.

For a schedule to be conflict serializable, there should be no cycle present in its precedence graph.

EXPLANATION: 

Option_1 – Not conflict serializable




Test: Transactions & Concurrency Control- 1 - Question 5

Consider the following schedule S of transactions T1, T2, T3, T4:


Q. Which one of the following statements is CORRECT?

Detailed Solution for Test: Transactions & Concurrency Control- 1 - Question 5

To check for conflict-serializable, we need to make a precedence graph, if the graph contains a cycle, then it's not conflict serializable, else it is. Here, for the precedence graph there will be only two directed edges, one from T2 -> T3 (Read- Write Conflict), and another from T2 -> T1(Read- Write Conflict), hence no cycle, so the schedule is conflict serializable. Now to check for Recoverable, we need to check for a dirty-read operation(Write by Transaction Ti, followed by Read by Transaction Tj but before Ti commits) between any pair of operations. If no dirty-read then recoverable schedule, if a dirty read is there then we need to check for commit operations. Here no dirty read operation (as T3 and T1 commits before T4 reads the Write(X) of T3 and T1 , and T2 commits before T4 reads the Write(Y) of T2). Therefore the schedule is recoverable. Hence, Option C.

Test: Transactions & Concurrency Control- 1 - Question 6

Consider the transactions T1, T2, and T3 and the schedules S1 and S2 given below.

Q. Which one of the following statements about the schedules is TRUE?

Detailed Solution for Test: Transactions & Concurrency Control- 1 - Question 6

For conflict serializability of a schedule(which gives same effect as a serial schedule) we should check for conflict operations, which are Read-Write, Write-Read and Write-Write between each pair of transactions, and based on those conflicts we make a precedence graph, if the graph contains a cycle, it's not a conflict serializable schedule. To make a precedence graph: if Read(X) in Ti followed by Write(X) in Tj (hence a conflict ), then we draw an edge from Ti to Tj (Ti -> Tj) If we make a precedence graph for S1 and S2 , we would get directed edges for S1 as T2->T1, T2->T3, T3->T1, and for S2 as T2->T1, T2->T3, T3->T1, T1->T2. In S1 there is no cycle, but S2 has a cycle. Hence only S1 is conflict serializable. Note : The serial order for S1 is T2 -> T3 -> T1.

Test: Transactions & Concurrency Control- 1 - Question 7

Consider the following log sequence of two transactions on a bank account, with initial balance 12000, that transfer 2000 to a mortgage payment and then apply a 5% interest.

1. T1 start
2. T1 B old=12000 new=10000
3. T1 M old=0 new=2000
4. T1 commit
5. T2 start
6. T2 B old=10000 new=10500
7. T2 commit

Q. Suppose the database system cra shes just before log record 7 is written. When the system is restarted, which one statement is true of the recovery procedure?

Detailed Solution for Test: Transactions & Concurrency Control- 1 - Question 7

We must undo log record 6 to set B to 10000 and then redo log records 2 and 3 bcoz system fail before commit operation. So we need to undone active transactions(T2) and redo committed transactions (T1) Note:Here we are not using checkpoints. Checkpoint : Checkpoint is a mechanism where all the previous logs are removed from the system and stored permanently in a storage disk. Checkpoint declares a point before which the DBMS was in consistent state, and all the transactions were committed. Recovery: When a system with concurrent transactions crashes and recovers, it behaves in the following manner − =>The recovery system reads the logs backwards from the end to the last checkpoint. =>It maintains two lists, an undo-list and a redo-list. =>If the recovery system sees a log with and or just , it puts the transaction in the redo-list. =>If the recovery system sees a log with but no commit or abort log found, it puts the transaction in undo-list. All the transactions in the undo-list are then undone and their logs are removed. All the transactions in the redo-list and their previous logs are removed and then redone before saving their logs. So Answer is B redo log records 2 and 3 and undo log record 6

Test: Transactions & Concurrency Control- 1 - Question 8

Which of the following scenarios may lead to an irrecoverable error in a database system ?

Detailed Solution for Test: Transactions & Concurrency Control- 1 - Question 8

Option C is a normal operation. Option B is also fine as no write operation is involved. Option A can be recovered, but option D can't be. See this for an example.

Test: Transactions & Concurrency Control- 1 - Question 9

Consider three data items D1, D2 and D3 and the following execution schedule of transactions T1, T2 and T3. In the diagram, R(D) and W(D) denote the actions reading and writing the data item D respectively.


Q.  Which of the following statements is correct?

Detailed Solution for Test: Transactions & Concurrency Control- 1 - Question 9

T1 and T2 have conflicting operations between them forming a cycle in the precedence graph. R(D2) of T2, and W(D2) of T1 (Read-Write Conflict) R(D1) of T1, and W(D1) of T2 (Read-Write Conflict) Hence in the precedence graph of the schedule there would be a cycle between T1 and T2 vertices. Therefore not a serializable schedule.

Test: Transactions & Concurrency Control- 1 - Question 10

Consider the following transaction involving two bank accounts x and y.

read(x); x := x – 50; write(x); read(y); y := y + 50; write(y)

The constraint that the sum of the accounts x and y should remain constant is that of

Detailed Solution for Test: Transactions & Concurrency Control- 1 - Question 10

Consistency in database systems refers to the requirement that any given database transaction must only change affected data in allowed ways, that is sum of x and y must not change.

Test: Transactions & Concurrency Control- 1 - Question 11

Consider a simple checkpointing protocol and the following set of operations in the log.

(start, T4); (write, T4, y, 2, 3); (start, T1); (commit, T4); (write, T1, z, 5, 7);
(checkpoint);
(start, T2); (write, T2, x, 1, 9); (commit, T2); (start, T3); (write, T3, z, 7, 2);
 

Q. If a crash happens now and the system tries to recover using both undo and redo operations, what are the contents of the undo list and the redo list

Detailed Solution for Test: Transactions & Concurrency Control- 1 - Question 11

Since T1 and T3 are not committed yet, they must be undone. The transaction T2 must be redone because it is after the latest checkpoint.

Test: Transactions & Concurrency Control- 1 - Question 12

Consider the following partial Schedule S involving two transactions T1 and T2. Only the read and the write operations have been shown. The read operation on data item P is denoted by read(P) and the write operation on data item P is denoted by write(P).


Q. Suppose that the transaction T1 fails immediately after time instance 9. Which one of the following statements is correct?

Detailed Solution for Test: Transactions & Concurrency Control- 1 - Question 12

if transaction fails, atomicity requires effect of transaction to be undone. Durability states that once transaction commits, its change cannot be undone (without running another, compensating, transaction). Recoverable schedule: A schedules exactly where, for every set of transaction Ti and Tj. If Tj reads a data items previously written by Ti, then the commit operation of Ti precedes the commit operation of Tj. Aborting involves undoing the operations and redoing them since by the time stamp it is aborted.
Option (A): T2 must be aborted and then both T1 and T2 must be re-started to ensure transaction atomicity. It is incorrect because it says abort transaction T2 and then redo all the operations. But there is no gaurantee that it will succeed this time as again T1 may be fail.
Option(B): Schedule S is non-recoverable and cannot ensure transaction atomicity. Correct, it is by definition an irrecoverable schedule so now even if we start to undo the actions one by one(after t1 fails) in order to ensure transaction atomicity. Still we cannot undo a commited transaction. hence this schedule is irrecoverable by definition and also not atomic since it leaves the database in an inconsistent state. Simply dirty read so nonrecoverable.
Option (C): Only T2 must be aborted and then re-started to ensure transaction atomicity. It is incorrect because it says abort only transaction T2 and then redo all the T2 operations. But this is dirty read problem as it is reading the data item A which is written by T1 and T1 is not committed. Again it will be the dirty read problem. So incorrect.
Option (D): Schedule S is recoverable and can ensure transaction atomicity and nothing else needs to be done. Incorrect, it is clearly saying that schedule s is recoverable but it is irrecoverable because T2 read the data item A which is written by T1 and T1 failed and rollback, at the rollback T1 start undo all operations and modified the value of A with previous value but T2 is already committed so T2 can't change the read value of A which was earlier taken from T1.

Test: Transactions & Concurrency Control- 1 - Question 13

Which level of locking provides the highest degree of concurrency in a relational data base?

Detailed Solution for Test: Transactions & Concurrency Control- 1 - Question 13
  • Page level locking locks whole page i.e all rows therefore highly restrictive
  • Table locking is mainly used for concurrency control with DDL operations
  • A row share table lock is the least restrictive, and has the highest degree of concurrency for a table.It indicates the transaction has locked rows in the table and intends to update them.

Therefore Row level provides highest level of concurrency.Hence Answer is C

Test: Transactions & Concurrency Control- 1 - Question 14

Which one of the following is NOT a part of the ACID properties of database transactions?

Detailed Solution for Test: Transactions & Concurrency Control- 1 - Question 14

D refers to Durability.

Test: Transactions & Concurrency Control- 1 - Question 15

Consider the following two phase locking protocol. Suppose a transaction T accesses (for read or write operations), a certain set of objects {O1,...,Ok}. This is done in the following manner:
Step 1. T acquires exclusive locks to O1, . . . , Ok in increasing order of their addresses.
Step 2. The required operations are performed. 
Step 3. All locks are released. This protocol will

Detailed Solution for Test: Transactions & Concurrency Control- 1 - Question 15

The above scenario is Conservative 2PL(or Static 2PL). In Conservative 2PL protocol, a transaction has to lock all the items it access before the transaction begins execution. It is used to avoid deadlocks. Also, 2PL is  conflict serializable, therefore it guarantees serializability. Therefore option A Advantages of Conservative 2PL :

  • No possibility of deadlock.
  • Ensure serializability.

Drawbacks of Conservative 2PL :

  • Less throughput and resource utilisation because it holds the resources before the transaction begins execution.
  • Starvation is possible since no restriction on unlock operation.
  • 2pl is a deadlock free protocol but it is difficult to use in practice.
Test: Transactions & Concurrency Control- 1 - Question 16

Suppose a database schedule S involves transactions T1, ....Tn. Construct the precedence graph of S with vertices representing the transactions and edges representing the conflicts. If S is serializable, which one of the following orderings of the vertices of the precedence graph is guaranteed to yield a serial schedule?

Detailed Solution for Test: Transactions & Concurrency Control- 1 - Question 16

Cycle in precedence graph tells that schedule is not conflict serializable. DFS and BFS traversal of graph are possible even if graph contains cycle. And hence DFS and BFS are also possible for non serializable graphs. But Topological sort of any cyclic graph is not possible. Thus topological sort guarantees graph to be serializable. Option D is not valid because in a transaction with more indices might have to come before lower one. Also two non- conflicting schedule can occur simultaneously.

Test: Transactions & Concurrency Control- 1 - Question 17

Consider the following database schedule with two transactions, T1 and T2.

S = r2(X); r1(X); r2(Y); w1(X); r1(Y); w2(X); a1; a2;

where ri(Z) denotes a read operation by transaction Ti on a variable Z, wi(Z) denotes a write operation by Ti on a variable Z and ai denotes an abort by transaction Ti . Which one of the following statements about the above schedule is TRUE?

Detailed Solution for Test: Transactions & Concurrency Control- 1 - Question 17

As we can see in figure,

  • T2 overwrites a value that T1 writes
  • T1 aborts: its “remembered” values are restored.
  • Cascading Abort could have arised if - > Abort of T1 required abort of T2 but as T2 is already aborted , its not a cascade abort. Therefore, Option C

Option A - is not true because the given schedule is recoverable Option B - is not true as it is recoverable and avoid cascading aborts; Option D - is not true because T2 is also doing abort operation after T1 does, so NOT strict.

Test: Transactions & Concurrency Control- 1 - Question 18

Consider the following three schedules of transactions T1, T2 and T3. [Notation: In the following NYO represents the action Y (R for read, W for write) performed by transac­tion N on object O.]
(S1) 2RA 2WA 3RC 2WB 3WA 3WC 1RA 1RB 1WA 1WB
(S2) 3RC 2RA 2WA 2WB 3WA 1RA 1RB 1WA 1WB 3WC
(S3) 2RA 3RC 3WA 2WA 2WB 3WC 1RA 1RB 1WA 1WB

Q. Which of the following statements is TRUE?

Detailed Solution for Test: Transactions & Concurrency Control- 1 - Question 18

All the conflicting pairs like (3WA, 1WA) are in the same order in both S1 and S2.

Test: Transactions & Concurrency Control- 1 - Question 19

Which of the following statement is/are incorrect? 
A: A schedule following strict two phase locking protocol is conflict serializable as well as recoverable.
B: Checkpoint in schedules are inserted to ensure recoverability.

Detailed Solution for Test: Transactions & Concurrency Control- 1 - Question 19

Basic two phase locking protocol ensures only conflict serializability and strict two phase locking protocol ensures recoverability as well. So statement A is correct. Checkpoints are inserted to minimize the task of undo-redo in recoverability. So, statement B is not correct. Hence correct option B is correct choice.

Test: Transactions & Concurrency Control- 1 - Question 20

Which of the following concurrency control protocols ensure both conflict serialzability and freedom from deadlock?
I. 2-phase locking
II. Time-stamp ordering

Information about Test: Transactions & Concurrency Control- 1 Page
In this test you can find the Exam questions for Test: Transactions & Concurrency Control- 1 solved & explained in the simplest way possible. Besides giving Questions and answers for Test: Transactions & Concurrency Control- 1, EduRev gives you an ample number of Online tests for practice

Top Courses for Computer Science Engineering (CSE)

Download as PDF

Top Courses for Computer Science Engineering (CSE)