@@ -179,6 +179,12 @@ type ClientOperationConfig struct {
179
179
PutMissing int
180
180
// PutExisting is an operation that Puts a key that likely exists.
181
181
PutExisting int
182
+ // PutMustAcquireExclusiveLockMissing is an operation that Puts a key that
183
+ // definitely doesn't exist, with MustAcquireExclusiveLock set to true.
184
+ PutMustAcquireExclusiveLockMissing int
185
+ // PutMustAcquireExclusiveLockExisting is an operation that Puts a key that
186
+ // likely exists, with MustAcquireExclusiveLock set to true.
187
+ PutMustAcquireExclusiveLockExisting int
182
188
// Scan is an operation that Scans a key range that may contain values.
183
189
Scan int
184
190
// ScanForUpdate is an operation that Scans a key range that may contain
@@ -259,6 +265,12 @@ type ClientOperationConfig struct {
259
265
DeleteMissing int
260
266
// DeleteExisting is an operation that Deletes a key that likely exists.
261
267
DeleteExisting int
268
+ // DeleteMustAcquireExclusiveLockMissing is an operation that Deletes a key
269
+ // that definitely doesn't exist, with MustAcquireExclusiveLock set to true.
270
+ DeleteMustAcquireExclusiveLockMissing int
271
+ // DeleteExisting is an operation that Deletes a key that likely exists, with
272
+ // MustAcquireExclusiveLock set to true.
273
+ DeleteMustAcquireExclusiveLockExisting int
262
274
// DeleteRange is an operation that Deletes a key range that may contain values.
263
275
DeleteRange int
264
276
// DeleteRange is an operation that invokes DeleteRangeUsingTombstone.
@@ -388,15 +400,17 @@ func newAllOperationsConfig() GeneratorConfig {
388
400
GetExistingForUpdateSkipLockedGuaranteedDurability : 1 ,
389
401
GetExistingForShareSkipLocked : 1 ,
390
402
GetExistingForShareSkipLockedGuaranteedDurability : 1 ,
391
- PutMissing : 1 ,
392
- PutExisting : 1 ,
393
- Scan : 1 ,
394
- ScanForUpdate : 1 ,
395
- ScanForUpdateGuaranteedDurability : 1 ,
396
- ScanForShare : 1 ,
397
- ScanForShareGuaranteedDurability : 1 ,
398
- ScanSkipLocked : 1 ,
399
- ScanForUpdateSkipLocked : 1 ,
403
+ PutMissing : 1 ,
404
+ PutExisting : 1 ,
405
+ PutMustAcquireExclusiveLockMissing : 1 ,
406
+ PutMustAcquireExclusiveLockExisting : 1 ,
407
+ Scan : 1 ,
408
+ ScanForUpdate : 1 ,
409
+ ScanForUpdateGuaranteedDurability : 1 ,
410
+ ScanForShare : 1 ,
411
+ ScanForShareGuaranteedDurability : 1 ,
412
+ ScanSkipLocked : 1 ,
413
+ ScanForUpdateSkipLocked : 1 ,
400
414
ScanForUpdateSkipLockedGuaranteedDurability : 1 ,
401
415
ScanForShareSkipLocked : 1 ,
402
416
ScanForShareSkipLockedGuaranteedDurability : 1 ,
@@ -412,6 +426,8 @@ func newAllOperationsConfig() GeneratorConfig {
412
426
ReverseScanForShareSkipLockedGuaranteedDurability : 1 ,
413
427
DeleteMissing : 1 ,
414
428
DeleteExisting : 1 ,
429
+ DeleteMustAcquireExclusiveLockMissing : 1 ,
430
+ DeleteMustAcquireExclusiveLockExisting : 1 ,
415
431
DeleteRange : 1 ,
416
432
DeleteRangeUsingTombstone : 1 ,
417
433
AddSSTable : 1 ,
@@ -777,7 +793,10 @@ func (g *generator) registerClientOps(allowed *[]opGen, c *ClientOperationConfig
777
793
c .GetMissingForShareSkipLockedGuaranteedDurability ,
778
794
)
779
795
addOpGen (allowed , randPutMissing , c .PutMissing )
796
+ addOpGen (allowed , randPutMustAcquireExclusiveLockMissing , c .PutMustAcquireExclusiveLockMissing )
780
797
addOpGen (allowed , randDelMissing , c .DeleteMissing )
798
+ addOpGen (allowed , randDelMustAcquireExclusiveLockMissing , c .DeleteMustAcquireExclusiveLockMissing )
799
+
781
800
if len (g .keys ) > 0 {
782
801
addOpGen (allowed , randGetExisting , c .GetExisting )
783
802
addOpGen (allowed , randGetExistingForUpdate , c .GetExistingForUpdate )
@@ -806,7 +825,9 @@ func (g *generator) registerClientOps(allowed *[]opGen, c *ClientOperationConfig
806
825
c .GetExistingForShareSkipLockedGuaranteedDurability ,
807
826
)
808
827
addOpGen (allowed , randPutExisting , c .PutExisting )
828
+ addOpGen (allowed , randPutMustAcquireExclusiveLockExisting , c .PutMustAcquireExclusiveLockExisting )
809
829
addOpGen (allowed , randDelExisting , c .DeleteExisting )
830
+ addOpGen (allowed , randDelMustAcquireExclusiveLockExisting , c .DeleteMustAcquireExclusiveLockExisting )
810
831
}
811
832
addOpGen (allowed , randScan , c .Scan )
812
833
addOpGen (allowed , randScanForUpdate , c .ScanForUpdate )
@@ -1001,6 +1022,19 @@ func randPutExisting(g *generator, rng *rand.Rand) Operation {
1001
1022
return put (key , seq )
1002
1023
}
1003
1024
1025
+ func randPutMustAcquireExclusiveLockMissing (g * generator , rng * rand.Rand ) Operation {
1026
+ seq := g .nextSeq ()
1027
+ key := randKey (rng )
1028
+ g .keys [key ] = struct {}{}
1029
+ return putMustAcquireLock (key , seq )
1030
+ }
1031
+
1032
+ func randPutMustAcquireExclusiveLockExisting (g * generator , rng * rand.Rand ) Operation {
1033
+ seq := g .nextSeq ()
1034
+ key := randMapKey (rng , g .keys )
1035
+ return putMustAcquireLock (key , seq )
1036
+ }
1037
+
1004
1038
func randAddSSTable (g * generator , rng * rand.Rand ) Operation {
1005
1039
ctx := context .Background ()
1006
1040
@@ -1315,6 +1349,19 @@ func randDelExisting(g *generator, rng *rand.Rand) Operation {
1315
1349
return del (key , seq )
1316
1350
}
1317
1351
1352
+ func randDelMustAcquireExclusiveLockExisting (g * generator , rng * rand.Rand ) Operation {
1353
+ key := randMapKey (rng , g .keys )
1354
+ seq := g .nextSeq ()
1355
+ return delMustAcquireLock (key , seq )
1356
+ }
1357
+
1358
+ func randDelMustAcquireExclusiveLockMissing (g * generator , rng * rand.Rand ) Operation {
1359
+ key := randKey (rng )
1360
+ g .keys [key ] = struct {}{}
1361
+ seq := g .nextSeq ()
1362
+ return delMustAcquireLock (key , seq )
1363
+ }
1364
+
1318
1365
func randDelRange (g * generator , rng * rand.Rand ) Operation {
1319
1366
// We don't write any new keys to `g.keys` on a DeleteRange operation,
1320
1367
// because DelRange(..) only deletes existing keys.
@@ -1906,7 +1953,16 @@ func getForShareSkipLockedGuaranteedDurability(key string) Operation {
1906
1953
}
1907
1954
1908
1955
func put (key string , seq kvnemesisutil.Seq ) Operation {
1909
- return Operation {Put : & PutOperation {Key : []byte (key ), Seq : seq }}
1956
+ return Operation {Put : & PutOperation {
1957
+ Key : []byte (key ),
1958
+ Seq : seq }}
1959
+ }
1960
+
1961
+ func putMustAcquireLock (key string , seq kvnemesisutil.Seq ) Operation {
1962
+ return Operation {Put : & PutOperation {
1963
+ Key : []byte (key ),
1964
+ MustAcquireExclusiveLock : true ,
1965
+ Seq : seq }}
1910
1966
}
1911
1967
1912
1968
func scan (key , endKey string ) Operation {
@@ -1996,6 +2052,14 @@ func del(key string, seq kvnemesisutil.Seq) Operation {
1996
2052
}}
1997
2053
}
1998
2054
2055
+ func delMustAcquireLock (key string , seq kvnemesisutil.Seq ) Operation {
2056
+ return Operation {Delete : & DeleteOperation {
2057
+ Key : []byte (key ),
2058
+ Seq : seq ,
2059
+ MustAcquireExclusiveLock : true ,
2060
+ }}
2061
+ }
2062
+
1999
2063
func delRange (key , endKey string , seq kvnemesisutil.Seq ) Operation {
2000
2064
return Operation {DeleteRange : & DeleteRangeOperation {Key : []byte (key ), EndKey : []byte (endKey ), Seq : seq }}
2001
2065
}
0 commit comments