-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.txt
162 lines (143 loc) · 2.45 KB
/
tests.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
// Test 1.
// T2 should abort, T1 should not, because of wait-die
// Younger T2 aborts.
begin(T1)
begin(T2)
W(T1,x1,101); W(T2,x2,202)
W(T1,x2,102); W(T2,x1,201)
end(T1)
dump()
=== output of dump
x1: 101 at site 2
x2: 102 at all sites
All other variables have their initial values.
// Test 2
// No aborts happens, since read-only transactions use
// multiversion read protocol.
begin(T1)
beginRO(T2)
W(T1,x1,101); R(T2,x2)
W(T1,x2,102); R(T2,x1)
end(T1)
end(T2)
dump()
=== output of dump
x1: 101 at site 2
x2: 102 at all sites
All other variables have their initial values.
// Test 3
// T1 should not abort because its site did not fail.
// In fact all transactions commit
begin(T1)
begin(T2)
R(T1,x3)
fail(2)
W(T2,x8,88); R(T2,x3)
W(T1, x5,91)
end(T2)
recover(2)
end(T1)
// Test 4
// Now T1 aborts, since site 2 died after T1 accessed it. T2 ok.
// Normally, we wait till the end(T1) to abort T1.
// However, it is ok to abort T1 right away when fail(2) happens. Both
// are correct.
begin(T1)
begin(T2)
R(T1,x1)
fail(2)
W(T2,x8,88); R(T2,x3)
R(T1, x5)
end(T2)
recover(2)
end(T1)
// Test 5
// T1 fails again here because it wrote to a site that failed. T2 ok.
begin(T1)
begin(T2)
W(T1,x6,66)
fail(2)
W(T2,x8,88); R(T2,x3)
R(T1, x5)
end(T2)
recover(2)
end(T1)
// Test 6
// T1 ok. T2 ok. T2 reads from a recovering site, but odd variables only
// at that site
begin(T1)
begin(T2)
fail(3); fail(4)
R(T1,x1)
W(T2,x8,88)
end(T1)
recover(4); recover(3)
R(T2,x3)
end(T2)
// Test 7
// T2 should read the initial version of x3 based on multiversion read
// consistency.
begin(T1)
beginRO(T2)
R(T2,x1)
R(T2,x2)
W(T1,x3,33)
end(T1)
R(T2,x3)
end(T2)
// Test 8
// T2 still reads the initial value of x3
// T3 still reads the value of x3 written by T1
begin(T1)
beginRO(T2)
R(T2,x1)
R(T2,x2)
W(T1,x3,33)
end(T1)
beginRO(T3)
R(T3,x3)
R(T2,x3)
end(T2)
end(T3)
// xTest 9
// T1, T2, T3 ok. T3 should wait because older
begin(T3)
begin(T1)
begin(T2)
W(T3,x2,22)
W(T2,x4,44)
R(T3,x4)
end(T2)
end(T3)
R(T1,x2)
end(T1)
// Test 10
// T3 should not wait and should abort
begin(T1)
begin(T2)
begin(T3)
W(T3,x2,22)
W(T2,x4,44)
R(T3,x4)
end(T2)
R(T1,x2)
end(T1)
// Test 11
// T2 should abort because it is waiting on R(T1,x2) but is younger so
// T2 cannot wait for T1.
// Note there is no end(T2) because it aborts
begin(T1)
begin(T2)
R(T1,x2)
R(T2,x2)
W(T2,x2,10)
end(T1)
// Test 12
// T2 should not abort because it is not waiting on R(T1,x2).
begin(T1)
begin(T2)
R(T1,x2)
R(T2,x2)
end(T1)
W(T2,x2,10)
end(T2)