This paper was converted on www.awesomepapers.org from LaTeX by an anonymous user.
Want to know more? Visit the Converter page.

Safety of Deferred Update
in Transactional Memory

Hagit Attiya1     Sandeep Hans1     Petr Kuznetsov2,3     Srivatsan Ravi2

1Department of Computer Science, Technion
2Telekom Innovation Laboratories, TU Berlin
3Télécom ParisTech
Abstract

Transactional memory allows the user to declare sequences of instructions as speculative transactions that can either commit or abort. If a transaction commits, it appears to be executed sequentially, so that the committed transactions constitute a correct sequential execution. If a transaction aborts, none of its instructions can affect other transactions.

The popular criterion of opacity requires that the views of aborted transactions must also be consistent with the global sequential order constituted by committed ones. This is believed to be important, since inconsistencies observed by an aborted transaction may cause a fatal irrecoverable error or waste of the system in an infinite loop. Intuitively, an opaque implementation must ensure that no intermediate view a transaction obtains before it commits or aborts can be affected by a transaction that has not started committing yet, so called deferred-update semantics.

In this paper, we intend to grasp this intuition formally. We propose a variant of opacity that explicitly requires the sequential order to respect the deferred-update semantics. Unlike opacity, our property also ensures that a serialization of a history implies serializations of its prefixes. Finally, we show that our property is equivalent to opacity if we assume that no two transactions commit identical values on the same variable, and present a counter-example for scenarios when the “unique-write” assumption does not hold.

1 Introduction

Resolving conflicts in an efficient and consistent manner is the most challenging task in concurrent software design. Transactional memory (TM) [11, 18] addresses this challenge by offering an interface in which sequences of shared-memory instructions can be declared as speculative transactions. The underlying idea, borrowed from databases, is to treat each transaction as an atomic event: a transaction may either commit in which case it appears as executed sequentially, or abort in which case none of its update instructions affect other transactions. The user can therefore design software having only sequential semantics in mind and let the memory take care of conflicts resulting from potentially concurrent executions.

In databases, a correct implementation of concurrency control should guarantee that committed transactions constitute a serial (or sequential) execution [9]. On the other hand, uncommitted transactions can be aborted without invalidating the correctness of committed ones. (In the literature on databases, the latter feature is called recoverability.)

In the TM context, intermediate states witnessed by an incomplete transaction may affect the application through the outcome of its read operations. If the intermediate state is not consistent with any sequential execution, the application may experience a fatal irrecoverable error or sink in an infinite loop. The correctness criterion of opacity [7, 8] addresses this issue by requiring the states observed by uncommitted transactions to be consistent with a global serial execution constituted by committed ones (a serialization).

An opaque TM implementation must, intuitively, ensure that no transaction can read from a transaction that has not started committing yet. This is usually referred to as the deferred-update semantics, and it was in fact explicitly required in some representations of opacity [6]. The motivation of this paper is to capture this intuition formally.

We present a new correctness criterion called du-opacity. Informally, a du-opaque (possibly, non-serial) execution must be indistinguishable from a totally-ordered execution, with respect to which no transaction reads from a transaction that has not started committing.

We further check if our correctness criterion is a safety property, as defined by Owicki and Lamport [17], Alpern and Schneider [2] and refined by Lynch [16]. We show that du-opacity is prefix-closed: every prefix of a du-opaque history is also du-opaque. We also show that du-opacity is, under certain restrictions, limit-closed. More precisely, assuming that, in an infinite execution, every transaction completes each of the operations it invoked (but possibly neither commits nor aborts), the infinite limit of any sequence of ever extending du-opaque histories is also du-opaque. To prove that such an implementation is du-opaque, it is thus sufficient to prove that all its finite histories are du-opaque. To the best of our knowledge, this paper contains the first non-trivial proof of limit-closure for a TM correctness property. We further show that any du-opaque serialization of a history implies a serialization of any of its prefixes that maintains the original read-from relations, which is instrumental in the comparison of du-opacity with opacity.

Opacity, as defined in [8], reduces correctness of an infinite history to correctness of all its prefixes, and thus is limit-closed by definition. In fact, we show that extending opacity to infinite histories in a non-trivial way (i.e., requiring that even infinite histories should have proper serializations), does not result in a limit-closed property. We observe that opacity does not preclude scenarios in which a transaction reads from a future transaction (cf. example in Figure 4), and, thus, our criterion is strictly stronger than opacity. Surprisingly, this is true even if we assume that all transactional operations are atomic, which somewhat attenuates earlier attempts to forcefully introduce the deferred-update in the definition of opacity for atomic operations [6]. However, we show that opacity and du-opacity are equivalent if we assume that no two transactions try to commit identical values on the same data item.

We believe that these results improve our understanding of the very notion of correctness in transactional memory. Our correctness criterion explicitly declares that a transaction is not allowed to read from a transaction that has not started committing yet, and we conjecture that it is simpler to verify. We present the first non-trivial proof for both limit- and prefix-closure of TM histories, which is quite interesting in its own right, for it enables reasoning about possible serializations of an infinite TM history based on serializations of its prefixes.

The paper is organized as follows. In Section 2, we introduce our basic model definitions and recall the notion of safety [17, 2, 16]. In Section 3, we define our criterion of du-opacity and show that it is prefix-closed and under certain restrictions, a limit-closed property. In Section 4, we prove that du-opacity is a proper subset of the original notion of opacity [8], and that it coincides with du-opacity under the “unique-writes” condition.

2 Model

A transactional memory (in short, TM) supports atomic transactions for reading and writing on a set of transactional objects (in short, t-objects). A transaction is a sequence of accesses (reads or writes) to t-objects; each transaction TkT_{k} has a unique identifier kk.

A transaction TkT_{k} may contain the following t-operations, each being a matching pair of invocation and response events:

  1. 1.

    read(X)k{}_{k}(X) returns a value in some domain VV or a special value AkVA_{k}\notin V (abort);

  2. 2.

    write(X,v)k{}_{k}(X,v), for a value vVv\in V, returns okk or AkA_{k};

  3. 3.

    tryCk returns CkVC_{k}\notin V (commit) or AkA_{k}; and

  4. 4.

    tryAk returns AkA_{k}.

The read set (resp., the write set) of a transaction TkT_{k}, denoted Rset(Tk)\textit{Rset}(T_{k}), is the set of t-objects that TkT_{k} reads in HH; the write set of TkT_{k}, denoted Wset(Tk)\textit{Wset}(T_{k}), is the set of t-objects TkT_{k} writes to in HH.

We consider an asynchronous shared-memory system in which processes communicate via transactions. A TM implementation provides processes with algorithms for implementing readk\textit{read}_{k}, writek\textit{write}_{k}, tryCk()\textit{tryC}_{k}() and tryAk()\textit{tryA}_{k}() of a transaction TkT_{k}.

A history of a TM implementation is a (possibly infinite) sequence of invocation and response events of t-operations.

For every transaction identifier kk, H|kH|k denotes the subsequence of HH restricted to events of transaction TkT_{k}. If H|kH|k is non-empty, we say that TkT_{k} participates in HH, and let txns(H)\textit{txns}(H) denote the set of transactions that participate in HH. In an infinite history HH, we assume that each Tktxns(H)T_{k}\in\textit{txns}(H), H|kH|k is finite; i.e., transactions do not issue an infinite number of t-operations.

Two histories HH and HH^{\prime} are equivalent if txns(H)=txns(H)\textit{txns}(H)=\textit{txns}(H^{\prime}) and for every transaction Tktxns(H)T_{k}\in\textit{txns}(H), H|k=H|kH|k=H^{\prime}|k.

A history HH is sequential if every invocation of a t-operation is either the last event in HH or is immediately followed by a matching response.

A history is well-formed if for all TkT_{k}, H|kH|k is sequential and has no events after AkA_{k} or CkC_{k}. We assume that all histories are well-formed, i.e., the client of the transactional memory never invokes a t-operation before receiving a response from the previous one and does not invoke any t-operation opkop_{k} after receiving CkC_{k} or AkA_{k}. We also assume, for simplicity, that the client invokes a readk(X)\textit{read}_{k}(X) at most once within a transaction TkT_{k}. This assumption incurs no loss of generality, since a repeated read can be assigned to return a previously returned value without affecting the history’s correctness.

