@@ -134,39 +134,46 @@ end
134
134
-- just check expirationd task continue work after conflicts
135
135
function g .test_mvcc_vinyl_tx_conflict (cg )
136
136
t .skip_if (cg .params .engine ~= ' vinyl' , ' Unsupported engine' )
137
- -- TODO: Remove the line below when tarantool/expirationd#105 is resolved.
138
- t .skip (' Skipped until tarantool/expirationd#105 is resolved' )
137
+ local tuples_cnt = 10
139
138
140
- for i = 1 ,10 do
139
+ for i = 1 ,tuples_cnt do
141
140
cg .space :insert ({i , tostring (i ), nil , nil , 0 })
142
141
end
143
142
144
143
local updaters = {}
145
- for i = 1 ,10 do
146
- local updater = fiber .create (function ()
144
+ for i = 1 ,tuples_cnt do
145
+ local updater = fiber .new (function ()
147
146
fiber .name (string.format (" updater of %d" , i ), { truncate = true })
148
- while true do
149
- cg .space :update ({i }, { {" +" , 5 , 1 } })
150
- fiber .yield ()
151
- end
147
+ cg .space :update ({i }, { {" +" , 5 , 1 } })
152
148
end )
149
+ updater :set_joinable (true )
153
150
table.insert (updaters , updater )
154
151
end
155
152
156
- local task = expirationd .start (" clean_all" , cg .space .id , helpers .is_expired_debug ,
157
- {atomic_iteration = true })
153
+ local is_expired = function (args , tuple )
154
+ -- The idea is to switch explicity to an updater fiber in the middle of
155
+ -- an expirationd's transaction:
156
+ -- Delete from expirationd + update from an updater == conflict at the
157
+ -- expirationd's transaction.
158
+ fiber .yield ()
159
+ return helpers .is_expired_debug (args , tuple )
160
+ end
158
161
159
- -- wait for tuples expired
160
- fiber .sleep (3 )
162
+ helpers .iteration_result = {}
163
+ local task = expirationd .start (" clean_all" , cg .space .id , is_expired ,
164
+ {atomic_iteration = true })
165
+ -- ensure that expirationd task does not delete a tuple yet
166
+ t .assert_equals (helpers .iteration_result , {})
161
167
162
- for i = 1 , 10 do
163
- updaters [ i ]: cancel ()
168
+ for _ , updater in pairs ( updaters ) do
169
+ updater : join ()
164
170
end
165
171
166
172
helpers .retrying ({}, function ()
167
173
t .assert_equals (cg .space :select (), {})
168
174
end )
169
- t .assert (box .stat .vinyl ().tx .conflict > 0 )
175
+ t .assert_gt (box .stat .vinyl ().tx .conflict , 0 )
176
+ t .assert_gt (# helpers .iteration_result , tuples_cnt )
170
177
t .assert_equals (box .stat .vinyl ().tx .conflict , box .stat .vinyl ().tx .rollback )
171
178
t .assert_equals (box .stat .vinyl ().tx .transactions , 0 )
172
179
task :kill ()
0 commit comments