forked from cockroachdb/cockroach
-
Notifications
You must be signed in to change notification settings - Fork 1
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
91969: sql: audit all processors to make their closure bullet-proof r=yuzefovich a=yuzefovich This commit replaces all usages of `ProcessorBaseNoHelper.Ctx` field with a call to the newly-introduced `Ctx()` method which returns a background context if the processor hasn't been started. This change makes it so that all processors now respect the contract of `colexecop.Closer` interface which says that `Close` must be safe to call even if `Init` hasn't been performed (in the context of processors this means that `Columnarizer.Init` wasn't called meaning that `Processor.Start` wasn't either). Initially, I attempted to fix this in cockroachdb#91446 by putting the protection into the columnarizer, but that led to broken assumptions since we wouldn't close all closers that we expected to (in particular, the materializer that is the input to the wrapped row-by-row processor wouldn't be closed). This commit takes a different approach and should fix the issue for good without introducing any flakiness. As a result, this commit fixes a rarely hit issue when the aggregator and the zigzag joiner attempt to log when they are closed if they haven't been started (that we see occasionally from sentry). The issue is quite rare though, so no release note seems appropriate. Fixes: cockroachdb#84902. Fixes: cockroachdb#91845. Release note: None 92265: kvconnectorccl: allow secondary tenants to prefetch range lookups r=ajwerner a=ajwerner This patch permits the tenant connector to request more than 0 ranges to be prefetched. In order to enable this, we add logic in the implementation of the RangeLookup RPC to filter any results which are not intended for this tenant. Fixes cockroachdb#91433 Release note: None 92284: ui: show stmt idle time in execution/planning chart r=matthewtodd a=matthewtodd Part of cockroachdb#86667. The example statement fingerprint below comes from me connecting to a local cockroach instance with `psql` (since `cockroach sql` by default runs a few extra queries that confuse the timings) and individually running the following lines to simulate some inter-statement latency: ```sql BEGIN; SELECT 1; COMMIT; ``` | Before | After | |--|--| |<img width="1372" alt="Screen Shot 2022-11-21 at 2 35 49 PM" src="https://user-images.githubusercontent.com/5261/203144731-fd5a42fb-7b60-473a-990a-fb5fabf2756a.png">|<img width="1372" alt="Screen Shot 2022-11-21 at 2 35 58 PM" src="https://user-images.githubusercontent.com/5261/203144736-2600c0f9-7811-4b9d-a9e1-dbb8aeea71ee.png">| Release note (ui change): The "Statement Execution and Planning Time" chart on the statement fingerprint page now includes a third value, "Idle," representing the time spent by the application waiting to execute this statement while holding a transaction open. Co-authored-by: Yahor Yuzefovich <[email protected]> Co-authored-by: Andrew Werner <[email protected]> Co-authored-by: Matthew Todd <[email protected]>
- Loading branch information
Showing
41 changed files
with
549 additions
and
284 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
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
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,81 @@ | ||
// Copyright 2022 The Cockroach Authors. | ||
// | ||
// Licensed as a CockroachDB Enterprise file under the Cockroach Community | ||
// License (the "License"); you may not use this file except in compliance with | ||
// the License. You may obtain a copy of the License at | ||
// | ||
// https://github.com/cockroachdb/cockroach/blob/master/licenses/CCL.txt | ||
|
||
package kvtenantccl_test | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/cockroachdb/cockroach/pkg/base" | ||
"github.com/cockroachdb/cockroach/pkg/keys" | ||
"github.com/cockroachdb/cockroach/pkg/kv/kvclient/kvcoord" | ||
"github.com/cockroachdb/cockroach/pkg/kv/kvclient/rangecache" | ||
"github.com/cockroachdb/cockroach/pkg/kv/kvserver" | ||
"github.com/cockroachdb/cockroach/pkg/roachpb" | ||
"github.com/cockroachdb/cockroach/pkg/testutils/testcluster" | ||
"github.com/cockroachdb/cockroach/pkg/util/leaktest" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
// TestRangeLookupPrefetchFiltering is an integration test to ensure that | ||
// range results are filtered for the client. | ||
func TestRangeLookupPrefetchFiltering(t *testing.T) { | ||
defer leaktest.AfterTest(t)() | ||
|
||
ctx := context.Background() | ||
tc := testcluster.StartTestCluster(t, 1, base.TestClusterArgs{ | ||
ServerArgs: base.TestServerArgs{ | ||
DisableDefaultTestTenant: true, // we're going to manually add tenants | ||
Knobs: base.TestingKnobs{ | ||
Store: &kvserver.StoreTestingKnobs{ | ||
DisableMergeQueue: true, | ||
}, | ||
}, | ||
}, | ||
}) | ||
defer tc.Stopper().Stop(ctx) | ||
|
||
ten2ID := roachpb.MustMakeTenantID(2) | ||
tenant2, err := tc.Server(0).StartTenant(ctx, base.TestTenantArgs{ | ||
TenantID: ten2ID, | ||
}) | ||
require.NoError(t, err) | ||
|
||
// Split some ranges within tenant2 that we'll want to see in prefetch. | ||
ten2Codec := keys.MakeSQLCodec(ten2ID) | ||
ten2Split1 := append(ten2Codec.TenantPrefix(), 'a') | ||
ten2Split2 := append(ten2Codec.TenantPrefix(), 'b') | ||
{ | ||
tc.SplitRangeOrFatal(t, ten2Split1) | ||
tc.SplitRangeOrFatal(t, ten2Split2) | ||
} | ||
|
||
// Split some ranges for the tenant which comes after tenant2. | ||
{ | ||
ten3Codec := keys.MakeSQLCodec(roachpb.MustMakeTenantID(3)) | ||
tc.SplitRangeOrFatal(t, ten3Codec.TenantPrefix()) | ||
tc.SplitRangeOrFatal(t, append(ten3Codec.TenantPrefix(), 'b')) | ||
tc.SplitRangeOrFatal(t, append(ten3Codec.TenantPrefix(), 'c')) | ||
} | ||
|
||
// Do the fetch and make sure we prefetch all the ranges we should see, | ||
// and none of the ranges we should not. | ||
db := tenant2.DistSenderI().(*kvcoord.DistSender).RangeDescriptorCache().DB() | ||
prefixRKey := keys.MustAddr(ten2Codec.TenantPrefix()) | ||
res, prefetch, err := db.RangeLookup( | ||
ctx, prefixRKey, | ||
rangecache.ReadFromLeaseholder, false, /* useReverseScan */ | ||
) | ||
require.NoError(t, err) | ||
require.Len(t, res, 1) | ||
require.Equal(t, prefixRKey, res[0].StartKey) | ||
require.Len(t, prefetch, 2) | ||
require.Equal(t, keys.MustAddr(ten2Split1), prefetch[0].StartKey) | ||
require.Equal(t, keys.MustAddr(ten2Split2), prefetch[1].StartKey) | ||
} |
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.