Skip to content

Commit 9b2f121

Browse files
author
Tomasz Stepniak
committed
WL#11417 - DevAPI : Support locking modes: NOWAIT and SKIP LOCKED
Add support for NOWAIT and SKIP LOCKED options when doing a locking read in the X plugin. RB: 18440 Reviewed by: Grzegorz Szwarc <grzegorz.szwarc@oracle.com> Reviewed by: Lukasz Kotula <lukasz.kotula@oracle.com> Approved by: Horst Hunger <horst.hunger@oracle.com>
1 parent 13bf7c4 commit 9b2f121

File tree

8 files changed

+402
-396
lines changed

8 files changed

+402
-396
lines changed

mysql-test/suite/x/r/features.result

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ send Mysqlx.Expect.Open {
1818

1919
ok
2020

21+
[Verification of Mysqlx.Crud.Find::locking_options (17.13)]
22+
send Mysqlx.Expect.Open {
23+
cond {
24+
condition_key: 2
25+
condition_value: "17.13"
26+
}
27+
}
28+
29+
ok
30+
2131
[Verification of all features in single request]
2232
send Mysqlx.Expect.Open {
2333
cond {
@@ -28,6 +38,10 @@ send Mysqlx.Expect.Open {
2838
condition_key: 2
2939
condition_value: "17.12"
3040
}
41+
cond {
42+
condition_key: 2
43+
condition_value: "17.13"
44+
}
3145
}
3246

3347
ok

mysql-test/suite/x/r/find_row_locking.result

Lines changed: 167 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
1 rows affected
1616

17+
1 rows affected
18+
1719
0 rows affected
1820
connecting...
1921
active session is now 'session1'
@@ -32,7 +34,7 @@ switched to session session2
3234

3335
0 rows affected
3436
doc
35-
{"a": 1, "_id": "2"}
37+
{"a": 2, "_id": "2"}
3638
command ok
3739
doc
3840
{"a": 1, "_id": "1"}
@@ -58,7 +60,7 @@ switched to session session2
5860

5961
0 rows affected
6062
doc
61-
{"a": 1, "_id": "2"}
63+
{"a": 2, "_id": "2"}
6264
command ok
6365
Got expected error: Lock wait timeout exceeded; try restarting transaction (code 1205)
6466
Verify [Expecting performance_schema.data_locks to be not empty]
@@ -82,10 +84,10 @@ switched to session session2
8284

8385
0 rows affected
8486
doc
85-
{"a": 1, "_id": "2"}
87+
{"a": 2, "_id": "2"}
8688
command ok
8789
doc
88-
{"a": 1, "_id": "3"}
90+
{"a": 30, "_id": "3"}
8991
command ok
9092
Got expected error: Lock wait timeout exceeded; try restarting transaction (code 1205)
9193
Verify [Expecting performance_schema.data_locks to be not empty]
@@ -109,7 +111,7 @@ switched to session session2
109111

110112
0 rows affected
111113
doc
112-
{"a": 1, "_id": "2"}
114+
{"a": 2, "_id": "2"}
113115
command ok
114116
Got expected error: Lock wait timeout exceeded; try restarting transaction (code 1205)
115117
Verify [Expecting performance_schema.data_locks to be not empty]
@@ -120,6 +122,166 @@ switched to session session2
120122

121123
0 rows affected
122124
Verify [Expecting performance_schema.data_locks to be empty]
125+
######### Locking with aggregate #########
126+
######### Shared lock with grouping #########
127+
switched to session session1
128+
Verify [Expecting performance_schema.data_locks to be empty]
129+
130+
0 rows affected
131+
doc
132+
{"a": 1, "_id": "1"}
133+
command ok
134+
Verify [Expecting performance_schema.data_locks to be not empty]
135+
switched to session session2
136+
137+
0 rows affected
138+
doc
139+
{"a": 1}
140+
{"a": 2}
141+
{"a": 30}
142+
command ok
143+
Verify [Expecting performance_schema.data_locks to be not empty]
144+
switched to session session1
145+
146+
0 rows affected
147+
switched to session session2
148+
149+
0 rows affected
150+
Verify [Expecting performance_schema.data_locks to be empty]
151+
######### Exclusive lock with grouping #########
152+
switched to session session1
153+
Verify [Expecting performance_schema.data_locks to be empty]
154+
155+
0 rows affected
156+
doc
157+
{"a": 1, "_id": "1"}
158+
command ok
159+
Verify [Expecting performance_schema.data_locks to be not empty]
160+
switched to session session2
161+
162+
0 rows affected
163+
doc
164+
{"a": 1}
165+
{"a": 2}
166+
{"a": 30}
167+
command ok
168+
Verify [Expecting performance_schema.data_locks to be not empty]
169+
switched to session session1
170+
171+
0 rows affected
172+
switched to session session2
173+
174+
0 rows affected
175+
Verify [Expecting performance_schema.data_locks to be empty]
176+
######### Locking options #########
177+
######### Shared lock with NOWAIT #########
178+
switched to session session1
179+
Verify [Expecting performance_schema.data_locks to be empty]
180+
181+
0 rows affected
182+
doc
183+
{"a": 1, "_id": "1"}
184+
command ok
185+
Verify [Expecting performance_schema.data_locks to be not empty]
186+
switched to session session2
187+
188+
0 rows affected
189+
Got expected error: Statement aborted because lock(s) could not be acquired immediately and NOWAIT is set. (code 3572)
190+
Verify [Expecting performance_schema.data_locks to be not empty]
191+
switched to session session1
192+
193+
0 rows affected
194+
switched to session session2
195+
196+
0 rows affected
197+
Verify [Expecting performance_schema.data_locks to be empty]
198+
######### Shared lock with SKIP LOCKED #########
199+
switched to session session1
200+
Verify [Expecting performance_schema.data_locks to be empty]
201+
202+
0 rows affected
203+
doc
204+
{"a": 1, "_id": "1"}
205+
command ok
206+
Verify [Expecting performance_schema.data_locks to be not empty]
207+
switched to session session2
208+
209+
0 rows affected
210+
doc
211+
{"a": 2, "_id": "2"}
212+
{"a": 30, "_id": "3"}
213+
{"a": 30, "_id": "4"}
214+
command ok
215+
Verify [Expecting performance_schema.data_locks to be not empty]
216+
switched to session session1
217+
218+
0 rows affected
219+
switched to session session2
220+
221+
0 rows affected
222+
Verify [Expecting performance_schema.data_locks to be empty]
223+
######### Exclusive lock with NOWAIT #########
224+
switched to session session1
225+
Verify [Expecting performance_schema.data_locks to be empty]
226+
227+
0 rows affected
228+
doc
229+
{"a": 1, "_id": "1"}
230+
command ok
231+
Verify [Expecting performance_schema.data_locks to be not empty]
232+
switched to session session2
233+
234+
0 rows affected
235+
Got expected error: Statement aborted because lock(s) could not be acquired immediately and NOWAIT is set. (code 3572)
236+
Verify [Expecting performance_schema.data_locks to be not empty]
237+
switched to session session1
238+
239+
0 rows affected
240+
switched to session session2
241+
242+
0 rows affected
243+
Verify [Expecting performance_schema.data_locks to be empty]
244+
######### Exclusive lock with SKIP LOCKED #########
245+
switched to session session1
246+
Verify [Expecting performance_schema.data_locks to be empty]
247+
248+
0 rows affected
249+
doc
250+
{"a": 1, "_id": "1"}
251+
command ok
252+
Verify [Expecting performance_schema.data_locks to be not empty]
253+
switched to session session2
254+
255+
0 rows affected
256+
doc
257+
{"a": 2, "_id": "2"}
258+
{"a": 30, "_id": "3"}
259+
{"a": 30, "_id": "4"}
260+
command ok
261+
Verify [Expecting performance_schema.data_locks to be not empty]
262+
switched to session session1
263+
264+
0 rows affected
265+
switched to session session2
266+
267+
0 rows affected
268+
Verify [Expecting performance_schema.data_locks to be empty]
269+
######### NOWAIT set but no locking #########
270+
Mysqlx.Error {
271+
severity: ERROR
272+
code: 5169
273+
msg: "Invalid \"find\" message, \"locking\" field is required when \"locking_options\" is set."
274+
sql_state: "HY000"
275+
}
276+
277+
######### SKIP LOCKED set but no locking #########
278+
Mysqlx.Error {
279+
severity: ERROR
280+
code: 5169
281+
msg: "Invalid \"find\" message, \"locking\" field is required when \"locking_options\" is set."
282+
sql_state: "HY000"
283+
}
284+
123285
closing session session2
124286
Mysqlx.Ok {
125287
msg: "bye!"

mysql-test/suite/x/t/features.test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ Mysqlx.Expect.Close {
5050
-->varlet %ALL_COND%
5151
-->callmacro Verify_feature_existence Mysqlx.Crud.Insert::upsert 18.6
5252
-->callmacro Verify_feature_existence Mysqlx.Crud.Find::locking 17.12
53+
-->callmacro Verify_feature_existence Mysqlx.Crud.Find::locking_options 17.13
5354
-->callmacro Verify_expect_open all features in single request %ALL_COND%
5455
EOF
5556

0 commit comments

Comments
 (0)