Professional Documents
Culture Documents
A New Operational Transformation Framework For Real-Time Group Editors
A New Operational Transformation Framework For Real-Time Group Editors
A New Operational Transformation Framework For Real-Time Group Editors
Abstract—Group editors allow a group of distributed human users to edit a shared multimedia document at the same time over a
computer network. Consistency control in this environment must not only guarantee convergence of replicated data, but also attempt to
preserve intentions of operations. Operational transformation (OT) is a well-established method for optimistic consistency control in
this context and has drawn continuing research attention since 1989. However, counterexamples to previous works have often been
identified despite the significant progress made on this topic over the past 15 years. This paper analyzes the root of correctness
problems in OT and establishes a novel operational transformation framework for developing OT algorithms and proving their
correctness.
1 INTRODUCTION
before o2 is the same as executing o2 before o1 . TP2 ensures 3 THE CONSISTENCY MODEL
that transforming any operation o3 along different paths, As revealed in Example 1, the main problem of the
½o1 ; o02 and ½o2 ; o01 , will yield the same result. These two established CCI model [17], [20] is that it only considers
properties ensure that arbitrary transformation paths can the “intentions” or effects of single operations in their
lead to a consistent final state. In other words, it is not generation states while failing to capture a global picture of
necessary to enforce a global total order between operations the whole system. Conversely, if a global picture was
in order to achieve convergence because divergence can present when transforming the two operations, o1 and o2 ,
always be repaired by operational transformation. we would know how to correctly determine the relation
The CC framework has influenced most of the OT between their effect characters, ‘x’ and ‘y.’
We address this problem by introducing a new concept
algorithms developed since it was proposed in 1996,
of effects relation to denote the order between characters.
including adOPTed [14], GOT [20], GOTO [19], [17], [4],
In Example 1, we have ‘b’ ‘x’ ‘c’ when o1 is generated
NICE [15], SOCT [16], [22], TIBOT [12], and SDT [9], [10], as
and ‘a’ ‘y’ ‘b’ when o2 is generated. Then, by transitiv-
they more or less struggle on the TP2 condition. Influential
ity, we infer ‘y’ ‘x’ based on which we can always
as it is, this framework is flawed in the following ways: correctly transform o1 and o2 . In this way, we can model
First, the consistency model does not explicitly constrain both effects of single operations and the relation between
convergence. Hence, it is theoretically acceptable in the effects of concurrent operations.
model that the system always converges in an empty state Our early result, as presented in [10], [11], introduced but
no matter what the users do. Second, in the technical did not rigorously formalize the concept of effects relation.
approach part, TP1 and TP2 are only for constraining IT. As Additionally, it was developed under the influence of CCI
revealed later [16], [17], [19], [20], ET is conceptually an and still strived to satisfy TP1 and TP2. Nevertheless, the
inverse of IT and indispensable for implementing group TP2 proofs in [11] are very complicated although they only
undo and building transformation paths. However, the CC treat two characterwise primitives. How to scale the proofs
framework does not constrain ET. Additionally, it does not to handle more sophisticated string operations [20] is still an
provide guidelines on how to develop IT functions that open problem. Related works in [12], [15], [20], [22] free TP2
satisfy TP2. In fact, TP2 had never been verified until in our by enforcing a unique transformation path. However, they
recent work [9], [10], [11]. are developed under the CCI framework and must verify
The second framework is established in Sun et al. [20] the condition of intention preservation as required in CCI.
with three consistency criteria: causality preservation, The purposes of the present paper are two-fold: First, we
convergence, and intention preservation (CCI). The inten- will present a rigorous definition of the effects relation.
tion preservation condition is the first attempt in the Second, we will explore a more practicable approach that no
literature to explicitly constrain convergence in interactive longer requires the verification of TP1 and TP2.
groupware. Due to its intuitiveness, this model has been 3.1 Effects Relation
well-accepted in group editors, such as [2], [4], [16], [18],
Suppose there is an observer to the system (group editor)
[22]. However, Sun et al. did not clearly formalize exactly
who observes the progress (every operation execution) at
what is intention-preserving and what is not in the original
each site. A virtual global data structure is maintained to
work [20] and its main follow-up [17]. Hence, it is difficult indicate the effects relation . is initialized by the initial
to evaluate the correctness of OT algorithms under the CCI system state s0 and incrementally updated by the execution
framework. of operations. Before we define rules for initializing and
Example 1. A well-known controversial scenario follows: updating , we study the order in which is updated.
Suppose three sites start from the same initial state “abc”. Note that the same operation is invoked to update
Concurrently, site 1 performs o1 ¼ insð2; ‘x’Þ to insert ‘x’ multiple times because it is executed once at every site in
between ‘b’ and ‘c’, site 2 performs o2 ¼ insð1; ‘y’Þ to the system. Hence, we have to examine these invocations at
insert ‘y’ between ‘a’ and ‘b,’ and site 3 performs o3 ¼ the event level. An allowed updating path is a sequence of
delð1Þ to delete ‘b.’ Intuitively, the only correct final operations (invocations), o1 ; o2 ; . . . ; on , in which, for any two
result must be “ayxc.” However, result “axyc” is also operations oi and oj , oi precedes (or is invoked before) oj ,
referred to as intention-preserving in [20]. 1 i < j n, iff one of the following conditions holds: 1) oi
is executed earlier than oj at the same site, 2) oi is the local
In the technical approach part of [17], the CCI framework
execution and oj is a remote execution of the same
inherits the TP1 and TP2 constraints on IT, while still not
operation, or 3) there exists another execution ok such that
providing guidelines for developing such IT functions. It oi precedes ok and ok precedes oj .
also defines several constraints that relate IT and ET, e.g., We annotate with a superscript to denote its incre-
reversibility and transpose properties. However, ET is mental construction process. 0 contains the initial effects
treated as a second-class citizen and no standalone relation: For any two characters ci ; cj 2 s0 , we add pair
constraints are defined. As an important contribution, Sun < ci ; cj > or ci cj into 0 iff s0 ½ci > s0 ½cj . Given any
et al. [20], [17] define the precondition of ITðo1 ; o2 Þ as updating path P ¼ ½o1 ; o2 ; . . . ; on , the execution of oi
estðo1 Þ ¼ estðo2 Þ and the precondition of ETðo1 ; o2 Þ as updates i1 to i , where 1 i n. For convenience, we
estðo1 Þ ¼ execðestðo2 Þ; o2 Þ. However, these two conditions assume that there are two invisible characters: cb and ce in
are not really sufficient, as will be illustrated later in any state s such that s½cb ¼ 1 and s½ce ¼ jsj and, for any
Examples 3 and 4 in Section 4. visible character c 2 s, we have cb c ce .
310 IEEE TRANSACTIONS ON PARALLEL AND DISTRIBUTED SYSTEMS, VOL. 18, NO. 3, MARCH 2007
Assume the execution of any operation o in its generation executing o1 , Site 3 generates o3 ¼ insð1; ‘z’Þ to get “azxb”.
state s is “correct.” If o ¼ insðp; cÞ, it inserts a new character We have o1 k o2 , o1 ! o3 and o2 k o3 . Suppose an
c between two existing characters s½p 1 and s½p. Hence, updating path is ½o1 ; o3 ; o2 . The question is how to
we add two pairs < s½p 1; c > and < c; s½p > into . On determine the order between ‘y’ and ‘z’ and the order
the other hand, if o ¼ delðpÞ, it deletes the existing character between ‘y’ and ‘x’. If we directly compared their site ids,
s½p. Its execution does not change the ordering between we would get ‘y’ ‘z’ and ‘x’ ‘y; ’ which violates the
existing characters. Hence, all pairs in carry over. established order of ‘z’ ‘x’. By Rule 5, to determine the
Obviously, 0 defines a total order over all characters in order between ‘y’ and ‘z,’ we first determine the order
s0 . We would like to be maintained as a total order over between ‘y’ and ‘x,’ which is ‘x’ ‘y’ by Rule 5b. Then,
all characters that have appeared in the system upon every by transitivity (Rule 5a), we infer ‘z’ ‘x’ ‘y:’ Hence,
update. To achieve this, we require that 1) every execution the final result must be “azxyb.”
of a deletion deletes the character it intended at its Theorem 1. The effects relation is a total order.
generation state and 2) only insertions at their generation
states introduce new pairs while any remote execution of an Definition 3 (Landmark Characters). For any two characters
ci and cj that are originally inserted by oi and oj , respectively,
insertion does not introduce pairs that contradict existing
character c is a landmark character between them iff 1) ci
pairs in . Therefore, we only need to consider the local
c cj or cj c ci and 2) c 2 s0 or the operation that
execution of insertions when we define the effects relation.
originally inserted c happened before at least one of oi and oj .
Definition 2 (Effects Relation). Assume 0 is initialized from The set of the landmark characters between ci and cj is denoted
the system initial state s0 by adding ci cj into 0 for any ci by Cld ðci ; cj Þ.
and cj such that s0 ½ci < s0 ½cj . Given an updating path P ,
assume j1 is a total order produced by the first j 1 exec- For example, in the scenario of Example 1, let c1 ¼ ‘x’
utions in P . Now, we consider how the jth execution oj and c2 ¼ ‘y’. By Definition 2, the set of landmark characters
extends j1 into j . Without loss of generality, assume oj ¼ between them is Cld ðc1 ; c2 Þ ¼ f‘b’g. In some updating paths,
insðpj ; cj Þ is an insertion to be executed in its generation state such as ½o3 ; o1 ; o2 , when o2 is transformed with o1 , the
s. Suppose cj is to be inserted between ¼ s½pj 1 and landmark character ‘b’ is not present in the current state.
¼ s½pj . Let be the set of characters that appear in j1 . This causes tie-breaking problems in previous work such as
Let B ¼ fg [ fc 2 jc g, A ¼ fg [ fc 2 j cg, GOTO [19], which will be further explained in Example 3.
and D ¼ A B ¼ fc 2 j c g. For any charac- The concept of landmark character will be used in our
ter ci 2 , we decide the relation between ci and cj by the correctness analyses. The reason we exclude operations
following rules and add the new relation to j : that are concurrent with, or are generated after, both oi and
oj is that, due to causality, the effects relation between ci
1. if ci 2 B, then ci cj ; and cj should not depend on the effects of those operations.
2. if ci 2 A, then cj ci ; By the following lemma, landmark characters will play
3. if ci 2 D and ci 2 s0 , we mandate cj ci ; an important role in determining the effects relation of
4. if ci 2 D and ci 62 s0 , assuming ci is originally operations:
inserted by oi and oi ! oj , we mandate cj ci ; and
Lemma 1. Suppose that two characters, ci and cj , are originally
5. if ci 2 D and ci 62 s0 , assuming ci is originally
inserted by oi and oj , respectively, and that oi precedes oj in
inserted by oi and oi k oj , we first (recursively) derive
an updating path and ci 62 gstðoj Þ. If Cld ðci ; cj Þ ¼ ;, then we
the relation between cj and every character c 2 D,
only need Rules 4 and 5b to determine the relation between ci
where c 2 s0 or c is originally inserted by some o such
and cj .
that o ! oi or o ! oj , and then consider the following
rules: 3.2 Correctness Criteria
a. if there exists c in D such that either ci c cj A quiescent state in a group editor means all generated
operations have been executed at all sites [6]. System
or cj c ci is implied, then we add ci cj or
consistency requires not only that all sites have the same set
cj ci accordingly;
of objects (characters), but also that all these objects are
b. if no such relation can be inferred, we mandate
ordered the same way. Based on the above notion of effects
ci cj if idðoi Þ < idðoj Þ, or cj ci if otherwise.
relation, we define the following correctness conditions:
In the above definition, rules 1 and 2 are straight-
Definition 4 (Correctness Criteria). A group editor is correct
forward. Rules 3 and 4 are to mandate an order between cj
if it always maintains the following two properties:
and those that have been deleted before oj is generated in
state s. Rule 5 conceptually breaks ties between two 1. Causality preservation: For any two operations o1
characters that are inserted concurrently between the same and o2 , if o1 ! o2 , then o1 is executed before o2 at all
two characters. It appears complicated because the ties sites.
cannot be safely broken by simply comparing their site ids 2. Effects relation preservation: The effects relation is
directly, as is illustrated by the following example: preserved at every operation execution.
Example 2. Suppose three sites start from s0 ¼ ‘‘ab:’’ By Causality preservation is a fundamental criterion in
definition, is initialized to include ‘a’ ‘b:’ Site 1 typical distributed systems as well as group editors [6],
generates o1 ¼ insð1; ‘x’Þ to get “axb” and, concurrently, [14], [16], [20]. The effects relation preservation as a system-
Site 2 generates o2 ¼ insð1; ‘y’Þ to get “ayb”. After specific measure constrains convergence in a group editor
LI AND LI: A NEW OPERATIONAL TRANSFORMATION FRAMEWORK FOR REAL-TIME GROUP EDITORS 311
and its behavior. It is easy to show that a correct group editor number at that site. Due to the established state vector
converges in any quiescent state because all sites have the maintenance protocol [6], [20], no two different operations
same set of characters that are ordered in the same way. share the same key value. Unlike posðoÞ, the value of keyðoÞ
Corollary 1. Any correct group editor converges in quiescent does not change. Since each operation has a unique effect
states. character, charðoÞ can be safely replaced by keyðoÞ in
algorithm implementation. The relation ER is implemented
In the following, we further study how to constrain all as a hash table, which stores pairs of operation keys: We
the possible states and operation executions in a group infer charðox Þ charðoy Þ if pair < keyðox Þ, keyðoy Þ > is
editor: found in ER, or equivalently, < charðox Þ, charðoy Þ >2 ER.
In this section, we define the IT/ET functions based on
Definition 5 (Reachable States). Any state s is reachable iff,
relation and study sufficient conditions under which
for any c1 ; c2 2 s, if s½c1 > s½c2 , then c1 c2 .
relation can be correctly determined using only local
Conceptually, a reachable state is such that the ordering information stored in ER and HB and the basic operation
of its characters is consistent with the effects relation. parameters posðoÞ, idðoÞ, and typeðoÞ.
Definition 6 (Admissible Operations). Given an operation o 4.1 Inclusion Transformation and Correctness
that is defined in a reachable state s, i.e., s ¼ estðoÞ, we say o The purpose of o01 ¼ ITðo1 ; o2 Þ, where s ¼ estðo1 Þ ¼ estðo2 Þ
is admissible in s iff one of the following conditions holds: and s0 ¼ execðs; o2 Þ, is to incorporate the effect of o2 into o1
1) typeðoÞ ¼ del and the execution of o in s only leads such that the result o01 can be correctly executed in state s0 .
charðoÞ to be deleted, 2) typeðoÞ ¼ ins and s ¼ gstðoÞ, or As defined in Algorithm 1, we first call Algorithm 2
3) typeðoÞ ¼ ins, s 6¼ gstðoÞ, and for any c 2 s: posðoÞ s½c (get_er_IT) to determine the effects relation of o1 and o2 and
iff charðoÞ c or s½c < posðoÞ iff c charðoÞ. then use this relation to decide how to compute o01 .
Intuitively, when executing a deletion, the system should Algorithm 1 ITðo1 ; o2 Þ: o01
not delete any character that is not intended by the original 1: get er ITðo1 ; o2 Þ
operation; when executing an insertion, the new character 2: if charðo1 Þ ¼ charðo2 Þ then
ordering should not violate the effects relation definition. 3: return o01 {// means identity operation }
As an example of admissible operations, consider the 4: else
execution of o1 and o2 in Fig. 1. At site 1, if o02 ¼ delð2Þ is 5: o01 o1
executed, it is not admissible because it targets the wrong 6: if charðo2 Þ charðo1 Þ then
character. At site 2, if o01 ¼ insð0; ‘x’Þ is executed instead, 7: if typeðo2 Þ ¼ ins then
then ‘x’ is inserted at the wrong position, which violates the 8: posðo01 Þ posðo1 Þ þ 1
effects relation established by o1 when it is generated. 9: else { // typeðo2 Þ ¼ del }
Lemma 2. If o is admissible in a reachable state s, then s0 ¼ 10: posðo01 Þ posðo1 Þ 1
execðs; oÞ is reachable. 11: end if
Lemma 3. Given an admissible operation o in a reachable state s, 12: end if
if o ¼ delðpÞ, we have charðoÞ ¼ s½p, or if o ¼ insðp; cÞ, we 13: return o01
have s½i c s½j for any i and j such that 1 i < p and 14: end if
p j jsj. Recall that s½cb ¼ 1 and s½ce ¼ jsj. If charðo1 Þ charðo2 Þ, it means that charðo2 Þ is on the right
side of charðo1 Þ and the execution of o2 does not affect o1 .
Based on the concept of admissible operations, we may Hence, o1 is returned as it is. In the case of charðo2 Þ charðo1 Þ,
further simplify the verification of system correctness by the however, if o2 inserted a character on the left of charðo1 Þ, the
following lemma: position of o1 should be increased by one, or if o2 deleted a
Lemma 4. If every operation a system executes is admissible, the character on the left, the position of o1 should be decreased
system preserves the effect relation. by one.
Assuming that every insertion introduces a new char-
acter, it is impossible that o1 has the same effect character as
4 TRANSFORMATION FUNCTIONS AND CONDITIONS another operation o2 . However, two concurrent deletions
The concept of effects relation lays a theoretical foundation may intend to delete the same existing character. To handle
for analyzing system behavior. However, it relies on a this situation, we adopt a policy in which this character is
global data structure that is expensive to maintain in only deleted once. The deletion received later is trans-
practice. Here, we explore an approach that only uses local formed into an identity operation , which will not be
information. More specifically, each site maintains a local executed. This corresponds to lines 1-2 in Algorithm 1 and
history buffer HB for recording operations in their lines 8-9 in Algorithm 2.
execution order and a local table ER for recording the
derived effects relation. The effects relation is derived only Algorithm 2 get er ITðo1 ; o2 Þ: relation of charðo1 Þ and
by information in HB and ER. charðo2 Þ
We use operation keys to uniquely identify operations. 1: return the relation if it is found in ER
The key of any operation o, denoted by function keyðoÞ, is a 2: er charðo2 Þ charðo1 Þ
pair of the id of its generation site idðoÞ and its sequence 3: if posðo1 Þ < posðo2 Þ then
312 IEEE TRANSACTIONS ON PARALLEL AND DISTRIBUTED SYSTEMS, VOL. 18, NO. 3, MARCH 2007
by one had o1 not inserted charðo1 Þ on its left, or the position Proof. Since o1 and o2 are admissible and o1 is executed
parameter of o2 should be increased by one had o1 not before o2 , the character charðo1 Þ must be present in state
deleted on its left. s ¼ execðestðo1 Þ; o1 Þ. Due to Lemma 3, by comparing
In Algorithm 4, we define rules for determining the their positions posðo1 Þ ¼ s½charðo1 Þ and posðo2 Þ, we can
relation of charðo2 Þ and charðo1 Þ in ET only by their position correctly infer their effects relation. Specifically, we get
parameters. Previous work [19], [20] proposed that the charðo2 Þ charðo1 Þ if posðo2 Þ posðo1 Þ or charðo1 Þ
precondition of ET be estðo2 Þ ¼ execðestðo1 Þ; o1 Þ. However, charðo2 Þ if otherwise. u
t
this condition alone is not sufficient for determining the
Lemma 10. get er ETðo1 ; o2 Þ is correct if typeðo1 Þ ¼ ins,
relation of charðo1 Þ and charðo2 Þ in ET, as shown in the
following scenario: typeðo2 Þ ¼ del, and o1 ! o2 .
Example 4. Suppose three sites start from the same state Proof. By the given conditions and Lemma 3, charðo1 Þ must
s0 ¼ ‘‘abc}. Site 1 generates o1 ¼ delð1Þ to yield “ac.” be present in s ¼ estðo2 Þ and posðo1 Þ ¼ s½charðo1 Þ. Since
Concurrently, site 2 generates o2 ¼ insð2; ‘x’Þ to yield o2 is a deletion and it is admissible in s, it must be that
“abxc.” At site 3, assume o1 is executed first, yielding posðo2 Þ ¼ s½charðo2 Þ. Hence, we can correctly determine
s13 ¼ execðs0 ; o1 Þ ¼ ‘‘ac}. After that, o2 is received. We have their effects relation by comparing their position para-
o02 ¼ ITðo2 ; o1 Þ ¼ insð1; ‘x’Þ and s23 ¼ execðs13 ; o02 Þ ¼ ‘‘axc:’’. meters. In particular, if posðo1 Þ ¼ posðo2 Þ, it must be that
Then, site 3 generates o3 ¼ insð2; ‘y’Þ, yielding s33 ¼ ‘‘axyc:’’ charðo1 Þ ¼ charðo2 Þ. u
t
By Definition 2, we know charðo1 Þ charðo2 Þ charðo3 Þ, Lemma 11. get er ETðo1 ; o2 Þ is correct if
namely, charðo1 Þ charðo3 Þ. Now, examine how the
effects of o02 and o1 are excluded from o3 in turn. typeðo1 Þ ¼ typeðo2 Þ ¼ del;
First, process o03 ¼ ETðo3 ; o02 Þ. According to get_er_ET(), charðo1 Þ 6¼ charðo2 Þ, and o1 ! o2 .
we infer charðo2 Þ charðo3 Þ because posðo02 Þ < posðo3 Þ.
Lemma 12. get er ETðo1 ; o2 Þ is correct if typeðo1 Þ ¼ del,
Hence, o03 ¼ insð1; ‘y’Þ. Next, consider o003 ¼ ETðo03 ; o1 Þ.
typeðo2 Þ ¼ ins, charðo1 Þ 6¼ charðo2 Þ, o1 ! o2 , and
According to get_er_ET(), we have charðo3 Þ charðo1 Þ
because their positions tie, which contradicts the correct ðposðo1 Þ 6¼ posðo2 Þ or posðo1 Þ ¼ posðo2 Þ and
relation charðo1 Þ charðo3 Þ. Cld ðcharðo1 Þ; charðo2 ÞÞ ¼ ;Þ:
Algorithm 4 get er ETðo1 ; o2 Þ: relation of charðo1 Þ and Proof. Let s1 ¼ estðo1 Þ and s2 ¼ estðo2 Þ. Since o1 is a
charðo2 Þ deletion admissible in s1 , by Lemma 3, it must be
1: return the relation if it is found in ER posðo1 Þ ¼ s1 ½charðo1 Þ. If posðo1 Þ < posðo2 Þ, there must be
2: if posðo1 Þ < posðo2 Þ then at least one character between posðo1 Þ and posðo2 Þ in s2 .
3: er charðo1 Þ charðo2 Þ Hence, we infer charðo1 Þ charðo2 Þ. If posðo1 Þ > posðo2 Þ,
4: else if posðo1 Þ > posðo2 Þ then similarly, we infer charðo2 Þ charðo1 Þ.
5: er charðo2 Þ charðo1 Þ In the case that posðo1 Þ ¼ posðo2 Þ, by Lemma 3, it must
6: else { // posðo1 Þ ¼ posðo2 Þ } be that o2 inserts a character between the two characters
7: if typeðo1 Þ ¼ typeðo2 Þ ¼ ins then s2 ½posðo2 Þ 1 ¼ s1 ½posðo1 Þ 1 and
8: er charðo2 Þ charðo1 Þ
s2 ½posðo2 Þ ¼ s1 ½posðo1 Þ þ 1:
9: else if typeðo1 Þ ¼ typeðo2 Þ ¼ del then
10: er charðo1 Þ charðo2 Þ By Definition 2, Cld ðcharðo1 Þ; charðo2 ÞÞ considers all the
11: else if typeðo1 Þ ¼ del ^ typeðo2 Þ ¼ ins then characters that are present before either o1 or o2 is
12: er charðo2 Þ charðo1 Þ generated. If Cld ðcharðo1 Þ; charðo2 ÞÞ ¼ ;, by Definition 2,
13: else { // typeðo1 Þ ¼ ins ^ typeðo2 Þ ¼ del } we infer charðo2 Þ charðo1 Þ. u
t
14: er charðo1 Þ ¼ charðo2 Þ
15: end if
Corollary 3. Given that o1 is admissible in a reachable state s and
16: end if
o2 is admissible in s0 ¼ execðs; o1 Þ, then ET is correct or o02 ¼
17: record er in ER
ETðo2 ; o1 Þ is admissible in s if the effects relation between
18: return er
charðo1 Þ and charðo2 Þ can be found in ER or can be correctly
In the following lemmas, we examine by cases the determined by the rules of get er ETðo1 ; o2 Þ.
sufficient conditions of get er ETðo1 ; o2 Þ or, more specifi-
cally, the rules defined in lines 2-16. They all require the
following conditions: estðo2 Þ ¼ execðestðo1 Þ; o1 Þ, estðo1 Þ and 5 OPERATION INTEGRATION
estðo2 Þ are reachable states, and o1 and o2 are admissible. To execute (integrate) a remote operation o, we often have
We say get er ETðo1 ; o2 Þ is correct iff the relation between to transform o against a sequence of operations sq. We
charðo1 Þ and charðo2 Þ as determined by its rules is identical denote the process of inclusively transforming o against sq
to the effects relation obtained by Definition 2. as ITSQðo; sqÞ and that of exclusively transforming o against
Lemma 9. get er ETðo1 ; o2 Þ is correct if typeðo1 Þ ¼ typeðo2 Þ ¼ sq as ETSQðo; sqÞ. In this section, we study how to execute
ins and o1 ! o2 . remote operations and how to transform sequences.
314 IEEE TRANSACTIONS ON PARALLEL AND DISTRIBUTED SYSTEMS, VOL. 18, NO. 3, MARCH 2007
typeðsq½n 1Þ ¼ del, typeðoÞ ¼ ins, sq½n 1 ! o, and contextually serialized before sq0 . In general, all the
posðsq½n 1Þ ¼ posðoÞ, it is impossible to have any c in transposition functions in this paper produce effects-
estðoÞ such that charðsq½n 1Þ c charðoÞ. Otherwise, equivalent sequences. Specifically, ½o01 ; o02 ½o2 ; o1 in
we would have posðsq½n 1Þ < posðoÞ, which contra- Transposeðo2 ; o1 Þ, o0 þ sq0 sq þ o in TransposeOSqðsq; oÞ,
dicts posðsq½n 1Þ ¼ posðoÞ. Since sqh þ sqc sq in TransposePreConðo; sqÞ, sqi þ sqd sq in
TransposeInsDelðsqÞ, and sq0 sq in BuildETSOSðsqÞ.
estðoÞ ¼ execðestðsq½0Þ; sqÞ
Sn1 Algorithm 9 TransposePreConðo; sqÞ: < sqh ; sqc >
and Csq ¼ i¼0 fcharðsq½iÞg [ estðsq½0Þ, with the above 1: sqh ;; sqc ;
two conclusions combined, we infer that there is no 2: for ði ¼ 0; i < jsqj; i þ þÞ do
character c in Csq such that charðsq½n 1Þ c charðoÞ. 3: if sq½i k o then
Therefore, we conclude Cld ðcharðoÞ; charðsq½n 1ÞÞ ¼ ;, 4: sqc sqc þ sq½i
or there exists at least one character c such that 5: else
charðoÞ c charðsq½n 1Þ. In either case, by the def-
6: < oi ; sqc > TransposeOSqðsqc ; sq½iÞ
inition of relation , we get charðoÞ charðsq½n 1Þ.
7: sqh sqh þ oi
Hence, ETðo; sq½n 1Þ is correct.
8: end if
Induction: Assume that processing of ETSQðo; sq½i þ
9: end for
1; n 1Þ is correct. Let o0 be the execution form of o
10: return < sqh ; sqc >
relative to estðsq½i þ 1Þ. By Lemma 14 and Algorithm 6, at
the time ETðo0 ; sq½iÞ is processed, o0 must have been Functions TransposePreCon() and TransposeInsDel()
exclusively transformed with all operations from sq½n 1 have similar structures. TransposePreConðo; sqÞ is adopted
to sq½i þ 1, inclusively. Hence, charðoÞ charðsq½kÞ from [16], [19]. It transposes sq into sqh þ sqc , such that sqh ,
must hold, where i þ 1 k n 1. Otherwise, the all operations that happened before o, are contextually
ET process should have stopped for some k. Since serialized before sqc , all those concurrent with o. It scans sq
Cld ðcharðoÞ; charðsq½iÞÞ Csq , similar to the base case, from left to right and appends every sq½i that is concurrent
there must not exist c such that charðsq½iÞ c charðoÞ, with o to sqc . For every sq½i that happened before o, it first
or we would have posðsq½iÞ < posðoÞ, which contradicts transposes sq½i and sqc and then appends sq½i to sqh .
Similarly, TransposeInsDelðsqÞ transposes sq such that all
posðsq½iÞ ¼ posðoÞ. Then, by the definition of relation ,
insertions ðsqi Þ are contextually serialized before all
no matter whether or not there exists c such that
deletions ðsqd Þ.
charðoÞ c charðsq½iÞ, we get charðoÞ charðsq½iÞ.
Hence, ETðo; sq½iÞ is correct. u
t Algorithm 10 TransposeInsDelðsqÞ: < sqi ; sqd >
1: sqi ;; sqd ;
5.5 Transposing Sequences
2: for ði ¼ 0; i < jsqj; i þ þÞ do
Transposeðo2 ; o1 Þ is to transpose two contextually serialized 3: if typeðsq½iÞ ¼ del then
operations o2 and o1 such that in the output o01 is 4: sqd sqd þ sq½i
contextually serialized before o02 . Since o2 is contextually 5: else
serialized before o1 , we first do o01 ¼ ETðo1 ; o2 Þ such that o01
6: < oi ; sqd > TransposeOSqðsqd ; sq½iÞ
and o2 are defined in the same state, and then do o02 ¼
7: sqi sqi þ oi
ITðo2 ; o01 Þ such that o02 is defined in state execðestðo01 Þ; o01 Þ.
8: end if
Note, if o1 depends on o2 , i.e., typeðo2 Þ ¼ ins, typeðo1 Þ ¼ del,
9: end for
o2 ! o1 , and posðo1 Þ ¼ posðo2 Þ, we know charðo1 Þ ¼ charðo2 Þ
10: return < sqi ; sqd >
and return < o1 ; o2 > .
Algorithm 7 Transposeðo2 ; o1 Þ: < o01 ; o02 > 5.6 Building ET-Safe Sequences
1: {// determined as in get_er_ET} Given a sequence sq, function BuildETSOSðsqÞ incremen-
2: if charðo1 Þ ¼ charðo2 Þ then tally builds an ETSOS sq0 . Initially, sq0 only includes sq½0.
3: return < o1 ; o2 > Then, each time a new element sq½i is added into sq0 . It
4: else transposes sq½i with operations in sq0 from right to left until
5: o01 ETðo1 ; o2 Þ some sq0 ½j is found (line 12) such that charðsq0 ½jÞ charðoÞ,
6: o02 ITðo2 ; o01 Þ which is exactly the condition defined in Lemma 14. Under
7: return < o01 ; o02 > this case, o is inserted after sq0 ½j (line 13). The relation
8: end if between charðoÞ and other operations in the rest of sq is
known and directly recorded in the local effects relation ER
Algorithm 8 TransposeOSqðsq; oÞ: < o0 ; sq0 > (line 10). If the condition never appears, as in lines 20-22,
1: o0 o; sq0 sq then o is added to the head of sq0 .
2: for ði ¼ jsqj 1; i 0; i Þ do Lemma 16. Given an admissible sequence sq defined in the initial
3: < o0 ; sq0 ½i > Transposeðsq0 ½i; o0 Þ system state s0 , which preserves the causal order of operations,
4: end for sq0 ¼ BuildETSOSðsqÞ is correct, i.e., sq0 is an ETSOS and
5: return < o0 ; sq0 > every operation in sq0 is admissible.
The precondition of TransposeOSqðsq; oÞ is that sq is Proof. Examine the process of building an ETSOS sq0 from
contextually serialized before o. The output is such that o0 is sq: Each time we add a new operation sq½i into the
LI AND LI: A NEW OPERATIONAL TRANSFORMATION FRAMEWORK FOR REAL-TIME GROUP EDITORS 317
partial result sq0 that was built from sq½0; i 1, sequence remote operation o is queued until it is causally-ready, i.e.,
sq0 is scanned from right to left to find the right position all operations that happened before o are in HB. Suppose
to insert sq½i. Note that each operation in sequence sq0 the initial state is s0 , the current state is s0 , and o is generated
actually represents a state transition. Hence, to insert in state s. Then, function Integrateðo; HBÞ is called to derive
sq½i before some position sq0 ½j, we have to transpose an o0 such that o0 is admissible in s0 . If o0 ¼ , it is discarded.
sq0 ½j; i 1 and sq½i. That is, the correctness of BuildET- Otherwise, o0 is executed and appended to HB. Apparently,
HB is a contextually serialized sequence.
SOS() depends on the correctness of Transpose().
In function Transposeðo1 ; o2 Þ, ET is always called Algorithm 12 Integrateðo; HBÞ: o0
before IT. If o01 ¼ ETðo1 ; o2 Þ is correct, then the relation 1: < sqh ; sqc > TransposePreConðo; HBÞ
of charðo1 Þ and charðo2 Þ is known, which ensures the 2: if sqc ¼ ; then
correctness of ITðo2 ; o01 Þ. Hence, we only need to prove 3: return o0 o
the correctness of ETSQðsq½i; sq0 ½j; i 1Þ. This can be 4: end if
further reduced to prove that the conditions of Lemma 15 5: if typeðoÞ ¼ del then
can be satisfied before calling BuildETSOS(). We prove 6: return o0 ITSQðo; sqc Þ
this by induction.
7: else { // typeðoÞ ¼ ins }
Algorithm 11 BuildETSOSðsqÞ: sq0 8: sqh0 BuildETSOSðsqh Þ
1: if jsqj < 1 then 9: < sqhi ; sqhd > TransposeInsDelðsqh0 Þ
2: return sq0 sq 10: sqhdc BuildETSOSðsqhd þ sqc Þ
3: end if 11: < sqi ; sqd > TransposeInsDelðsqhdc Þ
4: sq0 ½sq½0 12: o00 ETSQðo; sqhd Þ {// Pb ¼ sqhd }
5: for ði ¼ 1; i < jsqj; i þ þÞ do 13: o0 ITSQðo00 ; sqi þ sqd Þ {// Pf ¼ sqi þ sqd }
6: o sq½i 14: return o0
7: flag false 15: end if
8: for ðj ¼ jsq0 j 1; j 0; j Þ do In Integrateðo; HBÞ, we first call TransposePreConðo; HBÞ
9: if flag ¼ true then to transpose HB into two sequences: sqh , which includes all
10: record charðsq0 ½jÞ charðoÞ into ER operations that happened before o, and sqc , which includes
11: else {//effects relation determined as in get_er_ET} all operations that are concurrent with o. Due to causality,
12: if charðsq0 ½jÞ charðoÞ then we have os ¼ gstðoÞ ¼ execðs0 ; sqh Þ.
13: sq0 sq0 ½0; j þ o þ sq0 ½j þ 1; jsq0 j 1 If sqc is empty, it means s0 ¼ gstðoÞ. Then, o is returned
14: flag true as it is (lines 2-3) and will be executed in s0 directly. If sqc
15: else contains concurrent operations, we must incorporate the
16: < o; sq0 ½j > Transposeðsq0 ½j; oÞ effects of those operations into o to get its execution form
17: end if o0 in s0 . By the above analyses, we cannot perform
ITSQðo; sqc Þ until the preconditions defined in Lemma 13
18: end if
are satisfied. If typeðoÞ ¼ del, ITSQðo; sqc Þ is guaranteed to
19: end for
be correct (lines 5-6).
20: if flag ¼ false then However, if typeðoÞ ¼ ins, we must first construct
21: sq0 o þ sq0 Pb and Pf , then compute o00 ¼ ETSQðo; Pb Þ, and, finally,
22: end if o0 ¼ ITSQðo00 ; Pf Þ. Sequence Pb is constructed in lines 8-9:
23: end for We first build an ETSOS sqh0 from sqh , the sequence of all
24: return sq0 operations that happened before o, and then transpose sqh0
Base: Consider ETðsq½1; sq½0Þ. If sq½1 k sq½0, then into two subsequences, sqhi and sqhd , such that sqhi
includes all insertions that happened before o and sqhd
ETðsq½1; sq½0Þ is correct because the effects relation
includes all deletions that happened before o. Then, sqhd is
between concurrent operations has been recorded.
just the transformation path Pb we need.
Otherwise, it must be sq½0 ! sq½1 by causality. Because
Next, we construct Pf as in lines 10-11: We first build an
gstðsq½0Þ ¼ s0 and there is no other operation, we have
ETSOS sqhdc from sqhd þ sqc and then transpose sqhdc into
Cld ðcharðsq½0Þ; charðsq½1ÞÞ Csq . Hence, ETðsq½1; sq½0Þ two sequences, sqi and sqd , such that sqi includes all the
is correct. insertions and sqd all the deletions. Sequence Pf is just
Induction: Suppose sq0 is the ETSOS correctly built sqi þ sqd , the concatenation of sqi and sqd .
from sq½0; iS 1. Now, check how sq½i is added into sq0 .
Let Csq0 ¼ i1 0 0 0 Theorem 2. o0 ¼ Integrateðo; HBÞ is admissible in state s0 .
j¼0 ðcharðsq ½jÞÞ [ s . Since sq ½0 is defined
0
on s and all operations that happened before sq½i are in Proof. The assertion is easily verified if typeðoÞ ¼ del.
sq0 , it is obvious that Cld ðcharðsq½iÞ; charðsq0 ½jÞÞ Csq0 When typeðoÞ ¼ ins, the correctness of Integrate() relies
for any 0 j < jsq0 j and sq0 ½j ! sq½i. By Lemma 15, on four steps:
ETSQðsq½i; sq0 Þ is correct. u
t
1. TransposePreCon() in line 1,
5.7 The Integration Procedure 2. the construction of Pb in lines 8-9 and Pf in
The top-level control algorithm executes local and remote lines 10-11,
operations. For best responsiveness, any local operation is 3. ETSQðo; Pb Þ in line 12, and
executed and appended to HB once it is generated. Any 4. ITSQðo00 ; Pf Þ in line 13.
318 IEEE TRANSACTIONS ON PARALLEL AND DISTRIBUTED SYSTEMS, VOL. 18, NO. 3, MARCH 2007
To evaluate the proposed CR framework, we exemplify [8] M.J. Knister and A. Prakash, “A Framework for Undoing Actions
in Collaborative Systems,” ACM Trans. Computer-Human Interac-
a novel OT algorithm (called landmark-based transforma- tion, vol. 1, no. 4, pp. 295-330, Dec. 1994.
tion or LBT), which is testimony to the above design [9] D. Li and R. Li, “Ensuring Content and Intention Consistency in
guidelines. Specifically, the transformation functions in LBT Real-Time Group Editors,” Proc. 24th IEEE Int’l Conf. Distributed
Computing Systems (ICDCS ’04), pp. 748-755, Mar. 2004.
only use basic information such as operation type, position
[10] D. Li and R. Li, “Preserving Operation Effects Relation in Group
parameter, and site id. The concepts of IT/ET safe operation Editors,” Proc. ACM Conf. Computer-Supported Cooperative Work
sequences reveal practicable heuristics for constructing the (CSCW ’04), pp. 457-466, Nov. 2004.
special transformation paths. As demonstrated by the [11] D. Li and R. Li, “An Approach to Ensuring Consistency in Peer-to-
Peer Real-Time Group Editors,” Computer Supported Cooperative
design of the LBT algorithm, the CR framework simplifies Work: J. Collaborative Computing, Oct. 2005.
the design of transformation functions because it no longer [12] R. Li, D. Li, and C. Sun, “A Time Interval Based Consistency
demands that transformation functions (IT) work in all Control Algorithm for Interactive Groupware Applications,” Proc.
IEEE Int’l Conf. Parallel and Distributed Systems (ICPADS ’04),
possible cases. That is, it theoretically frees the difficult TP2 pp. 429-436, July 2004.
condition that is established in [14] and well-accepted in the [13] M. Raynal and M. Singhal, “Logical Time: Capturing Causality in
literature [16], [17], [19]. Distributed Systems,” Computer, pp. 49-56, Feb. 1996.
[14] M. Ressel, D. Nitsche-Ruhland, and R. Gunzenhäuser, “An
However, more work is necessary to evaluate these ideas
Integrating, Transformation-Oriented Approach to Concurrency
in a wider range of application domains. The proposed Control and Undo in Group Editors,” Proc. ACM Conf. Computer-
framework and algorithms seem generally applicable for Supported Cooperative Work (CSCW ’96), pp. 288-297, Nov. 1996.
optimistic consistency control on linear data structures. In [15] H. Shen and C. Sun, “Flexible Notification for Collaborative
Systems,” Proc. ACM Conf. Computer-Supported Cooperative Work
future research, we plan to extend this work to support tree- (CSCW ’02), pp. 77-86, Nov. 2002.
based data structures [4] and string operations [20]. Another [16] M. Suleiman, M. Cart, and J. Ferrié, “Concurrent Operations in a
possible direction is to support selective undo [17] such Distributed and Mobile Collaborative Environment,” Proc. IEEE
Int’l Conf. Data Eng. (ICDE ’98), pp. 36-45, Feb. 1998.
that any executed operation can be undone at any time. [17] C. Sun, “Undo as Concurrent Inverse in Group Editors,” ACM
Conceptually, computing an admissible operation in group Trans. Computer-Human Interaction, vol. 9, no. 4, pp. 309-361, Dec.
undo is an inverse process of that in group do. The 2002.
[18] C. Sun and D. Chen, “Consistency Maintenance in Real-Time
presented work seems to provide valuable insights into this Collaborative Graphics Editing Systems,” ACM Trans. Computer-
problem. In addition, this work defines a set of sufficient Human Interaction, vol. 9, no. 1, pp. 1-41, Mar. 2002.
conditions for IT/ET as a means to develop OT algorithms [19] C. Sun and C. Ellis, “Operational Transformation in Real-Time
Group Editors: Issues, Algorithms, and Achievements,” Proc.
and prove their correctness. In future work, it would also be ACM Conf. Computer-Supported Cooperative Work (CSCW ’98),
interesting to study necessary conditions and even suffi- pp. 59-68, Dec. 1998.
cient and necessary conditions. [20] C. Sun, X. Jia, Y. Zhang, Y. Yang, and D. Chen, “Achieving
Convergence, Causality-Preservation, and Intention-Preservation
in Real-Time Cooperative Editing Systems,” ACM Trans. Compu-
ACKNOWLEDGMENTS ter-Human Interaction, vol. 5, no. 1, pp. 63-108, Mar. 1998.
[21] D. Sun, S. Xia, C. Sun, and D. Chen, “Operational Transformation
The authors thank the associate editor, Dr. Philip K. for Collaborative Word Processing,” Proc. ACM Conf. Computer-
McKinley, and the anonymous expert referees for their Supported Cooperative Work (CSCW ’04), pp. 162-171, Nov. 2004.
[22] N. Vidot, M. Cart, J. Ferrie, and M. Suleiman, “Copies Conver-
insightful and constructive review comments, which sig- gence in a Distributed Realtime Collaborative Environment,” Proc.
nificantly improved the readability, technical quality, and ACM Conf. Computer-Supported Cooperative Work (CSCW ’00),
pp. 171-180, Dec. 2000.
presentation of this paper. This work was supported in part [23] W.E. Weihl, “Commutativity-Based Concurrency Control for
by the US National Science Foundation under CAREER Abstract Data Types,” IEEE Trans. Computers, vol. 37, no. 12,
award IIS-0133871. pp. 1488-1504, Dec. 1988.
[24] H. Yu and A. Vahdat, “Design and Evaluation of a Conit-Based
Continuous Consistency Model for Replicated Services,” ACM
Trans. Computer Systems, vol. 20, no. 3, pp. 239-282, Aug. 2002.
REFERENCES
[1] B.R. Badrinath and K. Ramamritham, “Semantics-Based Concur- Rui Li is a PhD candidate in the Department of
rency Control: Beyond Commutativity,” ACM Trans. Database Computer Science, Texas A&M University. His
Systems, vol. 17, no. 1, pp. 163-199, Mar. 1992. research interests include groupware, user
[2] P. Bellini, P. Nesi, and M.B. Spinu, “Cooperative Visual interfaces, and distributed systems. His PhD
Manipulation of Music Notation,” ACM Trans. Computer-Human dissertation focuses on operational transforma-
Interaction, vol. 9, no. 3, pp. 194-237, Sept. 2002. tion-based consistency control in group editors.
[3] P.A. Bernstein, V. Hadzilacos, and N. Goodman, Concurrency He is a student member of the IEEE.
Control and Recovery in Database Systems. Addison-Wesley, 1987.
[4] A.H. Davis, C. Sun, and J. Lu, “Generalizing Operational
Transformation to the Standard General Markup Language,”
Proc. ACM Conf. Computer-Supported Cooperative Work (CSCW ’02),
pp. 58-67, Nov. 2002.
[5] P. Dewan, R. Choudhary, and H. Shen, “An Editing-Based Du Li received the PhD degree from the
Characterization of the Design Space of Collaborative Applica- University of California, Los Angeles in 2000.
tions,” J. Organizational Computing, vol. 4, no. 3, pp. 219-240, 1994. He is currently an assistant professor in the
[6] C.A. Ellis and S.J. Gibbs, “Concurrency Control in Groupware Department of Computer Science, Texas A&M
Systems,” Proc. ACM SIGMOD Conf. Management of Data, pp. 399- University. His research interests include group-
407, 1989. ware, computer-supported cooperative work,
[7] S. Greenberg and D. Marwood, “Real-Time Groupware as a distributed systems, and software engineering.
Distributed System: Concurrency Control and Its Effect on the He is a member of the IEEE and the IEEE
Interface,” Proc. ACM Conf. Computer-Supported Cooperative Work Computer Society.
(CSCW ’94), pp. 207-217, Oct. 1994.