Skip to content

Commit

Permalink
storage/concurrency: use shortened UUID strings in ConcurrencyManager…
Browse files Browse the repository at this point in the history
… tests

Leaving this as a TODO for the LockTable tests.
  • Loading branch information
nvanbenschoten committed Mar 3, 2020
1 parent cf8cd92 commit a569548
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
7 changes: 3 additions & 4 deletions pkg/storage/concurrency/concurrency_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import (
"github.com/cockroachdb/cockroach/pkg/util/log"
"github.com/cockroachdb/cockroach/pkg/util/syncutil"
"github.com/cockroachdb/cockroach/pkg/util/tracing"
"github.com/cockroachdb/cockroach/pkg/util/uint128"
"github.com/cockroachdb/cockroach/pkg/util/uuid"
"github.com/cockroachdb/datadriven"
"github.com/cockroachdb/errors"
Expand Down Expand Up @@ -333,7 +332,7 @@ type cluster struct {
m concurrency.Manager

// Definitions.
txnCounter uint128.Uint128
txnCounter uint32
txnsByName map[string]*roachpb.Transaction
requestsByName map[string]concurrency.Request

Expand Down Expand Up @@ -380,7 +379,7 @@ func (c *cluster) makeConfig() concurrency.Config {
func (c *cluster) PushTransaction(
ctx context.Context, pushee *enginepb.TxnMeta, h roachpb.Header, pushType roachpb.PushTxnType,
) (roachpb.Transaction, *roachpb.Error) {
log.Eventf(ctx, "pushing txn %s", pushee.ID)
log.Eventf(ctx, "pushing txn %s", pushee.ID.Short())
pusheeRecord, err := c.getTxnRecord(pushee.ID)
if err != nil {
return roachpb.Transaction{}, roachpb.NewError(err)
Expand Down Expand Up @@ -410,7 +409,7 @@ func (c *cluster) PushTransaction(
func (c *cluster) ResolveIntent(
ctx context.Context, intent roachpb.LockUpdate, _ intentresolver.ResolveOptions,
) *roachpb.Error {
log.Eventf(ctx, "resolving intent %s for txn %s with %s status", intent.Key, intent.Txn.ID, intent.Status)
log.Eventf(ctx, "resolving intent %s for txn %s with %s status", intent.Key, intent.Txn.ID.Short(), intent.Status)
c.m.OnLockUpdated(ctx, &intent)
return nil
}
Expand Down
7 changes: 4 additions & 3 deletions pkg/storage/concurrency/datadriven_util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ import (
"github.com/cockroachdb/datadriven"
)

func nextUUID(counter *uint128.Uint128) uuid.UUID {
*counter = counter.Add(1)
return uuid.FromUint128(*counter)
func nextUUID(counter *uint32) uuid.UUID {
*counter = *counter + 1
hi := uint64(*counter) << 32
return uuid.FromUint128(uint128.Uint128{Hi: hi})
}

func scanTimestamp(t *testing.T, d *datadriven.TestData) hlc.Timestamp {
Expand Down
16 changes: 8 additions & 8 deletions pkg/storage/concurrency/testdata/concurrency_manager/basic
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ debug-lock-table
----
global: num=1
lock: "k"
holder: txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000012,1
holder: txn: 00000002-0000-0000-0000-000000000000, ts: 0.000000012,1
local: num=0

finish req=req2
Expand All @@ -69,7 +69,7 @@ debug-lock-table
----
global: num=1
lock: "k"
holder: txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000012,1
holder: txn: 00000002-0000-0000-0000-000000000000, ts: 0.000000012,1
local: num=0

reset
Expand Down Expand Up @@ -105,13 +105,13 @@ sequence req=req3
[1] sequence req3: acquiring latches
[1] sequence req3: scanning lock table for conflicting locks
[1] sequence req3: waiting in lock wait-queues
[1] sequence req3: pushing txn 00000000-0000-0000-0000-000000000002
[1] sequence req3: pushing txn 00000002
[1] sequence req3: blocked on sync.Cond.Wait in concurrency_test.(*cluster).PushTransaction

on-txn-updated txn=txn2 status=committed
----
[-] update txn: committing txn2
[1] sequence req3: resolving intent "k" for txn 00000000-0000-0000-0000-000000000002 with COMMITTED status
[1] sequence req3: resolving intent "k" for txn 00000002 with COMMITTED status
[1] sequence req3: acquiring latches
[1] sequence req3: scanning lock table for conflicting locks
[1] sequence req3: sequencing complete, returned guard
Expand Down Expand Up @@ -174,7 +174,7 @@ sequence req=req5
[1] sequence req5: acquiring latches
[1] sequence req5: scanning lock table for conflicting locks
[1] sequence req5: waiting in lock wait-queues
[1] sequence req5: pushing txn 00000000-0000-0000-0000-000000000002
[1] sequence req5: pushing txn 00000002
[1] sequence req5: blocked on sync.Cond.Wait in concurrency_test.(*cluster).PushTransaction

new-request name=req6 txn=none ts=16,1
Expand All @@ -192,7 +192,7 @@ sequence req=req6
on-txn-updated txn=txn2 status=pending ts=18,1
----
[-] update txn: increasing timestamp of txn2
[1] sequence req5: resolving intent "k" for txn 00000000-0000-0000-0000-000000000002 with PENDING status
[1] sequence req5: resolving intent "k" for txn 00000002 with PENDING status
[1] sequence req5: acquiring latches
[1] sequence req5: scanning lock table for conflicting locks
[1] sequence req5: sequencing complete, returned guard
Expand All @@ -219,13 +219,13 @@ finish req=req6
[-] finish req6: finishing request
[3] sequence req7: scanning lock table for conflicting locks
[3] sequence req7: waiting in lock wait-queues
[3] sequence req7: pushing txn 00000000-0000-0000-0000-000000000002
[3] sequence req7: pushing txn 00000002
[3] sequence req7: blocked on sync.Cond.Wait in concurrency_test.(*cluster).PushTransaction

on-txn-updated txn=txn2 status=committed
----
[-] update txn: committing txn2
[3] sequence req7: resolving intent "k" for txn 00000000-0000-0000-0000-000000000002 with COMMITTED status
[3] sequence req7: resolving intent "k" for txn 00000002 with COMMITTED status
[3] sequence req7: acquiring latches
[3] sequence req7: scanning lock table for conflicting locks
[3] sequence req7: sequencing complete, returned guard
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ debug-lock-table
----
global: num=1
lock: "k"
holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,1
holder: txn: 00000001-0000-0000-0000-000000000000, ts: 0.000000010,1
local: num=0

sequence req=req1
Expand All @@ -37,13 +37,13 @@ sequence req=req1
[2] sequence req1: acquiring latches
[2] sequence req1: scanning lock table for conflicting locks
[2] sequence req1: waiting in lock wait-queues
[2] sequence req1: pushing txn 00000000-0000-0000-0000-000000000001
[2] sequence req1: pushing txn 00000001
[2] sequence req1: blocked on sync.Cond.Wait in concurrency_test.(*cluster).PushTransaction

on-txn-updated txn=txn1 status=aborted
----
[-] update txn: aborting txn1
[2] sequence req1: resolving intent "k" for txn 00000000-0000-0000-0000-000000000001 with ABORTED status
[2] sequence req1: resolving intent "k" for txn 00000001 with ABORTED status
[2] sequence req1: acquiring latches
[2] sequence req1: scanning lock table for conflicting locks
[2] sequence req1: sequencing complete, returned guard
Expand Down

0 comments on commit a569548

Please sign in to comment.