A transaction Tktxns(H)T_{k}\in\textit{txns}(H) is complete in HH if H|kH|k ends with a response event. The history HH is complete if all transactions in txns(H)\textit{txns}(H) are complete in HH.

A transaction Tktxns(H)T_{k}\in\textit{txns}(H) is t-complete if H|kH|k ends with AkA_{k} or CkC_{k}; otherwise, TkT_{k} is t-incomplete. TkT_{k} is committed (resp., aborted) in HH if the last event of TkT_{k} is CkC_{k} (resp., AkA_{k}). The history HH is t-complete if all transactions in txns(H)\textit{txns}(H) are t-complete.

For t-operations opk,opjop_{k},op_{j}, we say that opkop_{k} precedes opjop_{j} in the real-time order of HH, denoted opkHRTopmop_{k}\prec_{H}^{RT}op_{m}, if the response of opkop_{k} precedes the invocation of opjop_{j}.

Similarly, for transactions Tk,Tmtxns(H)T_{k},T_{m}\in\textit{txns}(H), we say that TkT_{k} precedes TmT_{m} in the real-time order of HH, denoted TkHRTTmT_{k}\prec_{H}^{RT}T_{m}, if TkT_{k} is t-complete in HH and the last event of TkT_{k} precedes the first event of TmT_{m} in HH. If neither TkHRTTmT_{k}\prec_{H}^{RT}T_{m} nor TmHRTTkT_{m}\prec_{H}^{RT}T_{k}, then TkT_{k} and TmT_{m} overlap in HH. A history HH is t-sequential if there are no overlapping transactions in HH.

For simplicity of presentation, we assume that each history HH begins with an “imaginary” transaction T0T_{0} that writes initial values to all t-objects and commits before any other transaction begins in HH.

Let HH be a t-sequential history. For every operation readk(X)\textit{read}_{k}(X) in HH, we define the latest written value of XX as follows:

  1. 1.

    If TkT_{k} contains a writek(X,v)\textit{write}_{k}(X,v) preceding readk(X)\textit{read}_{k}(X), then the latest written value of XX is the value of the latest such write to XX.

  2. 2.

    Otherwise, if HH contains a writem(X,v)\textit{write}_{m}(X,v), TmT_{m} precedes TkT_{k}, and TmT_{m} commits in HH, then the latest written value of XX is the value of the latest such write to XX in HH. (This write is well-defined since HH starts with T0T_{0} writing to all t-objects.)

We say that readk(X)\textit{read}_{k}(X) is legal in a t-sequential history HH if it returns the latest written value of XX, and HH is legal if every readk(X)\textit{read}_{k}(X) in HH that does not return AkA_{k} is legal in HH.

Definition 1 ([2, 16]).

A property 𝒫\mathcal{P} is a set of (transactional) histories. A property 𝒫\mathcal{P} is a safety property if it satisfies:

  1. 1.

    Prefix-closure: every prefix HH^{\prime} of a history H𝒫H\in\mathcal{P} is also in 𝒫\mathcal{P} and

  2. 2.

    Limit-closure: for any infinite sequence of finite histories H0,H1,H^{0},H^{1},\ldots such that for all ii, Hi𝒫H^{i}\in\mathcal{P} and HiH^{i} is a prefix of Hi+1H^{i+1}, the infinite history that is the limit of the sequence is also in 𝒫\mathcal{P}.

Notice that the set of histories produced by a TM implementation MM is prefix-closed. Therefore, every infinite history of MM is the limit of an infinite sequence of ever-extending finite histories of MM. Thus, to prove that MM satisfies a safety property PP, it is enough to show that all finite histories of MM are in PP. Indeed, limit-closure of PP then implies that every infinite history of MM is also in PP.

3 DU-Opacity

In this section, we introduce our correctness criterion, du-opacity, and prove that a restriction of it is a limit-closed property.

Definition 2.

Let HH be any history. A completion of HH, denoted H¯{\bar{H}}, is a history derived from HH as follows:

  • for every incomplete t-operation opkop_{k} of Tktxns(H)T_{k}\in\textit{txns}(H) in HH, if opk=readkwritektryAk()op_{k}=\textit{read}_{k}\vee\textit{write}_{k}\vee\textit{tryA}_{k}(), insert AkA_{k} somewhere after the invocation of opkop_{k}; otherwise, if opk=tryCk()op_{k}=\textit{tryC}_{k}(), insert CkC_{k} or AkA_{k} somewhere after the last event of TkT_{k}.

  • for every complete transaction Tktxns(H)T_{k}\in\textit{txns}(H) that is not t-complete, insert tryCkAk\textit{tryC}_{k}\cdot A_{k} after the last event of transaction TkT_{k}.

Let HH be any history and SS be a legal t-complete t-sequential history that is equivalent to some completion of HH. Let <S<_{S} be the total order on transactions in SS.

For any readk(X)\textit{read}_{k}(X) that does not return AkA_{k}, let Sk,XS^{k,X} denote the prefix of SS up to the response of readk(X)\textit{read}_{k}(X) and Hk,XH^{k,X} denotes the prefix of HH up to the response of readk(X)\textit{read}_{k}(X). Let SHk,XS_{H}^{k,X} denote the subsequence of Sk,XS^{k,X} derived by removing from Sk,XS^{k,X} the events of all transactions Tmtxns(H)T_{m}\in\textit{txns}(H) such that Hk,XH^{k,X} does not contain an invocation of tryCm()\textit{tryC}_{m}(). We refer to SHk,XS_{H}^{k,X} as the local serialization for readk(X)\textit{read}_{k}(X) with respect to HH and SS.

We are now ready to present our correctness condition, du-opacity.

Definition 3.

A history HH is du-opaque if there is a legal t-complete t-sequential history SS such that

  1. (1)

    there exists a completion of HH that is equivalent to SS, and

  2. (2)

    for every pair of transactions Tk,Tmtxns(H)T_{k},T_{m}\in\textit{txns}(H), if TkHRTTmT_{k}\prec_{H}^{RT}T_{m}, then Tk<STmT_{k}<_{S}T_{m}, i.e., SS respects the real-time ordering of transactions in HH, and

  3. (3)

    each readk(X)\textit{read}_{k}(X) in SS that does not return AkA_{k} is legal in SHk,XS_{H}^{k,X}.

We then say that SS is a (du-opaque) serialization of HH. Let 𝑠𝑒𝑞(S)\mathord{\it seq}(S) denote the sequence of transactions in SS and 𝑠𝑒𝑞(S)[k]\mathord{\it seq}(S)[k] denote the kthk^{th} transaction in this sequence.

Informally, a history HH is du-opaque if there exists a legal t-sequential history SS that is equivalent to HH, respects the real-time ordering of transactions in HH and every t-read is legal in its local serialization with respect to HH and SS. The third condition reflects the implementation’s deferred-update semantics, i.e., the legality of a t-read in a serialization does not depend on transactions that start committing after the response of the t-read.

R1(X)vR_{1}(X)\rightarrow vW1(X,v)W_{1}(X,v^{\prime})tryC1C1\textit{tryC}_{1}\rightarrow C_{1}R4(X)vR_{4}(X)\rightarrow v^{\prime}tryC4C4\textit{tryC}_{4}\rightarrow C_{4}W2(X,v)W_{2}(X,v)tryC2C2\textit{tryC}_{2}\rightarrow C_{2}W3(X,v)W_{3}(X,v)tryC3C3\textit{tryC}_{3}\rightarrow C_{3}T1T_{1}T4T_{4}T2T_{2}T3T_{3}
Figure 1: A du-opaque history HH; there exists a serialization SS of HH such that each t-read in SS has a legal local serialization with respect to HH and SS

