##### Effect of rollback on RTS,WTS

If RTS('A')=timestamp of T & then T has to rollback then RTS('A') becomes:

a)0

b)remains same

c)equals timestamp of a transaction which read 'A' just before T

Pritam Prasun
12 Dec 2017 07:18 pm

It will remain same.

Ranita Biswas
13 Dec 2017 07:50 pm

The correct answer is (b) remains same. To understand this, let us revise the informal algorithm for Timestamp based protocol for concurrency control (copied from Wikipedia, you can also refer to the formal version of the algorithm there):

1) If a transaction wants to read an object,

a) but the transaction started before the object's write timestamp it means that something changed the object's data after the transaction started. In this case, the transaction is canceled and must be restarted.
b) and the transaction started after the object's write timestamp, it means that it is safe to read the object. In this case, if the transaction timestamp is after the object's read timestamp, the read timestamp is set to the transaction timestamp.
2) If a transaction wants to write to an object,

a) but the transaction started before the object's read timestamp it means that something has had a look at the object, and we assume it took a copy of the object's data. So we can't write to the object as that would make any copied data invalid, so the transaction is aborted and must be restarted.
b) and the transaction started before the object's write timestamp it means that something has changed the object since we started our transaction. In this case, we use the Thomas write rule and simply skip our write operation and continue as normal; the transaction does not have to be aborted or restarted
c) otherwise, the transaction writes to the object, and the object's write timestamp is set to the transaction's timestamp.

Now consider the following example schedule:

T1      T2      T3      T4
R(A)
R(A)
R(A)
W(A)

Consider that after the execution of the last R(A), T4 needs to rollback (as given in the question). So, RTS(A) was 4 and now we need to decide what should be the new RTS for A. Note that, the schedule at hand now is something like the following:

T1      T2      T3
R(A)
R(A)
W(A)

Independent of T4, this schedule will have RTS(A) = 3 when T2 tries to write and hence T2 should be aborted by rule 2(a).

Now, after rollback of T4, consider option (a) i.e. changing the RTS(A) to 0. This will certainly allow W(A) by T2 to execute without any problem as it falls under rule 2(c) and hence violates concurrency by allowing T2 to write a data already read by T3.

Consider option (c) i.e. RTS(A) becomes equal to the timestamp of the transaction which read 'A' just before T4, in this example then RTS(A) becomes 1. And hence the same problem arises as choosing option (a).

Therefore, if we choose option (b) and keep the RTS(A) same as before i.e. 4, then W(A) by T2 will fall under rule 2(a) and hence will be aborted. So, option (b) is the correct answer.

This is why RTS is kept as the largest of the timestamps of the transactions which has read the data, and not the recent timestamp.
{"ft_lang_label":"__label__en","ft_lang_prob":0.94040865,"math_prob":0.9041602,"size":3149,"snap":"2022-40-2023-06","text_gpt3_token_len":754,"char_repetition_ratio":0.19173291,"word_repetition_ratio":0.16425993,"special_character_ratio":0.23721817,"punctuation_ratio":0.08809892,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.97382945,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-10-06T16:36:44Z\",\"WARC-Record-ID\":\"<urn:uuid:5c68f2ef-e008-4816-a356-ff454a774d89>\",\"Content-Length\":\"49621\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:fe195e87-dd00-4948-b139-0368043dce9d>\",\"WARC-Concurrent-To\":\"<urn:uuid:2c0900eb-c4e8-4eb6-b93d-fcdfba1579e2>\",\"WARC-IP-Address\":\"172.67.182.199\",\"WARC-Target-URI\":\"https://www.edredo.com/doubt/effect-rollback-rtswts\",\"WARC-Payload-Digest\":\"sha1:U33BPFNJPZ6MHL3TOVEMN7ULAMKQ5RFC\",\"WARC-Block-Digest\":\"sha1:KGGW72LZKHZH2U7EH5QBYGH6BIRRAOHH\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-40/CC-MAIN-2022-40_segments_1664030337853.66_warc_CC-MAIN-20221006155805-20221006185805-00285.warc.gz\"}"}