-
Notifications
You must be signed in to change notification settings - Fork 3.8k
/
Copy pathcmd_barrier.go
47 lines (40 loc) · 1.44 KB
/
cmd_barrier.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright 2021 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0, included in the file
// licenses/APL.txt.
package batcheval
import (
"context"
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/batcheval/result"
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/spanset"
"github.com/cockroachdb/cockroach/pkg/roachpb"
"github.com/cockroachdb/cockroach/pkg/storage"
)
func init() {
RegisterReadWriteCommand(roachpb.Barrier, declareKeysBarrier, Barrier)
}
func declareKeysBarrier(
rs ImmutableRangeState,
h roachpb.Header,
req roachpb.Request,
latchSpans, lockSpans *spanset.SpanSet,
) {
// Barrier is special-cased in the concurrency manager to *not* actually
// grab these latches. Instead, any conflicting latches with these are waited
// on, but new latches aren't inserted.
latchSpans.AddNonMVCC(spanset.SpanReadWrite, req.Header().Span())
}
// Barrier evaluation is a no-op, as all the latch waiting happens in
// the latch manager.
func Barrier(
_ context.Context, _ storage.ReadWriter, cArgs CommandArgs, response roachpb.Response,
) (result.Result, error) {
resp := response.(*roachpb.BarrierResponse)
resp.Timestamp = cArgs.EvalCtx.Clock().Now()
return result.Result{}, nil
}