|
| 1 | +new-lock-table maxlocks=10000 |
| 2 | +---- |
| 3 | + |
| 4 | +new-txn txn=txn1 ts=10 epoch=0 seq=0 |
| 5 | +---- |
| 6 | + |
| 7 | +new-txn txn=txn2 ts=10 epoch=0 seq=0 |
| 8 | +---- |
| 9 | + |
| 10 | +new-request r=req1 txn=txn1 ts=10 spans=shared@a |
| 11 | +---- |
| 12 | + |
| 13 | +acquire r=req1 k=a durability=u strength=shared |
| 14 | +---- |
| 15 | +num=1 |
| 16 | + lock: "a" |
| 17 | + holder: txn: 00000000-0000-0000-0000-000000000001 epoch: 0, iso: Serializable, ts: 10.000000000,0, info: unrepl [(str: Shared seq: 0)] |
| 18 | + |
| 19 | +# ------------------------------------------------------------------------------ |
| 20 | +# Ensure conflict resolution semantics for shared locks are sane -- that is, |
| 21 | +# if a shared lock is held on a key, {shared, non} locking requests are allowed |
| 22 | +# to proceed; {intent, exclusive} locking requests are not. |
| 23 | +# ------------------------------------------------------------------------------ |
| 24 | + |
| 25 | +new-request r=req2 txn=txn2 ts=10 spans=none@a |
| 26 | +---- |
| 27 | + |
| 28 | +scan r=req2 |
| 29 | +---- |
| 30 | +start-waiting: false |
| 31 | + |
| 32 | +new-request r=req3 txn=txn2 ts=10 spans=shared@a |
| 33 | +---- |
| 34 | + |
| 35 | +# req3 should not actively wait, as it's locking strength is shared, but it |
| 36 | +# should be able to acquire a joint claim. |
| 37 | +scan r=req3 |
| 38 | +---- |
| 39 | +start-waiting: false |
| 40 | + |
| 41 | +print |
| 42 | +---- |
| 43 | +num=1 |
| 44 | + lock: "a" |
| 45 | + holder: txn: 00000000-0000-0000-0000-000000000001 epoch: 0, iso: Serializable, ts: 10.000000000,0, info: unrepl [(str: Shared seq: 0)] |
| 46 | + queued writers: |
| 47 | + active: false req: 2, txn: 00000000-0000-0000-0000-000000000002 |
| 48 | + |
| 49 | +# TODO(arul): This is currently a limitation of the lock table, as it doesn't |
| 50 | +# allow multiple locks on a single key from different transactions. |
| 51 | +acquire r=req3 k=a durability=u strength=shared |
| 52 | +---- |
| 53 | +existing lock cannot be acquired by different transaction |
| 54 | + |
| 55 | +new-request r=req4 txn=txn2 ts=10 spans=exclusive@a |
| 56 | +---- |
| 57 | + |
| 58 | +scan r=req4 |
| 59 | +---- |
| 60 | +start-waiting: true |
| 61 | + |
| 62 | +new-request r=req5 txn=txn2 ts=10 spans=intent@a |
| 63 | +---- |
| 64 | + |
| 65 | +scan r=req5 |
| 66 | +---- |
| 67 | +start-waiting: true |
| 68 | + |
| 69 | +print |
| 70 | +---- |
| 71 | +num=1 |
| 72 | + lock: "a" |
| 73 | + holder: txn: 00000000-0000-0000-0000-000000000001 epoch: 0, iso: Serializable, ts: 10.000000000,0, info: unrepl [(str: Shared seq: 0)] |
| 74 | + queued writers: |
| 75 | + active: false req: 2, txn: 00000000-0000-0000-0000-000000000002 |
| 76 | + active: true req: 3, txn: 00000000-0000-0000-0000-000000000002 |
| 77 | + active: true req: 4, txn: 00000000-0000-0000-0000-000000000002 |
| 78 | + distinguished req: 3 |
| 79 | + |
| 80 | +# ------------------------------------------------------------------------------ |
| 81 | +# Ensure requests with locking strength shared actively wait if there are active |
| 82 | +# waiters with conflicting lock strengths (even though the lock itself is |
| 83 | +# compatible with the shared lock request). |
| 84 | +# ------------------------------------------------------------------------------ |
| 85 | + |
| 86 | +new-request r=req6 txn=txn2 ts=10 spans=shared@a |
| 87 | +---- |
| 88 | + |
| 89 | +scan r=req6 |
| 90 | +---- |
| 91 | +start-waiting: true |
| 92 | + |
| 93 | +print |
| 94 | +---- |
| 95 | +num=1 |
| 96 | + lock: "a" |
| 97 | + holder: txn: 00000000-0000-0000-0000-000000000001 epoch: 0, iso: Serializable, ts: 10.000000000,0, info: unrepl [(str: Shared seq: 0)] |
| 98 | + queued writers: |
| 99 | + active: false req: 2, txn: 00000000-0000-0000-0000-000000000002 |
| 100 | + active: true req: 3, txn: 00000000-0000-0000-0000-000000000002 |
| 101 | + active: true req: 4, txn: 00000000-0000-0000-0000-000000000002 |
| 102 | + active: true req: 5, txn: 00000000-0000-0000-0000-000000000002 |
| 103 | + distinguished req: 3 |
0 commit comments