forked from cockroachdb/cockroach
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…db#93912 56675: rfc: closed timestamps v2 RFC r=andreimatei a=andreimatei We need a more flexible closed timestamps mechanism because the Non-blocking Transactions project will use two different closed timestamps policies for different ranges. The existing mechanism closes a single timestamps for all the ranges for which a node is the leaseholder, which is not good enough. Besides, the existing mechanism is quite complex. The alternative proposed by this RFC seems significantly simpler. Release note: None Epic: None 93239: kvserver: decouple cmd checks in replicaAppBatch r=pavelkalinnikov a=tbg This refactors the command application pre-flight checks on replicaAppBatch such that they can move to appBatch once that struct evolves from a stub into an actual implementation of `apply.Batch`. Epic: CRDB-220 Release note: None 93910: go.mod: bump Pebble to 6ca7956d84c1 r=nicktrav a=jbowens ``` 6ca7956d db: tweak NextPrefix semantics in prefix-iteration mode 7fced9a5 metamorphic: fix NextPrefix integration 33377d59 metamorphic: fix NextPrefix integration ``` Epic: None Release note: none 93912: scripts: adapt bump-pebble.sh for removal of vendor r=jbowens a=jbowens Remove all references to the vendor directory in the bump-pebble script. Release note: None Epic: None Co-authored-by: Andrei Matei <[email protected]> Co-authored-by: Tobias Grieger <[email protected]> Co-authored-by: Jackson Owens <[email protected]>
- Loading branch information
Showing
14 changed files
with
803 additions
and
100 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1485,10 +1485,10 @@ def go_deps(): | |
patches = [ | ||
"@com_github_cockroachdb_cockroach//build/patches:com_github_cockroachdb_pebble.patch", | ||
], | ||
sha256 = "0401364025128ab1d3d592293d0c3e1109eb6b50f6c30bb948c5743e7200e9e1", | ||
strip_prefix = "github.com/cockroachdb/[email protected]20221212215000-0893071d8a52", | ||
sha256 = "8e17511f72ac42694d17f2fc293a484a6f243d0ea6bb592120ca9424bce3dbfb", | ||
strip_prefix = "github.com/cockroachdb/[email protected]20221219140626-6ca7956d84c1", | ||
urls = [ | ||
"https://storage.googleapis.com/cockroach-godeps/gomod/github.com/cockroachdb/pebble/com_github_cockroachdb_pebble-v0.0.0-20221212215000-0893071d8a52.zip", | ||
"https://storage.googleapis.com/cockroach-godeps/gomod/github.com/cockroachdb/pebble/com_github_cockroachdb_pebble-v0.0.0-20221219140626-6ca7956d84c1.zip", | ||
], | ||
) | ||
go_repository( | ||
|
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,93 @@ | ||
// Copyright 2022 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 kvserver | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/kvserverbase" | ||
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/kvserverpb" | ||
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/raftlog" | ||
"github.com/cockroachdb/cockroach/pkg/util/log" | ||
"github.com/cockroachdb/errors" | ||
) | ||
|
||
// appBatch is the in-progress foundation for standalone log entry | ||
// application[^1], i.e. the act of applying raft log entries to the state | ||
// machine in a library-style fashion, without a running CockroachDB server. | ||
// | ||
// The intended usage is as follows. Starting with a ReplicatedCmd per Entry, | ||
// | ||
// 1. check it via assertAndCheckCommand followed by toCheckedCmd | ||
// 2. run pre-add triggers (which may augment the WriteBatch) | ||
// 3. stage the WriteBatch into a pebble Batch | ||
// 4. run post-add triggers (metrics, etc) | ||
// | ||
// when all Entries have been added, the batch can be committed. In the course | ||
// of time, appBatch will become an implementation of apply.Batch itself; at the | ||
// time of writing it is only used by the replicaAppBatch implementation of | ||
// apply.Batch, which goes through the above steps while interspersing: | ||
// | ||
// 1a. testing interceptors between assertAndCheckCommand and toCheckedCmd | ||
// 2b. pre-add triggers specific to online command application (e.g. acquiring locks | ||
// during replica-spanning operations), and | ||
// 4b. post-add triggers specific to online command application (e.g. updates to | ||
// Replica in-mem state) | ||
// | ||
// [^1]: https://github.com/cockroachdb/cockroach/issues/75729 | ||
type appBatch struct { | ||
// TODO(tbg): this will absorb the following fields from replicaAppBatch: | ||
// | ||
// - batch | ||
// - state | ||
// - changeRemovesReplica | ||
} | ||
|
||
func (b *appBatch) assertAndCheckCommand( | ||
ctx context.Context, cmd *raftlog.ReplicatedCmd, state *kvserverpb.ReplicaState, isLocal bool, | ||
) (kvserverbase.ForcedErrResult, error) { | ||
if log.V(4) { | ||
log.Infof(ctx, "processing command %x: raftIndex=%d maxLeaseIndex=%d closedts=%s", | ||
cmd.ID, cmd.Index(), cmd.Cmd.MaxLeaseIndex, cmd.Cmd.ClosedTimestamp) | ||
} | ||
|
||
if cmd.Index() == 0 { | ||
return kvserverbase.ForcedErrResult{}, errors.AssertionFailedf("processRaftCommand requires a non-zero index") | ||
} | ||
if idx, applied := cmd.Index(), state.RaftAppliedIndex; idx != applied+1 { | ||
// If we have an out-of-order index, there's corruption. No sense in | ||
// trying to update anything or running the command. Simply return. | ||
return kvserverbase.ForcedErrResult{}, errors.AssertionFailedf("applied index jumped from %d to %d", applied, idx) | ||
} | ||
|
||
// TODO(sep-raft-log): move the closedts checks from replicaAppBatch here as | ||
// well. This just needs a bit more untangling as they reference *Replica, but | ||
// for no super-convincing reason. | ||
|
||
return kvserverbase.CheckForcedErr(ctx, cmd.ID, &cmd.Cmd, isLocal, state), nil | ||
} | ||
|
||
func (b *appBatch) toCheckedCmd( | ||
ctx context.Context, cmd *raftlog.ReplicatedCmd, fr kvserverbase.ForcedErrResult, | ||
) { | ||
cmd.ForcedErrResult = fr | ||
if cmd.Rejected() { | ||
log.VEventf(ctx, 1, "applying command with forced error: %s", cmd.ForcedError) | ||
|
||
// Apply an empty command. | ||
cmd.Cmd.ReplicatedEvalResult = kvserverpb.ReplicatedEvalResult{} | ||
cmd.Cmd.WriteBatch = nil | ||
cmd.Cmd.LogicalOpLog = nil | ||
cmd.Cmd.ClosedTimestamp = nil | ||
} else { | ||
log.Event(ctx, "applying command") | ||
} | ||
} |
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
Oops, something went wrong.