An example of a du-opaque history HH is presented in Figure 1. Let SS be the t-complete t-sequential history such that 𝑠𝑒𝑞(S)=T2,T3,T1,T4\mathord{\it seq}(S)=T_{2},T_{3},T_{1},T_{4} and SS is equivalent to HH (HH is its own completion). It is easy to see that SS is legal and respects the real-time order of transactions in HH. We now need to prove that each t-read performed in SS has a local serialization with respect to HH in SS that is legal. Consider read1(X)\textit{read}_{1}(X) in SS; since T2T_{2} is t-complete in H1,XH^{1,X}, it follows that read1(X)\textit{read}_{1}(X) is legal in T2read1(X)T_{2}\cdot\textit{read}_{1}(X) (local serialization for read1(X)\textit{read}_{1}(X) with respect to HH and SS). Similarly, since T1,T2,T3T_{1},T_{2},T_{3} are t-complete in H4,XH^{4,X}, read4(X)\textit{read}_{4}(X) is legal in T2T3T1read4(X)T_{2}\cdot T_{3}\cdot T_{1}\cdot\textit{read}_{4}(X) (local serialization for read4(X)\textit{read}_{4}(X) with respect to HH and SS) Thus, SS is a du-opaque serialization of HH.

For a history HH, let HiH^{i} be the finite prefix of HH of length ii, i.e., consisting of the first ii events of HH. Now we show a property of du-opaque histories that is going to be instrumental in the rest of the paper.

W1(X,1)W_{1}(X,1)tryC1\textit{tryC}_{1}R2(X)1R_{2}(X)\rightarrow 1Ri(X)0R_{i}(X)\rightarrow 0R3(X)0R_{3}(X)\rightarrow 0T1T_{1}T2T_{2}T3T_{3}TiT_{i}\rightarrow\infty
Figure 2: Each finite prefix of the history is du-opaque, but the infinite limit of the ever-extending sequence is not du-opaque
Lemma 1.

Let HH be a du-opaque history and SS be a serialization of HH. For any ii\in\mathbb{N}, there exists a serialization SiS^{i} of HiH^{i}, such that 𝑠𝑒𝑞(Si)\mathord{\it seq}(S^{i}) is a subsequence of 𝑠𝑒𝑞(S)\mathord{\it seq}(S).

Proof.

Given HH, SS and HiH^{i}, we construct a t-complete t-sequential history SiS^{i} as follows:

  • for every transaction TkT_{k} that is t-complete in HiH^{i}, Si|k=S|kS^{i}|k=S|k.

  • for every transaction TkT_{k} that is complete but not t-complete in HiH^{i}, Si|kS^{i}|k consists of the sequence of events in Hi|kH^{i}|k, immediately followed by tryCk()Ak\textit{tryC}_{k}()\cdot A_{k}.

  • for every transaction TkT_{k} with an incomplete t-operation opk=readkwritektryAk()op_{k}=\textit{read}_{k}\vee\textit{write}_{k}\vee\textit{tryA}_{k}() in HiH^{i}, Si|kS^{i}|k is the sequence of events in S|kS|k up to the invocation of opkop_{k}, immediately followed by AkA_{k}.

  • for every transaction Tktxns(Hi)T_{k}\in\textit{txns}(H^{i}) with an incomplete t-operation opk=tryCk()op_{k}=\textit{tryC}_{k}(), Si|k=S|kS^{i}|k=S|k.

By the above construction, SiS^{i} is indeed a t-complete history and every transaction that appears in SiS^{i} also appears in SS. Now we order transactions in SiS^{i} so that 𝑠𝑒𝑞(Si)\mathord{\it seq}(S^{i}) is a subsequence of 𝑠𝑒𝑞(S)\mathord{\it seq}(S).

Note that SiS^{i} is derived from events contained in some completion H¯\bar{H} of HH that is equivalent to SS. Since SiS^{i} contains events from every complete t-operation in HiH^{i} and other events included are borrowed from H¯\bar{H}, there exists a completion of HiH^{i} that is equivalent to SiS^{i}.

We now prove that SiS^{i} is a serialization of HiH^{i}. First we observe that SiS^{i} respects the real-time order of HiH^{i}. Indeed, if TjHiRTTkT_{j}\prec_{H^{i}}^{RT}T_{k}, then TjHRTTkT_{j}\prec_{H}^{RT}T_{k} and Tj<STkT_{j}<_{S}T_{k}. Since 𝑠𝑒𝑞(Si)\mathord{\it seq}(S^{i}) is a subsequence of 𝑠𝑒𝑞(S)\mathord{\it seq}(S), we have Tj<SiTkT_{j}<_{S^{i}}T_{k}.

To show that SiS^{i} is legal, suppose, by way of contradiction, that there is some readk(X)\textit{read}_{k}(X) that returns vAkv\neq A_{k} in HiH^{i} such that vv is not the latest written value of XX in SiS^{i}. If TkT_{k} contains a writek(X,v)\textit{write}_{k}(X,v^{\prime}) preceding readk(X)\textit{read}_{k}(X) such that vvv\neq v^{\prime} and vv is not the latest written value for readk(X)\textit{read}_{k}(X) in SiS^{i}, it is also not the latest written value for readk(X)\textit{read}_{k}(X) in SS, which is a contradiction. Thus, the only case to consider is when readk(X)\textit{read}_{k}(X) should return a value written by another transaction.

Since SS is a serialization of HH, there exists a committed transaction TmT_{m} that performs the last writem(X,v)\textit{write}_{m}(X,v) that precedes readk(X)\textit{read}_{k}(X) in TkT_{k} in SS. Moreover, since readk(X)\textit{read}_{k}(X) is legal in the local serialization for readk(X)\textit{read}_{k}(X) in HH with respect to SS, the prefix of HH up to the response of readk(X)\textit{read}_{k}(X) must contain an invocation of tryCm()\textit{tryC}_{m}(). Thus, readk(X)HRTtryCm()\textit{read}_{k}(X)\not\prec_{H}^{RT}\textit{tryC}_{m}() and Tmtxns(Hi)T_{m}\in\textit{txns}(H^{i}). By construction of SiS^{i}, Tmtxns(Si)T_{m}\in\textit{txns}(S^{i}) and TmT_{m} is committed in SiS^{i}.

We have assumed, towards a contradiction, that vv is not the latest written value for readk(X)\textit{read}_{k}(X) in SiS^{i}. Hence, there exists a committed transaction TjT_{j} that performs writej(X,v);vv\textit{write}_{j}(X,v^{\prime});v^{\prime}\neq v in SiS^{i} such that Tm<SiTj<SiTkT_{m}<_{S^{i}}T_{j}<_{S^{i}}T_{k}. But this is not possible since 𝑠𝑒𝑞(Si)\mathord{\it seq}(S^{i}) is a subsequence of 𝑠𝑒𝑞(S)\mathord{\it seq}(S).

Thus, SiS^{i} is a legal t-complete t-sequential history equivalent to some completion of HiH^{i}. Now, by the construction of SiS^{i}, for every readk(X)\textit{read}_{k}(X) that does not return AkA_{k} in SiS^{i}, we have SiHik,X=SHk,X{S^{i}}_{H^{i}}^{k,X}={S}_{H}^{k,X}. Indeed, the transactions that appear before TkT_{k} in SiHik,X{S^{i}}_{H^{i}}^{k,X} are those with a tryC event before the response of readk(X)\textit{read}_{k}(X) in HH and are committed in SS. Since 𝑠𝑒𝑞(Si)\mathord{\it seq}(S^{i}) is a subsequence of 𝑠𝑒𝑞(S)\mathord{\it seq}(S), we have SiHik,X=SHk,X{S^{i}}_{H^{i}}^{k,X}={S}_{H}^{k,X}. Thus, readk(X)\textit{read}_{k}(X) is legal in SiHik,X{S^{i}}_{H^{i}}^{k,X}. ∎

Lemma 1 implies that every prefix of a du-opaque history has a du-opaque serialization and thus:

Corollary 2.

DU-Opacity is a prefix-closed property.

We show, however, that du-opacity is, in general, not limit-closed. We present an infinite history that is not du-opaque, but every its prefix is.

Proposition 1.

DU-Opacity is not a limit-closed property.

Proof.

