Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hlc: improve/fix the representation of timestamps #43185

Merged
merged 1 commit into from
Dec 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions pkg/ccl/changefeedccl/sink_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,18 +274,18 @@ func TestSQLSink(t *testing.T) {
sqlDB.CheckQueryResults(t,
`SELECT topic, partition, key, value, resolved FROM sink ORDER BY PRIMARY KEY sink`,
[][]string{
{`bar`, `0`, ``, ``, `0.000000000,0`},
{`bar`, `0`, ``, ``, `0,0`},
{`bar`, `0`, ``, ``, `0.000000001,0`},
{`bar`, `1`, ``, ``, `0.000000000,0`},
{`bar`, `1`, ``, ``, `0,0`},
{`bar`, `1`, ``, ``, `0.000000001,0`},
{`bar`, `2`, ``, ``, `0.000000000,0`},
{`bar`, `2`, ``, ``, `0,0`},
{`bar`, `2`, ``, ``, `0.000000001,0`},
{`foo`, `0`, ``, ``, `0.000000000,0`},
{`foo`, `0`, ``, ``, `0,0`},
{`foo`, `0`, `foo0`, `v0`, ``},
{`foo`, `0`, ``, ``, `0.000000001,0`},
{`foo`, `1`, ``, ``, `0.000000000,0`},
{`foo`, `1`, ``, ``, `0,0`},
{`foo`, `1`, ``, ``, `0.000000001,0`},
{`foo`, `2`, ``, ``, `0.000000000,0`},
{`foo`, `2`, ``, ``, `0,0`},
{`foo`, `2`, ``, ``, `0.000000001,0`},
},
)
Expand Down
8 changes: 4 additions & 4 deletions pkg/storage/batcheval/cmd_lease_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ func TestLeaseCommandLearnerReplica(t *testing.T) {
cArgs.Args = &roachpb.RequestLeaseRequest{}
_, err = RequestLease(ctx, nil, cArgs, nil)

const expForUnknown = `cannot replace lease repl=(n0,s0):? seq=0 start=0.000000000,0 exp=<nil> ` +
`with repl=(n0,s0):? seq=0 start=0.000000000,0 exp=<nil>: ` +
const expForUnknown = `cannot replace lease repl=(n0,s0):? seq=0 start=0,0 exp=<nil> ` +
`with repl=(n0,s0):? seq=0 start=0,0 exp=<nil>: ` +
`replica (n0,s0):? not found in r0:{-} [(n1,s1):1, (n2,s2):2LEARNER, next=0, gen=0?]`
require.EqualError(t, err, expForUnknown)

Expand All @@ -150,8 +150,8 @@ func TestLeaseCommandLearnerReplica(t *testing.T) {
}
_, err = RequestLease(ctx, nil, cArgs, nil)

const expForLearner = `cannot replace lease repl=(n0,s0):? seq=0 start=0.000000000,0 exp=<nil> ` +
`with repl=(n2,s2):2LEARNER seq=0 start=0.000000000,0 exp=<nil>: ` +
const expForLearner = `cannot replace lease repl=(n0,s0):? seq=0 start=0,0 exp=<nil> ` +
`with repl=(n2,s2):2LEARNER seq=0 start=0,0 exp=<nil>: ` +
`replica (n2,s2):2LEARNER of type LEARNER cannot hold lease`
require.EqualError(t, err, expForLearner)
}
34 changes: 17 additions & 17 deletions pkg/storage/closedts/minprop/doc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,19 @@ func Example() {
// Output:
// The newly initialized tracker has a zero closed timestamp:
//
// closed=0.000000000,0
// | next=0.000000000,1
// closed=0,0
// | next=0,1
// | left | right
// | 0 # 0
// | 1 e 1
// v v
// ---------------------------------------------------------> time
//
// A first command arrives on range 12 (though the range isn't known yet to the Tracker).
// All commands initially start out on the right. The command has its timestamp forwarded to 0.000000000,2 .
// All commands initially start out on the right. The command has its timestamp forwarded to 0,2 .
//
// closed=0.000000000,0
// | next=0.000000000,1
// closed=0,0
// | next=0,1
// | left | right
// | 0 # 1
// | 1 e 1
Expand All @@ -100,8 +100,8 @@ func Example() {
//
// Two more commands arrive, on r1 and r12.
//
// closed=0.000000000,0
// | next=0.000000000,1
// closed=0,0
// | next=0,1
// | left | right
// | 0 # 3
// | 1 e 1
Expand All @@ -110,8 +110,8 @@ func Example() {
//
// The command on r1 finishes evaluating at Lease Applied Index 10 and lets the Tracker know.
//
// closed=0.000000000,0
// | next=0.000000000,1
// closed=0,0
// | next=0,1
// | left | right
// | 0 # 2
// | 1 e 1
Expand All @@ -121,8 +121,8 @@ func Example() {
//
// The command on r12 also finishes quickly, at LAI 77.
//
// closed=0.000000000,0
// | next=0.000000000,1
// closed=0,0
// | next=0,1
// | left | right
// | 0 # 1
// | 1 e 1
Expand All @@ -132,11 +132,11 @@ func Example() {
// ---------------------------------------------------------> time
//
// The system closes out a timestamp (registering 1000 as the next timestamp to close out).
// No problem: nothing is tracked on the left side; returns: 0.000000000,1 and map[]
// No problem: nothing is tracked on the left side; returns: 0,1 and map[]
// Note how the items on the right have moved to the left, as they are relevant for the
// next call to Close.
//
// closed=0.000000000,1
// closed=0,1
// | next=1.000000000,0
// | left | right
// | 1 # 0
Expand All @@ -148,9 +148,9 @@ func Example() {
//
// Nothing happens for a while until the system tries to close out the next timestamp.
// However, the very first proposal is still tracked and blocks progress.
// The call returns a no-op in the form 0.000000000,1 map[] .
// The call returns a no-op in the form 0,1 map[] .
//
// closed=0.000000000,1
// closed=0,1
// | next=1.000000000,0
// | left | right
// | 1 # 0
Expand All @@ -163,7 +163,7 @@ func Example() {
// A new command gets tracked on r12 (and is forwarded to 1.000000000,1 (if necessary).
// It terminates quickly, leaving an MLAI entry of 78 behind.
//
// closed=0.000000000,1
// closed=0,1
// | next=1.000000000,0
// | left | right
// | 1 # 0
Expand All @@ -178,7 +178,7 @@ func Example() {
// Note that the right now tracks a smaller value of 78. Consumers have to keep the
// maximum they've seen.
//
// closed=0.000000000,1
// closed=0,1
// | next=1.000000000,0
// | left | right
// | 0 # 0
Expand Down
24 changes: 12 additions & 12 deletions pkg/storage/closedts/minprop/tracker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,20 +386,20 @@ func ExampleTracker_Close_epochChange() {
// Output:
// The newly initialized tracker has a zero closed timestamp:
//
// closed=0.000000000,0
// | next=0.000000000,1
// closed=0,0
// | next=0,1
// | left | right
// | 0 # 0
// | 1 e 1
// v v
// ---------------------------------------------------------> time
//
// A first command arrives on range 1 (though the range isn't known yet to the Tracker).
// All commands initially start out on the right. The command has its timestamp forwarded to 0.000000000,2 .
// All commands initially start out on the right. The command has its timestamp forwarded to 0,2 .
// The command finished quickly and is released in epoch 1.
//
// closed=0.000000000,0
// | next=0.000000000,1
// closed=0,0
// | next=0,1
// | left | right
// | 0 # 0
// | 1 e 1
Expand All @@ -409,8 +409,8 @@ func ExampleTracker_Close_epochChange() {
//
// Another proposal arrives on range 2 but does not complete before the next call to Close().
//
// closed=0.000000000,0
// | next=0.000000000,1
// closed=0,0
// | next=0,1
// | left | right
// | 0 # 1
// | 1 e 1
Expand All @@ -419,10 +419,10 @@ func ExampleTracker_Close_epochChange() {
// ---------------------------------------------------------> time
//
// The system closes out a timestamp expecting liveness epoch 2 (registering 1.000000000,0 as the next timestamp to close out).
// The Close() call fails due to the liveness epoch mismatch between the expected current epoch and the tracked data, returning 0.000000000,0 map[] false
// The Close() call fails due to the liveness epoch mismatch between the expected current epoch and the tracked data, returning 0,0 map[] false
// The Close() call evicts the tracked range 1 LAI.
//
// closed=0.000000000,1
// closed=0,1
// | next=1.000000000,0
// | left | right
// | 1 # 0
Expand All @@ -432,7 +432,7 @@ func ExampleTracker_Close_epochChange() {
//
// The proposal on range 2 is released in epoch 2.
//
// closed=0.000000000,1
// closed=0,1
// | next=1.000000000,0
// | left | right
// | 0 # 0
Expand All @@ -444,7 +444,7 @@ func ExampleTracker_Close_epochChange() {
// Another proposal arrives on range 1 and quickly finishes with LAI 2 but is still in epoch 1 and is not tracked.
// Meanwhile a proposal arrives on range 2 and quickly finishes with LAI 2 in epoch 2.
//
// closed=0.000000000,1
// closed=0,1
// | next=1.000000000,0
// | left | right
// | 0 # 0
Expand All @@ -457,7 +457,7 @@ func ExampleTracker_Close_epochChange() {
// A new proposal arrives on range 1 and quickly finishes with LAI 2 in epoch 3.
// This new epoch evicts the data on the right side corresponding to epoch 2.
//
// closed=0.000000000,1
// closed=0,1
// | next=1.000000000,0
// | left | right
// | 0 # 0
Expand Down
32 changes: 15 additions & 17 deletions pkg/storage/closedts/storage/storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,8 @@ func ExampleSingleStorage() {
// Output:
// The empty storage renders as below:
// +--+---------------------+----------------------+----------------------+----------------------+
// 0.000000000,0 0.000000000,0 0.000000000,0 0.000000000,0
// age=0s (target ≤0s) age=0s (target ≤10s) age=0s (target ≤20s) age=0s (target ≤40s)
// epoch=0 epoch=0 epoch=0 epoch=0
// 0,0 age=0s (target 0,0 age=0s (target 0,0 age=0s (target 0,0 age=0s (target
// ≤0s) epoch=0 ≤10s) epoch=0 ≤20s) epoch=0 ≤40s) epoch=0
// +--+---------------------+----------------------+----------------------+----------------------+
// +--+---------------------+----------------------+----------------------+----------------------+
//
Expand All @@ -139,8 +138,8 @@ func ExampleSingleStorage() {
//
// the result is:
// +----+---------------------+------------------------+------------------------+------------------------+
// 123.000000000,0 0.000000000,0 age=2m3s 0.000000000,0 age=2m3s 0.000000000,0 age=2m3s
// age=0s (target ≤0s) (target ≤10s) epoch=0 (target ≤20s) epoch=0 (target ≤40s) epoch=0
// 123.000000000,0 0,0 age=2m3s (target 0,0 age=2m3s (target 0,0 age=2m3s (target
// age=0s (target ≤0s) ≤10s) epoch=0 ≤20s) epoch=0 ≤40s) epoch=0
// epoch=0
// +----+---------------------+------------------------+------------------------+------------------------+
// r1 1000
Expand All @@ -158,8 +157,8 @@ func ExampleSingleStorage() {
// The remaining buckets are unchanged. The best we could do is
// give them identical copies of the second, but that's nonsense.
// +----+---------------------+----------------------+------------------------+------------------------+
// 125.000000000,0 123.000000000,0 0.000000000,0 age=2m5s 0.000000000,0 age=2m5s
// age=0s (target ≤0s) age=2s (target ≤10s) (target ≤20s) epoch=0 (target ≤40s) epoch=0
// 125.000000000,0 123.000000000,0 0,0 age=2m5s (target 0,0 age=2m5s (target
// age=0s (target ≤0s) age=2s (target ≤10s) ≤20s) epoch=0 ≤40s) epoch=0
// epoch=0 epoch=0
// +----+---------------------+----------------------+------------------------+------------------------+
// r1 1001 1000
Expand All @@ -176,8 +175,8 @@ func ExampleSingleStorage() {
// older than 10s. Note also how the first bucket ignores the
// downgrade for r1; these can occur in practice.
// +----+---------------------+-----------------------+-------------------------+-------------------------+
// 133.000000000,0 123.000000000,0 0.000000000,0 age=2m13s 0.000000000,0 age=2m13s
// age=0s (target ≤0s) age=10s (target ≤10s) (target ≤20s) epoch=0 (target ≤40s) epoch=0
// 133.000000000,0 123.000000000,0 0,0 age=2m13s (target 0,0 age=2m13s (target
// age=0s (target ≤0s) age=10s (target ≤10s) ≤20s) epoch=0 ≤40s) epoch=0
// epoch=0 epoch=0
// +----+---------------------+-----------------------+-------------------------+-------------------------+
// r1 1001 1000
Expand All @@ -192,8 +191,8 @@ func ExampleSingleStorage() {
//
// Consequently we now see the third bucket fill up.
// +----+---------------------+-------------------------+-------------------------+---------------------------+
// 133.500000000,0 133.000000000,0 123.000000000,0 0.000000000,0 age=2m13.5s
// age=0s (target ≤0s) age=500ms (target ≤10s) age=10.5s (target ≤20s) (target ≤40s) epoch=0
// 133.500000000,0 133.000000000,0 123.000000000,0 0,0 age=2m13.5s (target
// age=0s (target ≤0s) age=500ms (target ≤10s) age=10.5s (target ≤20s) ≤40s) epoch=0
// epoch=0 epoch=0 epoch=0
// +----+---------------------+-------------------------+-------------------------+---------------------------+
// r1 1001 1001 1000
Expand Down Expand Up @@ -244,9 +243,8 @@ func ExampleSingleStorage() {
//
// Finally, when the storage is cleared, all buckets are reset.
// +--+---------------------+----------------------+----------------------+----------------------+
// 0.000000000,0 0.000000000,0 0.000000000,0 0.000000000,0
// age=0s (target ≤0s) age=0s (target ≤10s) age=0s (target ≤20s) age=0s (target ≤40s)
// epoch=0 epoch=0 epoch=0 epoch=0
// 0,0 age=0s (target 0,0 age=0s (target 0,0 age=0s (target 0,0 age=0s (target
// ≤0s) epoch=0 ≤10s) epoch=0 ≤20s) epoch=0 ≤40s) epoch=0
// +--+---------------------+----------------------+----------------------+----------------------+
// +--+---------------------+----------------------+----------------------+----------------------+
}
Expand Down Expand Up @@ -303,9 +301,9 @@ func ExampleMultiStorage_epoch() {
//
// ***** n1 *****
// +----+---------------------+----------------------+
// 1.000000000,0 0.000000000,0
// age=0s (target ≤0s) age=1s (target ≤1ms)
// epoch=10 epoch=0
// 1.000000000,0 0,0 age=1s (target
// age=0s (target ≤0s) ≤1ms) epoch=0
// epoch=10
// +----+---------------------+----------------------+
// r9 17
// +----+---------------------+----------------------+
Expand Down
8 changes: 4 additions & 4 deletions pkg/storage/engine/enginepb/mvcc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ func TestFormatMVCCMetadata(t *testing.T) {
},
}

const expStr = `txn={id=d7aa0f5e key="a" pri=0.00000000 epo=1 ts=0.000000000,1 min=0.000000000,1 seq=0}` +
` ts=0.000000000,1 del=false klen=123 vlen=456 rawlen=8 nih=2`
const expStr = `txn={id=d7aa0f5e key="a" pri=0.00000000 epo=1 ts=0,1 min=0,1 seq=0}` +
` ts=0,1 del=false klen=123 vlen=456 rawlen=8 nih=2`

if str := meta.String(); str != expStr {
t.Errorf(
Expand All @@ -61,8 +61,8 @@ func TestFormatMVCCMetadata(t *testing.T) {
expStr, str)
}

const expV = `txn={id=d7aa0f5e key="a" pri=0.00000000 epo=1 ts=0.000000000,1 min=0.000000000,1 seq=0}` +
` ts=0.000000000,1 del=false klen=123 vlen=456 raw=/BYTES/foo ih={{11 /BYTES/bar}{22 /BYTES/baz}}`
const expV = `txn={id=d7aa0f5e key="a" pri=0.00000000 epo=1 ts=0,1 min=0,1 seq=0}` +
` ts=0,1 del=false klen=123 vlen=456 raw=/BYTES/foo ih={{11 /BYTES/bar}{22 /BYTES/baz}}`

if str := fmt.Sprintf("%+v", meta); str != expV {
t.Errorf(
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/engine/testdata/mvcc_histories/clear_range
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ with t=A v=abc resolve
put k=c
----
>> at end:
txn: "A" meta={id=00000000 key=/Min pri=0.00000000 epo=0 ts=0.000000044,0 min=0.000000000,0 seq=0} rw=true stat=PENDING rts=0.000000044,0 wto=false max=0.000000000,0
txn: "A" meta={id=00000000 key=/Min pri=0.00000000 epo=0 ts=0.000000044,0 min=0,0 seq=0} rw=true stat=PENDING rts=0.000000044,0 wto=false max=0,0
data: "a"/0.000000044,0 -> /BYTES/abc
data: "a/123"/0.000000044,0 -> /BYTES/abc
data: "b"/0.000000044,0 -> /BYTES/abc
Expand Down
Loading