We will be analyzing a schedule under several variations of timestamp-based concurrency control.
You may find it helpful to consult the following summary of the rules related to timestamps from the coursepack: timestamp review
In each exercise, we will be considering the following schedule:
s1; r1(Y); s2; w2(Y); w2(X); s3; r3(Z); r2(Z); w3(Y); r3(X); c2; c3; w1(Y); r1(X); c1
You should assume that:
Assume that the timestamps assigned to the transactions are:
Note that these timestamps are consistent with the fact that T1 starts first, followed by T2, followed by T3.
In giving your answers, you should fill in a table that begins as follows:
request | response | state changes and/or explanation |
---|---|---|
r1(Y) | allowed | RTS(Y) = 100 |
The third column should include any changes to the state maintained for the data item. If a request is denied or ignored, that column should also include a brief explanation of why.
You do not need to restart a transaction that is rolled back, which means that you can skip any requests by a transaction that come after the point at which it is rolled back.
Here again is the schedule that we’re considering:
s1; r1(Y); s2; w2(Y); w2(X); s3; r3(Z); r2(Z); w3(Y); r3(X); c2; c3; w1(Y); r1(X); c1
If the DBMS uses regular timestamp-based concurrency control without commit bits, what would be the response of the system to each of the requested actions in the schedule?
Note: Because commits don’t have an effect when we’re not using
commit bits, you do not need to include the commit actions
(c1
, c2
, etc.) in your table.
request | response | state changes and/or explanation |
---|---|---|
r1(Y) | allowed | RTS(Y) = 100 |
w2(Y) | allowed | WTS(Y) = 200 |
w2(X) | allowed | WTS(X) = 200 |
r3(Z) | allowed | RTS(Z) = 300 |
r2(Z) | allowed | RTS is not changed (see below) |
w3(Y) | allowed | WTS(Y) = 300 |
r3(X) | allowed | RTS(X) = 300 |
w1(Y) | ignored | TS(T1) >= RTS(Y) but TS(T1) < WTS(Y) |
r1(X) | denied; roll back | TS(T1) < WTS(X); RTS(Y) = 0 |
Here are some additional notes about each request:
r1(Y):
w2(Y):
w2(X):
r3(Z):
r2(Z):
w3(Y):
r3(X):
w1(Y):
r1(X):
When using timestamp-based concurrency control, the DBMS can optionally maintain commit bits. What is the purpose of doing so?
Consider again the following schedule:
s1; r1(Y); s2; w2(Y); w2(X); s3; r3(Z); r2(Z); w3(Y); r3(X); c2; c3; w1(Y); r1(X); c1
What would the system’s response be to each of the requested actions if it uses commit bits? Make sure to include the responses to the commit requests (c1, c2, c3), since they are relevant when a system uses commit bits.
In addition to our prior assumptions, you should assume that all of the commit bits are initially true.
If a transaction is made to wait, you should include the relevant request a second time when the transaction is allowed to try again.
request | response | state changes and/or explanation |
---|---|---|
r1(Y) | allowed | RTS(Y) = 100 |
w2(Y) | allowed | WTS(Y) = 200, c(Y) = false |
w2(X) | allowed | WTS(X) = 200, c(X) = false |
r3(Z) | allowed | RTS(Z) = 300 |
r2(Z) | allowed | RTS is not changed (see below) |
w3(Y) | allowed | WTS(Y) = 300, C(Y) remains false |
r3(X) | denied; make wait | TS(T3) >= WTS(X) but c(X) == false |
c2 | allowed | c(X) = true |
r3(X) | now allowed! | RTS(X) = 300 |
c3 | allowed | c(Y) = true |
w1(Y) | ignored | TS(T1) >= RTS(Y) but TS(T1) < WTS(Y) |
and c(Y) == true | ||
r1(X) | denied; roll back | TS(T1) < WTS(X); RTS(Y) = 0 |
c1 | doesn’t happen | T1 has already been rolled back |
Here are some additional notes about each request:
r1(Y): same as before, but we also check that c(Y) == true before allowing the read.
w2(Y): same as before, but we also set c(Y) to false to indicate that the writer of Y has not yet committed.
w2(X): same as before, but we also set c(X) to false.
r3(Z): same as before, but we also check that c(Z) == true before allowing the read
r2(Z): same as before, but we also check that c(Z) == true.
w3(Y): same as before; c(Y) remains true, and T3 becomes Y’s most recent writer.
r3(X):
c2: T2 commits.
r3(X): now that c(X) is true, T3 is allowed to try again and the read is allowed.
c3: T3 commits.
w1(Y):
r1(X):
c1: T1 has already been rolled back, so this action doesn’t occur.
When using timestamp-based concurrency control, the DBMS can optionally maintain multiple versions of each item. What is the purpose of doing so?
Consider again this schedule:
s1; r1(Y); s2; w2(Y); w2(X); s3; r3(Z); r2(Z); w3(Y); r3(X); c2; c3; w1(Y); r1(X); c1
If the DBMS uses timestamp-based concurrency control without commit bits but with multiple versions of data items, what would be the response of the system to each of the requested actions in the schedule?
You should make the same assumptions as before about the timestamps of the transactions and the initial timestamps of the data items, and you should assume that all of the commit bits are initially true.
Note: Because commits don’t have an effect when we’re not using
commit bits, you do not need to include the commit actions
(c1
, c2
, etc.) in your table.
Remember to create a new version of a data item whenever necessary.
request | response | state changes and/or explanation |
---|---|---|
r1(Y) | allowed to read Y(0) | RTS(Y(0)) = 100 |
w2(Y) | allowed | create Y(200) with RTS = 0 |
w2(X) | allowed | create X(200) with RTS = 0 |
r3(Z) | allowed to read Z(0) | RTS(Z(0)) = 300 |
r2(Z) | allowed to read Z(0) | RTS(Z(0)) is unchanged |
w3(Y) | allowed | create Y(300) with RTS = 0 |
r3(X) | allowed to read X(200) | RTS(X(200)) = 300 |
w1(Y) | allowed | create Y(100) with RTS = 0 |
r1(X) | allowed to read X(0) | RTS(X(0)) = 100 |
Here are some additional notes about each request:
r1(Y):
w2(Y):
w2(X):
r3(Z):
r2(Z):
w3(Y):
r3(X):
w1(Y):
r1(X):
Last updated on November 13, 2024.