Let HjH^{j} denote a finite prefix of HH of length jj. Consider an infinite history HH that is the limit of the histories HjH^{j} defined as follows (see Figure 2):

  • Transaction T1T_{1} performs a write1(X,1)\textit{write}_{1}(X,1) and then invokes tryC1()\textit{tryC}_{1}() that is incomplete in HH.

  • Transaction T2T_{2} performs a read2(X)\textit{read}_{2}(X) that overlaps with tryC1()\textit{tryC}_{1}() and returns 11.

  • There are infinitely many transactions TiT_{i}, i3i\geq 3, each of which performing a single readi(X)\textit{read}_{i}(X) that returns 0 such that each TiT_{i} overlaps with both T1T_{1} and T2T_{2}.

A t-complete t-sequential history SjS^{j} is derived from the sequence T3,,Tj,T0,T1T_{3},\ldots,T_{j},T_{0},T_{1} in which (1) tryC1()\textit{tryC}_{1}() is completed by inserting C1C_{1} immediately after its invocation and (2) any incomplete readj(X)\textit{read}_{j}(X) is completed by inserting AjA_{j} immediately after its invocation. It is easy to observe that SjS^{j} is indeed a serialization of HjH^{j}.

However, there is no serialization of HH. Suppose that such a serialization SS exists. Since every transaction that participates in HH must participate in SS, there exists nn\in\mathbb{N} such that 𝑠𝑒𝑞(S)[n]=T1\mathord{\it seq}(S)[n]=T_{1}. Consider the transaction at index n+1n+1, say TiT_{i} in 𝑠𝑒𝑞(S)\mathord{\it seq}(S). But for any i3i\geq 3, TiT_{i} must precede T1T_{1} in any serialization (by legality), which is a contradiction. ∎

We next prove that du-opacity is limit-closed if we assume that, in an infinite history, every transaction eventually completes (but not necessarily t-completes).

The proof uses König’s Path Lemma on a rooted directed graph, GG. Let v0v_{0} be the root vertex of GG. We say that vkv_{k}, a vertex of GG, is reachable from v0v_{0}, if there is a sequence of vertices v0,vkv_{0}\ldots,v_{k} such that for each ii, there exists an edge from viv_{i} to vi+1v_{i+1}. GG is connected if every vertex in GG is reachable from v0v_{0}. GG is finitely branching if every vertex in GG has a finite out-degree. GG is infinite if the set of vertices in GG is not finite.

Lemma 3 (König’s Path Lemma [13]).

If GG is an infinite connected finitely branching rooted directed graph, then GG contains an infinite sequence of vertices v0,v1,v_{0},v_{1},\ldots such that v0v_{0} is the root, for every i0i\geq 0, there is an edge from viv_{i} to vi+1v_{i+1}, and for every iji\neq j, vivjv_{i}\neq v_{j}.

We first prove the following lemma concerning du-opaque serializations.

For a transaction Ttxns(H)T\in\textit{txns}(H), we define the live set of TT in HH, denoted 𝐿𝑠𝑒𝑡H(T)\mathord{\it Lset}_{H}(T) (TT included) as follows: every transaction Ttxns(H)T^{\prime}\in\textit{txns}(H) such that neither the last event of TT^{\prime} precedes the first event of TT in HH nor the last event of TT precedes the first event of TT^{\prime} in HH is contained in 𝐿𝑠𝑒𝑡H(T)\mathord{\it Lset}_{H}(T). We say that transaction Ttxns(H)T^{\prime}\in\textit{txns}(H) succeeds the live set of TT and we write THLSTT\prec_{H}^{LS}T^{\prime} if in HH, for all T′′𝐿𝑠𝑒𝑡H(T)T^{\prime\prime}\in\mathord{\it Lset}_{H}(T), T′′T^{\prime\prime} is complete and the last event of T′′T^{\prime\prime} precedes the first event of TT^{\prime}.

Lemma 4.

Let HH be a finite du-opaque history and assume Tktxns(H)T_{k}\in\textit{txns}(H) be a complete transaction in HH such that every transaction in 𝐿𝑠𝑒𝑡H(Tk)\mathord{\it Lset}_{H}(T_{k}) is complete in HH. Then there exists a serialization SS of HH such that for all Tk,Tmtxns(H)T_{k},T_{m}\in\textit{txns}(H); TkHLSTmT_{k}\prec_{H}^{LS}T_{m}, we have Tk<STmT_{k}<_{S}T_{m}.

Proof.

Since HH is du-opaque, there exists a serialization S~{\tilde{S}} of HH.

Let S{S} be a t-complete t-sequential history such that txns(S~)=txns(S)\textit{txns}(\tilde{S})=\textit{txns}(S), and Titxns(S~):S|i=S~|i\forall~T_{i}\in\textit{txns}(\tilde{S}):S|i={\tilde{S}}|i. We now perform the following procedure iteratively to derive 𝑠𝑒𝑞(S)\mathord{\it seq}(S) from 𝑠𝑒𝑞(S~)\mathord{\it seq}(\tilde{S}). Initially 𝑠𝑒𝑞(S)=𝑠𝑒𝑞(S~)\mathord{\it seq}(S)=\mathord{\it seq}(\tilde{S}). For each Tktxns(H)T_{k}\in\textit{txns}(H), let Ttxns(H)T_{\ell}\in\textit{txns}(H) denote the earliest transaction in S~{\tilde{S}} such that TkHLSTT_{k}\prec_{H}^{LS}T_{\ell}. If T<S~TkT_{\ell}<_{\tilde{S}}T_{k} (implying TkT_{k} is not t-complete), then move TkT_{k} to immediately precede TT_{\ell} in 𝑠𝑒𝑞(S)\mathord{\it seq}(S).

By construction, SS is equivalent to S~{\tilde{S}} and for all Tk,Tmtxns(H)T_{k},T_{m}\in\textit{txns}(H); TkHLSTmT_{k}\prec_{H}^{LS}T_{m}, Tk<STmT_{k}<_{S}T_{m} We claim that SS is a serialization of HH. Observe that any two transactions that are complete in HH, but not t-complete are not related by real-time order in HH. By construction of SS, for any transaction Tktxns(H)T_{k}\in\textit{txns}(H), the set of transactions that precede TkT_{k} in S~{\tilde{S}}, but succeed TkT_{k} in SS are not related to TkT_{k} by real-time order. Since S~\tilde{S} respects the real-time order in HH, this holds also for SS.

We now show that SS is legal. Consider any readk(X)\textit{read}_{k}(X) performed by some transaction TkT_{k} that returns vVv\in V in SS and let Ttxns(H)T_{\ell}\in\textit{txns}(H) be the earliest transaction in S~{\tilde{S}} such that TkHLSTT_{k}\prec_{H}^{LS}T_{\ell}. Suppose, by contradiction, that readk(X)\textit{read}_{k}(X) is not legal in SS. Thus, there exists a committed transaction TmT_{m} that performs writem(X,v)\textit{write}_{m}(X,v) in S~{\tilde{S}} such that Tm=TT_{m}=T_{\ell} or T<S~Tm<S~TkT_{\ell}<_{\tilde{S}}T_{m}<_{\tilde{S}}T_{k}. Note that, by our assumption, readk(X)HRTtryC()\textit{read}_{k}(X)\prec_{H}^{RT}\textit{tryC}_{\ell}(). Since readk(X)\textit{read}_{k}(X) must be legal in the local serialization of S~\tilde{S} with respect to HH, readk(X)HRTtryCm()\textit{read}_{k}(X)\not\prec_{H}^{RT}\textit{tryC}_{m}(). Thus, Tm𝐿𝑠𝑒𝑡H(Tk)T_{m}\in\mathord{\it Lset}_{H}(T_{k}). Therefore TmTT_{m}\neq T_{\ell}. Moreover, TmT_{m} is complete, and since it commits in S~\tilde{S}, it is also t-complete in HH and the last event of TmT_{m} precedes the first event of TT_{\ell} in HH, i.e., TmHRTTT_{m}\prec_{H}^{RT}T_{\ell}. Hence, TT_{\ell} cannot precede TmT_{m} in S~{\tilde{S}}—a contradiction.

