-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
48024: roachpb: rework replicas.CanMakeProgress() r=andreimatei a=andreimatei CanMakeProgress was delegating to Raft, but also had a local fast-path. The fast-path was broken: it was considering a configuration with two voter-fulls and a voter-incoming, and one of the fulls dead, to be able to make progress. That was false; the configuration doesn't have quorum for the outgoing config. This patch fixes the bug, and also removes the dependency on the Raft code. The way in which we were using the Raft library was quite inefficient, and I want to start using this function in the replication report, which will call it a lot. For purposes of deciding under-replication, that report already needs to understand the different replica states instead of delegating everything to Raft. So let's embrace this responsibility more fully. Release note: None 48159: sql: use rangefeeds for notifications about changes to table descriptors r=lucyzhang a=ajwerner This PR comes in several commits: 1) Enable rangefeeds unconditionally on system ranges * this is going to need to some modification to work with tenant system spans 2) Add a cluster version for the above functionality 3) Add the basic (messy) implementation of rangefeed based lease manager notifications 4) Add some testing knobs 5) Clean up 3 in a number of ways, add some more testing, fix a synchronization issue. 6) Updates a test to not break a new assertion that values in the descriptor table actually be descriptors Relates to but does not fully resolve #47150. Another PR will follow-up and disable the gossip of the descriptors table and lift the enforcement of the system config transaction anchor. 48668: colexec: short-circuit hash join when build side is empty r=yuzefovich a=yuzefovich Previously, we would always fully consume both sides of the join, even when the build (right) side is empty. We can, however, short-circuit in such case for INNER, RIGHT OUTER, and LEFT SEMI joins and skip probing phase altogether in such scenarios. For example, this helps query 93 of TPC-DS benchmark with scale factor 1. Release note: None 48669: colexec: fix performance inefficiency in materializer r=yuzefovich a=yuzefovich **colexec: fix performance inefficiency in materializer** We mistakenly were passing `sqlbase.DatumAlloc` by value, and not by pointer, and as a result we would always be allocating 16 datums but using only 1 - i.e. we were not only not pooling the allocations, but actually making a bunch of useless allocations as well. This inefficiency becomes noticeable when the vectorized query returns many rows and when we have wrapped processors and those processors get a lot of input rows - in all cases when we need to materialize a lot. For example, TPC-H query 16 sees about 10% improvement (it returns 18k rows) and TPC-DS query 6 sees 2x improvement (it has wrapped hash aggregator with a decimal column) with this fix. Release note (performance improvement): A performance inefficiency has been fixed in the vectorized execution engine which results in speed ups on all queries when run via the vectorized engine, with most noticeable gains on the queries that output many rows. **sqlbase: prohibit copying DatumAlloc by value** This commit adds `_ util.NoCopy` to `DatumAlloc` struct to prevent us from misusing it. A few places failed the linter, and those have been addressed, but there was no performance problems AFAICT due to the removed copies by value. Release note: None Co-authored-by: Andrei Matei <[email protected]> Co-authored-by: Andrew Werner <[email protected]> Co-authored-by: Yahor Yuzefovich <[email protected]>
- Loading branch information
Showing
43 changed files
with
1,081 additions
and
303 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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
// Copyright 2020 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_test | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/cockroachdb/cockroach/pkg/base" | ||
"github.com/cockroachdb/cockroach/pkg/keys" | ||
"github.com/cockroachdb/cockroach/pkg/kv" | ||
"github.com/cockroachdb/cockroach/pkg/kv/kvclient/kvcoord" | ||
"github.com/cockroachdb/cockroach/pkg/roachpb" | ||
"github.com/cockroachdb/cockroach/pkg/sql/sqlbase" | ||
"github.com/cockroachdb/cockroach/pkg/testutils/testcluster" | ||
"github.com/cockroachdb/cockroach/pkg/util/leaktest" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
// TestRangefeedWorksOnSystemRangesUnconditionally ensures that a rangefeed will | ||
// not return an error when operating on a system span even if the setting is | ||
// disabled. The test also ensures that an error is received if a rangefeed is | ||
// run on a user table. | ||
func TestRangefeedWorksOnSystemRangesUnconditionally(t *testing.T) { | ||
defer leaktest.AfterTest(t)() | ||
|
||
ctx := context.Background() | ||
tc := testcluster.StartTestCluster(t, 3, base.TestClusterArgs{}) | ||
defer tc.Stopper().Stop(ctx) | ||
|
||
// Make sure the rangefeed setting really is disabled. | ||
_, err := tc.ServerConn(0).Exec("SET CLUSTER SETTING kv.rangefeed.enabled = false") | ||
require.NoError(t, err) | ||
|
||
db := tc.Server(0).DB() | ||
ds := tc.Server(0).DistSenderI().(*kvcoord.DistSender) | ||
|
||
t.Run("works on system ranges", func(t *testing.T) { | ||
startTS := db.Clock().Now() | ||
descTableKey := keys.SystemSQLCodec.TablePrefix(keys.DescriptorTableID) | ||
descTableSpan := roachpb.Span{ | ||
Key: descTableKey, | ||
EndKey: descTableKey.PrefixEnd(), | ||
} | ||
|
||
evChan := make(chan *roachpb.RangeFeedEvent) | ||
rangefeedErrChan := make(chan error, 1) | ||
ctxToCancel, cancel := context.WithCancel(ctx) | ||
go func() { | ||
rangefeedErrChan <- ds.RangeFeed(ctxToCancel, descTableSpan, startTS, false /* withDiff */, evChan) | ||
}() | ||
|
||
// Note: 42 is a system descriptor. | ||
const junkDescriptorID = 42 | ||
require.GreaterOrEqual(t, keys.MaxReservedDescID, junkDescriptorID) | ||
junkDescriptorKey := sqlbase.MakeDescMetadataKey(keys.SystemSQLCodec, junkDescriptorID) | ||
junkDescriptor := sqlbase.WrapDescriptor(&sqlbase.DatabaseDescriptor{ | ||
Name: "junk", | ||
ID: junkDescriptorID, | ||
}) | ||
require.NoError(t, db.Txn(ctx, func(ctx context.Context, txn *kv.Txn) error { | ||
if err := txn.SetSystemConfigTrigger(); err != nil { | ||
return err | ||
} | ||
return txn.Put(ctx, junkDescriptorKey, junkDescriptor) | ||
})) | ||
after := db.Clock().Now() | ||
for { | ||
ev := <-evChan | ||
if ev.Checkpoint != nil && after.Less(ev.Checkpoint.ResolvedTS) { | ||
t.Fatal("expected to see write which occurred before the checkpoint") | ||
} | ||
|
||
if ev.Val != nil && ev.Val.Key.Equal(junkDescriptorKey) { | ||
var gotProto sqlbase.Descriptor | ||
require.NoError(t, ev.Val.Value.GetProto(&gotProto)) | ||
require.EqualValues(t, junkDescriptor, &gotProto) | ||
break | ||
} | ||
} | ||
cancel() | ||
// There are several cases that seems like they can happen due | ||
// to closed connections. Instead we just expect an error. | ||
// The main point is we get an error in a timely manner. | ||
require.Error(t, <-rangefeedErrChan) | ||
}) | ||
t.Run("does not work on user ranges", func(t *testing.T) { | ||
k := tc.ScratchRange(t) | ||
require.NoError(t, tc.WaitForSplitAndInitialization(k)) | ||
startTS := db.Clock().Now() | ||
scratchSpan := roachpb.Span{Key: k, EndKey: k.PrefixEnd()} | ||
evChan := make(chan *roachpb.RangeFeedEvent) | ||
require.Regexp(t, `rangefeeds require the kv\.rangefeed.enabled setting`, | ||
ds.RangeFeed(ctx, scratchSpan, startTS, false /* withDiff */, evChan)) | ||
}) | ||
} |
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
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.