-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50119 from nvanbenschoten/backport20.1-49980
release-20.1: kv/concurrency: drop uncontended replicated lock on unreplicated upgrade
- Loading branch information
Showing
5 changed files
with
293 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
129 changes: 129 additions & 0 deletions
129
pkg/kv/kvserver/concurrency/testdata/lock_table/lock_dropped
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
# Misc tests where locks are ignored or dropped during lock acquisitions. | ||
|
||
new-lock-table maxlocks=10000 | ||
---- | ||
|
||
# --------------------------------------------------------------------------------- | ||
# New replicated locks are ignored. | ||
# --------------------------------------------------------------------------------- | ||
|
||
new-txn txn=txn1 ts=10 epoch=0 seq=2 | ||
---- | ||
|
||
new-request r=req1 txn=txn1 ts=10 spans=w@a | ||
---- | ||
|
||
acquire r=req1 k=a durability=r | ||
---- | ||
global: num=0 | ||
local: num=0 | ||
|
||
# --------------------------------------------------------------------------------- | ||
# Upgrading from unreplicated to replicated for an uncontended lock causes that | ||
# lock to be dropped. | ||
# --------------------------------------------------------------------------------- | ||
|
||
acquire r=req1 k=a durability=u | ||
---- | ||
global: num=1 | ||
lock: "a" | ||
holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,0, info: unrepl epoch: 0, seqs: [2] | ||
local: num=0 | ||
|
||
acquire r=req1 k=a durability=r | ||
---- | ||
global: num=0 | ||
local: num=0 | ||
|
||
# --------------------------------------------------------------------------------- | ||
# Upgrading from unreplicated to replicated for a lock with only waiting readers | ||
# causes that lock to be dropped and the readers to be released. | ||
# --------------------------------------------------------------------------------- | ||
|
||
new-request r=reqContendReader txn=none ts=10 spans=r@a | ||
---- | ||
|
||
acquire r=req1 k=a durability=u | ||
---- | ||
global: num=1 | ||
lock: "a" | ||
holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,0, info: unrepl epoch: 0, seqs: [2] | ||
local: num=0 | ||
|
||
scan r=reqContendReader | ||
---- | ||
start-waiting: true | ||
|
||
---- | ||
global: num=1 | ||
lock: "a" | ||
holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,0, info: unrepl epoch: 0, seqs: [2] | ||
waiting readers: | ||
req: 1, txn: none | ||
distinguished req: 1 | ||
local: num=0 | ||
|
||
acquire r=req1 k=a durability=r | ||
---- | ||
global: num=0 | ||
local: num=0 | ||
|
||
guard-state r=reqContendReader | ||
---- | ||
new: state=doneWaiting | ||
|
||
# --------------------------------------------------------------------------------- | ||
# Upgrading from unreplicated to replicated for a lock with waiting reader and | ||
# writers causes the lock to be retained. | ||
# --------------------------------------------------------------------------------- | ||
|
||
new-request r=reqContendWriter txn=none ts=10 spans=w@a | ||
---- | ||
|
||
acquire r=req1 k=a durability=u | ||
---- | ||
global: num=1 | ||
lock: "a" | ||
holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,0, info: unrepl epoch: 0, seqs: [2] | ||
local: num=0 | ||
|
||
scan r=reqContendReader | ||
---- | ||
start-waiting: true | ||
|
||
scan r=reqContendWriter | ||
---- | ||
start-waiting: true | ||
|
||
---- | ||
global: num=1 | ||
lock: "a" | ||
holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,0, info: unrepl epoch: 0, seqs: [2] | ||
waiting readers: | ||
req: 1, txn: none | ||
queued writers: | ||
active: true req: 2, txn: none | ||
distinguished req: 1 | ||
local: num=0 | ||
|
||
acquire r=req1 k=a durability=r | ||
---- | ||
global: num=1 | ||
lock: "a" | ||
holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,0, info: repl epoch: 0, seqs: [2], unrepl epoch: 0, seqs: [2] | ||
waiting readers: | ||
req: 1, txn: none | ||
queued writers: | ||
active: true req: 2, txn: none | ||
distinguished req: 1 | ||
local: num=0 | ||
|
||
guard-state r=reqContendReader | ||
---- | ||
new: state=waitForDistinguished txn=txn1 ts=10 key="a" held=true guard-access=read | ||
|
||
guard-state r=reqContendWriter | ||
---- | ||
new: state=waitFor txn=txn1 ts=10 key="a" held=true guard-access=write |
Oops, something went wrong.