Observe also that since TkT_{k} is complete in HH but not t-complete, HH does not contain an invocation of tryCk()\textit{tryC}_{k}(). Thus, the legality of any other transaction is unaffected by moving TkT_{k} to precede TT_{\ell} in SS. Thus, SS is a legal t-complete t-sequential history equivalent to some completion of HH. The above arguments also prove that every t-read in SS is legal in its local serialization with respect to HH and SS and, thus, SS is a serialization of HH. ∎

Theorem 5.

Under the restriction that in any infinite history HH, every transaction Tktxns(H)T_{k}\in\textit{txns}(H) is complete, du-opacity is a limit-closed property.

Proof.

We are given an infinite sequence of finite ever-extending du-opaque histories, let HH be the corresponding infinite limit history. We want to show that HH is also du-opaque. By Corollary 2, every prefix of HH is du-opaque. Therefore, we can assume the sequence of du-opaque histories to be H0,H1,Hi,Hi+1,H^{0},H^{1},\ldots H^{i},H^{i+1},\ldots, where each HiH^{i} is the prefix of HH of length ii.

We construct a rooted directed graph GHG_{H} as follows:

  1. (0)

    The root vertex of GHG_{H} is (H0,S0)H^{0},S^{0}) where S0S^{0} and H0H^{0} contain the initial transaction T0T_{0}.

  2. (1)

    Each non-root vertex of GHG_{H} is a tuple (Hi,Si)({H}^{i},S^{i}), where SiS^{i} is a du-opaque serialization of Hi{H}^{i} that satisfies the condition specified in Lemma 4: for all Tk,Tmtxns(H)T_{k},T_{m}\in\textit{txns}(H); TkHLSTmT_{k}\prec_{H}^{LS}T_{m}, Tk<STmT_{k}<_{S}T_{m}. Note that there exist several possible serializations for any HiH^{i}. For succinctness, in the rest of this proof, when we refer to a specific SiS^{i}, it is understood to be associated with the prefix HiH^{i} of HH.

  3. (2)

    We say that a transaction TT is complete in HH^{\prime} with respect to HH, where HH is any extension of HH^{\prime} if last step of TT in HH is a response event and it is contained in HH^{\prime}.

    Let 𝑐𝑠𝑒𝑞i(Sj)\mathord{\it cseq}_{i}(S^{j}), jij\geq i, denote the subsequence of 𝑠𝑒𝑞(Sj)\mathord{\it seq}(S^{j}) reduced to transactions that are complete in HiH^{i} with respect to HH. For every pair of vertices v=(Hi,Si)v=({H}^{i},S^{i}) and v=(Hi+1,Si+1)v^{\prime}=({H}^{i+1},S^{i+1}) in GHG_{H}, there is an edge from vv to vv^{\prime} if 𝑐𝑠𝑒𝑞i(Si)=𝑐𝑠𝑒𝑞i(Si+1)\mathord{\it cseq}_{i}(S^{i})=\mathord{\it cseq}_{i}(S^{i+1}).

The out-degree of a vertex v=(Hi,Si)v=(H^{i},S^{i}) in GHG_{H} is defined by the number of possible serializations of Hi+1{H}^{i+1}, bounded by the number of possible permutations of the set txns(Si+1)\textit{txns}(S^{i+1}), implying that GHG_{H} is finitely branching.

By Lemma 1, given any serialization Si+1S^{i+1} of Hi+1H^{i+1}, there exists a serialization SiS^{i} of HiH^{i} such that 𝑠𝑒𝑞(Si)\mathord{\it seq}(S^{i}) is a subsequence of 𝑠𝑒𝑞(Si+1)\mathord{\it seq}(S^{i+1}). Indeed, the serialization SiS^{i} of HiH^{i} also respects the restriction specified in Lemma 4. Since 𝑠𝑒𝑞(Si+1)\mathord{\it seq}(S^{i+1}) contains every complete transaction that takes its last step in HH in HiH^{i}, 𝑐𝑠𝑒𝑞i(Si)=𝑐𝑠𝑒𝑞i(Si+1)\mathord{\it cseq}_{i}(S^{i})=\mathord{\it cseq}_{i}(S^{i+1}). Therefore, for every vertex (Hi+1,Si+1)({H}^{i+1},S^{i+1}), there is a vertex (Hi,Si)({H}^{i},S^{i}) such that 𝑐𝑠𝑒𝑞i(Si)=cseqi(Si+1)\mathord{\it cseq}_{i}(S^{i})={cseq}_{i}(S^{i+1}). Thus, we can iteratively construct a path from (H0,S0)(H^{0},S^{0}) to every vertex (Hi,Si)(H^{i},S^{i}) in GHG_{H}, implying that GHG_{H} is connected.

We now apply König’s Path Lemma to GHG_{H}. Since GHG_{H} is an infinite connected finitely branching rooted directed graph, we can derive an infinite sequence of non-repeating vertices

=(H0,S0),(H1,S1),,(Hi,Si),\mathcal{L}=(H^{0},S^{0}),(H^{1},S^{1}),\ldots,(H^{i},S^{i}),\ldots

such that 𝑐𝑠𝑒𝑞i(Si)=𝑐𝑠𝑒𝑞i(Si+1)\mathord{\it cseq}_{i}(S^{i})=\mathord{\it cseq}_{i}(S^{i+1}).

The rest of the proof explains how to use \mathcal{L} to construct a serialization of HH. We begin with the following claim concerning \mathcal{L}.

Claim 6.

For any j>ij>i, 𝑐𝑠𝑒𝑞i(Si)=𝑐𝑠𝑒𝑞i(Sj)\mathord{\it cseq}_{i}(S^{i})=\mathord{\it cseq}_{i}(S^{j}).

Proof.

Recall that 𝑐𝑠𝑒𝑞i(Si)\mathord{\it cseq}_{i}(S^{i}) is a prefix of 𝑐𝑠𝑒𝑞i(Si+1)\mathord{\it cseq}_{i}(S^{i+1}), and 𝑐𝑠𝑒𝑞i+1(Si+1)\mathord{\it cseq}_{i+1}(S^{i+1}) is a prefix of 𝑐𝑠𝑒𝑞i+1(Si+2)\mathord{\it cseq}_{i+1}(S^{i+2}). Also, 𝑐𝑠𝑒𝑞i(Si+1)\mathord{\it cseq}_{i}(S^{i+1}) is a subsequence of 𝑐𝑠𝑒𝑞i+1(Si+1)\mathord{\it cseq}_{i+1}(S^{i+1}). Hence, 𝑐𝑠𝑒𝑞i(Si)\mathord{\it cseq}_{i}(S^{i}) is a subsequence of 𝑐𝑠𝑒𝑞i+1(Si+2)\mathord{\it cseq}_{i+1}(S^{i+2}). But, 𝑐𝑠𝑒𝑞i+1(Si+2)\mathord{\it cseq}_{i+1}(S^{i+2}) is a subsequence of 𝑐𝑠𝑒𝑞i+2(Si+2)\mathord{\it cseq}_{i+2}(S^{i+2}). Thus, 𝑐𝑠𝑒𝑞i(Si)\mathord{\it cseq}_{i}(S^{i}) is a subsequence of 𝑐𝑠𝑒𝑞i+2(Si+2)\mathord{\it cseq}_{i+2}(S^{i+2}). Inductively, for any j>ij>i, 𝑐𝑠𝑒𝑞i(Si)\mathord{\it cseq}_{i}(S^{i}) is a subsequence of 𝑐𝑠𝑒𝑞j(Sj)\mathord{\it cseq}_{j}(S^{j}). But 𝑐𝑠𝑒𝑞i(Sj)\mathord{\it cseq}_{i}(S^{j}) is the subsequence of 𝑐𝑠𝑒𝑞j(Sj)\mathord{\it cseq}_{j}(S^{j}) reduced to transactions that are complete in HiH^{i} with respect to HH. Thus, 𝑐𝑠𝑒𝑞i(Si)\mathord{\it cseq}_{i}(S^{i}) is indeed equal to 𝑐𝑠𝑒𝑞i(Sj)\mathord{\it cseq}_{i}(S^{j}). ∎

Let f:txns(H)f:\mathbb{N}\rightarrow\textit{txns}(H) be defined as follows: f(1)=T0f(1)=T_{0}, For every integer k>1k>1, let

ik=min{|j>:𝑐𝑠𝑒𝑞(S)[k]=𝑐𝑠𝑒𝑞j(Sj)[k]}i_{k}=\min\{\ell\in\mathbb{N}|\forall j>\ell:\mathord{\it cseq}_{\ell}(S^{\ell})[k]=\mathord{\it cseq}_{j}(S^{j})[k]\}

Thus, f(k)=𝑐𝑠𝑒𝑞ik(Sik)[k]f(k)=\mathord{\it cseq}_{i_{k}}(S^{i_{k}})[k].

Claim 7.

The function ff is total and bijective.

Proof.

(Totality and surjectivity)

Since each transaction Ttxns(H)T\in\textit{txns}(H) is complete in some prefix HiH^{i} of HH, for each kk\in\mathbb{N}, there exists ii\in\mathbb{N} such that 𝑐𝑠𝑒𝑞i(Si)[k]=T\mathord{\it cseq}_{i}(S^{i})[k]=T. By Claim 6, for any j>ij>i, 𝑐𝑠𝑒𝑞i(Si)=𝑐𝑠𝑒𝑞i(Sj)\mathord{\it cseq}_{i}(S^{i})=\mathord{\it cseq}_{i}(S^{j}). Since a transaction that is complete in HiH^{i} w.r.t HH is also complete in HjH^{j} w.r.t HH, it follows that for every j>ij>i, 𝑐𝑠𝑒𝑞j(Sj)[k]=T\mathord{\it cseq}_{j}(S^{j})[k^{\prime}]=T, with kkk^{\prime}\geq k. By construction of GHG_{H} and the assumption that each transaction is complete in HH, there exists ii\in\mathbb{N} such that each T𝐿𝑠𝑒𝑡Hi(T)T\in\mathord{\it Lset}_{H^{i}}(T) is complete in HiH^{i} with respect to HH and TT precedes in SiS^{i} every transaction whose first event succeeds the last event of each T𝐿𝑠𝑒𝑡Hi(T)T^{\prime}\in\mathord{\it Lset}_{H^{i}}(T) in HiH^{i}. Indeed, this implies that for each kk\in\mathbb{N}, there exists ii\in\mathbb{N} such that 𝑐𝑠𝑒𝑞i(Si)[k]=T\mathord{\it cseq}_{i}(S^{i})[k]=T; j>i:𝑐𝑠𝑒𝑞j(Sj)[k]=T\forall j>i:\mathord{\it cseq}_{j}(S^{j})[k]=T.

This shows that for every Ttxns(H)T\in\textit{txns}(H), there are i,ki,k\in\mathbb{N}; 𝑐𝑠𝑒𝑞i(Si)[k]=T\mathord{\it cseq}_{i}(S^{i})[k]=T, such that for every j>ij>i, 𝑐𝑠𝑒𝑞j(Sj)[k]=T\mathord{\it cseq}_{j}(S^{j})[k]=T. Thus, for every Ttxns(H)T\in\textit{txns}(H), there is kk such that f(k)=Tf(k)=T.

(Injectivity)

If f(k)f(k) and f(m)f(m) are transactions at indices kk, mm of the same 𝑐𝑠𝑒𝑞i(Si)\mathord{\it cseq}_{i}(S^{i}), then clearly f(k)=f(m)f(k)=f(m) implies k=mk=m. Suppose f(k)f(k) is the transaction at index kk in some 𝑐𝑠𝑒𝑞i(Si)\mathord{\it cseq}_{i}(S^{i}) and f(m)f(m) is the transaction at index mm in some 𝑐𝑠𝑒𝑞(S)\mathord{\it cseq}_{\ell}(S^{\ell}). For every >i\ell>i and k<mk<m, if 𝑐𝑠𝑒𝑞i(Si)[k]=T\mathord{\it cseq}_{i}(S^{i})[k]=T, then 𝑐𝑠𝑒𝑞(S)[m]T\mathord{\it cseq}_{\ell}(S^{\ell})[m]\neq T since 𝑐𝑠𝑒𝑞i(Si)=𝑐𝑠𝑒𝑞i(S)\mathord{\it cseq}_{i}(S^{i})=\mathord{\it cseq}_{i}(S^{\ell}). If >i\ell>i and k>mk>m, it follows from the definition that f(k)f(m)f(k)\neq f(m). Similar arguments for the case when <i\ell<i prove that if f(k)=f(m)f(k)=f(m), then k=mk=m. ∎

By Claim 7, =f(1),f(2),,f(i),\mathcal{F}=f(1),f(2),\ldots,f(i),\ldots is an infinite sequence of transactions. Let SS be a t-complete t-sequential history such that 𝑠𝑒𝑞(S)=\mathord{\it seq}(S)=\mathcal{F} and for each t-complete transaction TkT_{k} in HH, S|k=H|kS|k=H|k; and for transaction that is complete, but not t-complete in HH, S|kS|k consists of the sequence of events in H|kH|k, immediately followed by tryAk()Ak\textit{tryA}_{k}()\cdot A_{k}. Clearly, there exists a completion of HH that is equivalent to SS.

Let i\mathcal{F}^{i} be the prefix of \mathcal{F} of length ii, and S^i{\widehat{S}^{i}} be the prefix of SS such that 𝑠𝑒𝑞(S^i)=i\mathord{\it seq}({\widehat{S}^{i}})=\mathcal{F}^{i}.

Claim 8.

Let H^ji{\widehat{H}^{j}}_{i} be a subsequence of HjH^{j} reduced to transactions in S^i{\widehat{S}^{i}} such that each Tktxns(S^i)T_{k}\in\textit{txns}({\widehat{S}^{i}}) is complete in HjH^{j} with respect to HH. Then, for every ii, there is jj such that S^i{\widehat{S}^{i}} is a serialization of H^ji{\widehat{H}^{j}}_{i}.

Proof.

Let HjH^{j} be the shortest prefix of HH (from \mathcal{L}) such that for each Ttxns(S^i)T\in\textit{txns}({\widehat{S}^{i}}), if 𝑠𝑒𝑞(Sj)[k]=T\mathord{\it seq}(S^{j})[k]=T, then for every j>jj^{\prime}>j, 𝑠𝑒𝑞(Sj)[k]=T\mathord{\it seq}(S^{j^{\prime}})[k]=T. From the construction of \mathcal{F}, such jj and kk exist. Also, we observe that txns(S^i)txns(Sj)\textit{txns}({\widehat{S}^{i}})\subseteq\textit{txns}(S^{j}) and i\mathcal{F}^{i} is a subsequence of 𝑠𝑒𝑞(Sj)\mathord{\it seq}(S^{j}). Using arguments similar to the proof of Lemma 1, it follows that S^i{\widehat{S}^{i}} is indeed a serialization of H^ji{\widehat{H}^{j}}_{i}. ∎

Since HH is complete, there is exactly one completion of HH, where each transaction TkT_{k} that is not t-complete in HH is completed with tryCkAk\textit{tryC}_{k}\cdot A_{k} after its last event. By Claim 8, the limit t-sequential t-complete history is equivalent to this completion, is legal, respects the real-time order of HH, and ensures that every read is legal in the corresponding local serialization. Thus, SS is a serialization of HH. ∎

From Theorem 5, it follows that:

Corollary 9.

Let MM be any TM implementation that ensures that in every infinite history HH of MM, each transaction Ttxns(H)T\in\textit{txns}(H) is complete in HH. Then, MM is du-opaque iff every finite history of MM is du-opaque.

4 Comparison with Other TM Consistency Definitions

tryC2C2\textit{tryC}_{2}\rightarrow C_{2}R(X)1R(X)\rightarrow 1tryC1C1\textit{tryC}_{1}\rightarrow C_{1}W(X,1)W(X,1)T1T_{1}T2T_{2}HH^{\prime}HH
Figure 3: History HH is final-state opaque, while its prefix HH^{\prime} is not final-state opaque

4.1 Relation to Opacity

In this section, we relate du-opacity with opacity, as defined by Guerraoui and Kapalka [8]. Note that the definition presented in [8] applies to any object with a sequential specification. For the sake of comparison, we restrict it here to TMs with read-write semantics.

Definition 4 (Guerraoui and Kapalka [7, 8]).

A finite history HH is final-state opaque if there is a legal t-complete t-sequential history SS, such that

  1. (1)

    for any two transactions Tk,Tmtxns(H)T_{k},T_{m}\in\textit{txns}(H), if TkHRTTmT_{k}\prec_{H}^{RT}T_{m}, then Tk<STmT_{k}<_{S}T_{m}, and

  2. (2)

    SS is equivalent to a completion of HH (cf. Definition 2).

We say that SS is a final-state serialization of HH.

Figure 3 presents a t-complete sequential history HH, demonstrating that final-state opacity is not a prefix-closed property. HH is final-state opaque, with T1T2T_{1}\cdot T_{2} being a legal t-complete t-sequential history equivalent to HH. Let H=write1(X,1),read2(X)H^{\prime}=\textit{write}_{1}(X,1),\textit{read}_{2}(X) be a prefix of HH in which T1T_{1} and T2T_{2} are t-incomplete. By Definition 2, TiT_{i} (i=1,2i=1,2) is completed by inserting tryCiAi\textit{tryC}_{i}\cdot A_{i} immediately after the last event of TiT_{i} in HH. Observe that neither T1T2T_{1}\cdot T_{2} nor T2T1T_{2}\cdot T_{1} are sequences that allow us to derive a serialization of HH^{\prime} (we assume that the initial value of XX is 0).

A restriction of final-state opacity, which we refer to as opacity, was presented in [8] by filtering out histories that are not prefix-closed.

Definition 5 (Guerraoui and Kapalka [8]).

A history HH is opaque if and only if every finite prefix HH^{\prime} of HH (including HH itself if it is finite) is final-state opaque.

It can be easily seen that opacity is prefix and limit-closed, and, thus, opacity is a safety property.

Proposition 2.

There is an opaque history that is not du-opaque.

Proof.

Consider the finite history HH depicted in Figure 4. To prove that HH is opaque, we proceed by examining every prefix of HH.

W1(X,1)W_{1}(X,1)tryC1A1\textit{tryC}_{1}\rightarrow A_{1}R2(X)1R_{2}(X)\rightarrow 1W3(X,1)W_{3}(X,1)tryC3C3\textit{tryC}_{3}\rightarrow C_{3}T1T_{1}T2T_{2}T3T_{3}
Figure 4: History is opaque, but not du-opaque
  1. 1.

    Each prefix up to the invocation of read2(X)\textit{read}_{2}(X) is trivially final-state opaque.

  2. 2.

    Consider the prefix, HiH^{i} of HH where the ithi^{th} event is the response of read2(X)\textit{read}_{2}(X). Let SiS^{i} be a t-complete t-sequential history derived from the sequence T1,T2T_{1},T_{2} by inserting C1C_{1} immediately after the invocation of tryC1()\textit{tryC}_{1}(). It is easy to see that SiS^{i} is a final-state serialization of HiH^{i}.

  3. 3.

    Consider the t-complete t-sequential history SS derived from the sequence T1,T3,T2T_{1},T_{3},T_{2} in which each transaction is t-complete in HH. Clearly, SS is a final-state serialization of HH.

Since HH and every (proper) prefix of it are final-state opaque, HH is opaque.

Clearly, the only final-state serialization SS of HH is specified by 𝑠𝑒𝑞(S)=T1,T3,T2\mathord{\it seq}(S)=T_{1},T_{3},T_{2}. Consider read2(X)\textit{read}_{2}(X) in SS; since H2,XH^{2,X}, the prefix of HH up to the response of read2(X)\textit{read}_{2}(X) does not contain an invocation of tryC3()\textit{tryC}_{3}(), the local serialization for read2(X)\textit{read}_{2}(X) with respect to HH and SS, SH2,XS_{H}^{2,X} is T1read2(X)T_{1}\cdot\textit{read}_{2}(X). But read2(X)\textit{read}_{2}(X) is not legal in SH2,XS_{H}^{2,X}—contradiction. Thus, HH is not du-opaque. ∎

Theorem 10.

DU-Opacity \subsetneq Opacity.

Proof.

We first claim that every finite du-opaque history is opaque. Let HH be a finite du-opaque history. By definition, there exists a final-state serialization SS of HH. Since du-opacity is a prefix-closed property, every prefix of HH is final-state opaque. Thus, HH is opaque.

Again, since every prefix of a du-opaque history is also du-opaque, by Definition 5, every infinite du-opaque history is also opaque.

Proposition 2 now establishes that du-opacity is indeed a restriction of opacity. ∎

We now show that du-opacity is equivalent to opacity assuming that no two transactions write identical values to the same t-object (“unique-write” assumption).

Let Opacityut \subseteq Opacity, be a property defined as follows:

  1. (1)

    an infinite opaque history HH\in Opacityut iff every transaction Ttxns(H)T\in\textit{txns}(H) is complete in HH, and

  2. (2)

    an opaque history HH\in Opacityut iff for any two transactions Tk,Tmtxns(H)T_{k},T_{m}\in\textit{txns}(H) that perform writek(X,v)\textit{write}_{k}(X,v) and writem(X,v)\textit{write}_{m}(X,v^{\prime}) respectively, vvv\neq v^{\prime}.

W1(X,1)W_{1}(X,1)tryC1C1\textit{tryC}_{1}\rightarrow C_{1}R2(X)1R_{2}(X)\rightarrow 1R2(Y)1R_{2}(Y)\rightarrow 1W3(X,1)W_{3}(X,1)W3(Y,1)W_{3}(Y,1)tryC3C3\textit{tryC}_{3}\rightarrow C_{3}T1T_{1}T2T_{2}T3T_{3}
Figure 5: A sequential du-opaque history that is not opaque by the definition in [6]
R1(X)0R_{1}(X)\rightarrow 0W1(X,1)W_{1}(X,1)tryC1C1\textit{tryC}_{1}\rightarrow C_{1}R2(X)0R_{2}(X)\rightarrow 0W2(Y,1)W_{2}(Y,1)tryC2C2\textit{tryC}_{2}\rightarrow C_{2}T1T_{1}T2T_{2}
Figure 6: History is du-opaque, but not TMS2 [5]
Theorem 11.

Opacityut=DU-Opacity.

Proof.

We show first that every finite history HH\in Opacityut is also du-opaque. Let HH be any finite opaque history such that for any two transactions Tk,Tmtxns(H)T_{k},T_{m}\in\textit{txns}(H) that perform writek(X,v)\textit{write}_{k}(X,v) and writem(X,v)\textit{write}_{m}(X,v) respectively, vvv\neq v^{\prime}

Since HH is opaque, there exists a final-state serialization SS of HH. Suppose by contradiction that HH is not du-opaque. Thus, there exists a readk(X)\textit{read}_{k}(X) that returns a value vVv\in V in SS that is not legal in SHk,X{S}_{H}^{k,X}, the local serialization for readk(X)\textit{read}_{k}(X) with respect to HH and SS. Let Hk,X{H}^{k,X} and Sk,X{S}^{k,X} denote the prefixes of HH and SS resp. up to the response of readk(X)\textit{read}_{k}(X) in HH and SS resp.. Recall that the local serialization for readk(X)\textit{read}_{k}(X) with respect to HH and SS, SHk,X{S}_{H}^{k,X} is defined as the subsequence of Sk,XS^{k,X} that does not contain events of any transaction Titxns(H)T_{i}\in\textit{txns}(H) if Hk,XH^{k,X} does not contain an invocation of tryCi()\textit{tryC}_{i}(). Since readk(X)\textit{read}_{k}(X) is legal in SS, there exists a committed transaction Tmtxns(H)T_{m}\in\textit{txns}(H) that performs writem(X,v)\textit{write}_{m}(X,v) that is the latest such write in SS that precedes TkT_{k}. Thus, if readk(X)\textit{read}_{k}(X) is not legal in SHk,X{S}_{H}^{k,X}, the only possibility is that readk(X)HRTtryCm()\textit{read}_{k}(X)\prec_{H}^{RT}\textit{tryC}_{m}(). Under the assumption of unique writes, there does not exist any other transaction Tjtxns(H)T_{j}\in\textit{txns}(H) that performs writej(X,v)\textit{write}_{j}(X,v). Consequently, there does not exist any H¯k,X{\bar{H}^{k,X}} (some completion of Hk,XH^{k,X}) and (t-complete t-sequential history) SS^{\prime} such that SS^{\prime} is equivalent to H¯k,X{\bar{H}^{k,X}} and SS^{\prime} contains any committed transaction that writes vv to XX i.e. Hk,XH^{k,X} is not final-state opaque. However, since HH is opaque, every prefix of HH must be final-state opaque—contradiction.

By Definition 5, an infinite history HH is opaque if every finite prefix of HH is final-state opaque. Theorem 5 now implies that Opacityut \subseteq DU-Opacity.

By Definition 5 and Corollary 2, it follows that DU-Opacity \subseteq Opacityut. ∎

4.2 Relation with Other definitions

Explicitly using the deferred-update semantics in an opacity definition was first proposed by Guerraoui et al. [6] and later adopted by Kuznetsov and Ravi [14]. In both papers, opacity is only defined on sequential histories, where every invocation of a t-operation is immediately followed by a matching response. In particular, these definitions require the final-state serialization to respect the read-commit order: HH is opaque by their definition if there exists a final-state serialization SS of HH such that if a t-read of a t-object XX by a transaction TkT_{k} precedes the tryC of a transaction TmT_{m} that commits on XX in HH, then TkT_{k} precedes TmT_{m} in SS. But we observe that this definition is not equivalent to opacity even for sequential histories. In fact the property defined in [6] is strictly stronger than du-opacity: the sequential history in Figure 5 is du-opaque (and consequently opaque by Theorem 10). We can derive a du-opaque serialization SS for this history such that 𝑠𝑒𝑞(S)=T1,T3,T2\mathord{\it seq}(S)=T_{1},T_{3},T_{2}. In fact, this is the only final-state serialization for HH. However, by the above definition, T2T_{2} must precede T3T_{3} in any serialization of this history since the response of read2(X)\textit{read}_{2}(X) precedes the invocation of tryC()3{}_{3}(). Thus, HH is not opaque by the definition in [6].

The recently introduced TMS2 correctness condition [5, 15] is another attempt to clarify opacity. Two transactions are said to conflict in a given history if they access the same t-object and at least one of them successfully commits to it. Informally, for each history HH in TMS2, there exists a final-state serialization SS of HH such that if two transactions T1T_{1} and T2T_{2} conflict on t-object XX in HH, where XWset(T1)Rset(T2)X\in\textit{Wset}(T_{1})\cap\textit{Rset}(T_{2}) and tryC of T1T_{1} precedes the tryC of T2T_{2}, then T1T_{1} must precede T2T_{2} in SS. We conjecture that every history in TMS2 is du-opaque, but not vice-versa. Figure 6 depicts a history HH that is du-opaque, but not TMS2. Indeed, there exists a du-opaque serialization SS of HH such that 𝑠𝑒𝑞(S)=T2,T1\mathord{\it seq}(S)=T_{2},T_{1}. On the other hand, T1T_{1} and T2T_{2} are in conflict, T1T_{1} commits before T2T_{2}, but there does not exist any final-state serialization of HH in which T1T_{1} precedes T2T_{2}.

5 Discussion

It is widely accepted that a correctness condition on a set of histories should be a safety property, i.e., should be prefix- and limit-closed. The definition of opacity proposed in [8] forcefully achieves prefix-closure by restricting final-state opacity to prefix-closed histories, and trivially achieves limit-closure by reducing correctness of an infinite history to correctness of its prefixes.

This paper proposes a correctness criterion that explicitly disallows reading from an uncommitted transaction, which ensures prefix-closure and (under the restriction that every transaction eventually completes every operation it invokes, but not neccesarily commits or aborts) limit-closure. We believe that this constructive definition is useful to TM practitioners, since it streamlines possible implementations of t-read and tryC operations. Moreover, it seems that du-opacity already captures the sets of histories exported by most existing opaque TM implementations [4, 10, 3]. In contrast, the recent pessimistic STM implementation [1], in which no transaction aborts, does not intend to provide the deferred-update semantics and, thus, is not in the focus of this paper. Technically, the pessimistic STM of [1] is not opaque, and certainly, not du-opaque.

To the best of our knowledge, there is no prior work proving that any TM correctness property is a safety property in the formal sense. The argumentation in the proof of Theorem 5 is inspired by the proof sketch in [16] of the safety of linearizability [12], but turns out to be trickier due to the more complicated definition of du-opacity.

Acknowledgements

The authors are grateful to the anonymous reviewers for insightful comments on the previous versions of this paper, and Victor Luchangco for interesting discussions.

This work was supported by the European Union Seventh Framework Programme (FP7/2007-2013) under grant agreement Number 238639, ITN project TRANSFORM, and grant agreement Number 248465, the S(o)OS project.

References

  • [1] Yehuda Afek, Alexander Matveev, and Nir Shavit. Pessimistic software lock-elision. In DISC, pages 297–311, 2012.
  • [2] Bowen Alpern and Fred B. Schneider. Defining liveness. Information Processing Letters, 21(4):181–185, October 1985.
  • [3] Luke Dalessandro, Michael F. Spear, and Michael L. Scott. Norec: streamlining stm by abolishing ownership records. In Proceedings of the 15th ACM SIGPLAN Symposium on Principles and Practice of Parallel Programming, PPoPP ’10, pages 67–78, New York, NY, USA, 2010. ACM.
  • [4] Dave Dice, Ori Shalev, and Nir Shavit. Transactional locking ii. In In Proc. of the 20th Intl. Symp. on Distributed Computing, 2006.
  • [5] Simon Doherty, Lindsay Groves, Victor Luchangco, and Mark Moir. Towards formally specifying and verifying transactional memory. Electron. Notes Theor. Comput. Sci., 259:245–261, December 2009.
  • [6] Rachid Guerraoui, Thomas A. Henzinger, and Vasu Singh. Permissiveness in transactional memories. In DISC, pages 305–319, 2008.
  • [7] Rachid Guerraoui and Michal Kapalka. On the correctness of transactional memory. In PPOPP, pages 175–184, 2008.
  • [8] Rachid Guerraoui and Michal Kapalka. Principles of Transactional Memory,Synthesis Lectures on Distributed Computing Theory. Morgan and Claypool, 2010.
  • [9] Vassos Hadzilacos. A theory of reliability in database systems. J. ACM, 35(1):121–145, 1988.
  • [10] Maurice Herlihy, Victor Luchangco, Mark Moir, and William N. Scherer, III. Software transactional memory for dynamic-sized data structures. In Proceedings of the twenty-second annual symposium on Principles of distributed computing, PODC ’03, pages 92–101, New York, NY, USA, 2003. ACM.
  • [11] Maurice Herlihy and J. Eliot B. Moss. Transactional memory: architectural support for lock-free data structures. SIGARCH Comput. Archit. News, 21(2):289–300, 1993.
  • [12] Maurice Herlihy and Jeannette M. Wing. Linearizability: A correctness condition for concurrent objects. ACM Trans. Program. Lang. Syst., 12(3):463–492, 1990.
  • [13] Dénes König. Theorie der Endlichen und Unendlichen Graphen: Kombinatorische Topologie der Streckenkomplexe. Akad. Verlag. 1936.
  • [14] Petr Kuznetsov and Srivatsan Ravi. On the cost of concurrency in transactional memory. CoRR, abs/1103.1302, 2011.
  • [15] Mohsen Lesani, Victor Luchangco, and Mark Moir. Putting opacity in its place. In WTTM, 2012.
  • [16] Nancy A. Lynch. Distributed Algorithms. Morgan Kaufmann, 1996.
  • [17] Susan S. Owicki and Leslie Lamport. Proving liveness properties of concurrent programs. ACM Trans. Program. Lang. Syst., 4(3):455–495, 1982.
  • [18] Nir Shavit and Dan Touitou. Software transactional memory. In PODC ’95: Proceedings of the fourteenth annual ACM symposium on Principles of distributed computing, pages 204–213, 1995.