Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
99636: roachtest: loq recovery use new min range logic r=erikgrinaker a=aliher1911

This commit makes test compliant with new enforcement of min range size. Test needs small range and it now sets env var that restricts size to value of 1 byte.

Release note: None

Fixes cockroachdb#99529
Fixes cockroachdb#99569
Fixes cockroachdb#99576
Fixes cockroachdb#99577


99742: kv: deflake and unskip TestSecondaryTenantFollowerReadsRouting r=arulajmani a=nvanbenschoten

Fixes cockroachdb#95338.

The test was failing to wait for configuration changes that added VOTER replicas to apply on all replicas, causing flakiness. This commit fixes that issue.

Before the fix, the test failed after 100 iterations on average on a gceworker. After the fix, the test has not failed in over 2000 iterations.

Release note: None

99746: sql: complete EXPLAIN (VEC, VERBOSE) in the bundle r=yuzefovich a=yuzefovich

This commit makes it so that `vec-v.txt` file in the stmt bundle is complete. In particular, previously we would not include the auxiliary stats-related operators since we hard-coded `recordingStats=false` when generating the operator chains, and this is now fixed. The impact is very minor so there is no release note, but I believe it's worth backporting still.

Informs: cockroachdb#99741

Epic: None

Release note: None

Co-authored-by: Oleg Afanasyev <oleg@cockroachlabs.com>
Co-authored-by: Nathan VanBenschoten <nvanbenschoten@gmail.com>
Co-authored-by: Yahor Yuzefovich <yahor@cockroachlabs.com>
  • Loading branch information
4 people committed Mar 28, 2023
4 parents 0745cd4 + 5fce5c5 + 37138ad + 62fd43b commit f9a99a9
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pkg/ccl/kvccl/kvfollowerreadsccl/followerreads_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,6 @@ func TestFollowerReadsWithStaleDescriptor(t *testing.T) {
// where it needs to be estimated using node localities.
func TestSecondaryTenantFollowerReadsRouting(t *testing.T) {
defer leaktest.AfterTest(t)()
skip.WithIssue(t, 95338, "flaky test")
defer utilccl.TestingEnableEnterprise()()

skip.UnderStressRace(t, "times out")
Expand Down Expand Up @@ -973,6 +972,7 @@ func TestSecondaryTenantFollowerReadsRouting(t *testing.T) {

startKey := keys.MakeSQLCodec(serverutils.TestTenantID()).TenantPrefix()
tc.AddVotersOrFatal(t, startKey, tc.Target(1), tc.Target(2))
tc.WaitForVotersOrFatal(t, startKey, tc.Target(1), tc.Target(2))
desc := tc.LookupRangeOrFatal(t, startKey)
require.Equal(t, []roachpb.ReplicaDescriptor{
{NodeID: 1, StoreID: 1, ReplicaID: 1},
Expand Down
8 changes: 6 additions & 2 deletions pkg/cmd/roachtest/tests/loss_of_quorum_recovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,9 @@ func runRecoverLossOfQuorum(ctx context.Context, t test.Test, c cluster.Cluster,
workloadHistogramFile := "restored.json"

c.Put(ctx, t.Cockroach(), "./cockroach", c.All())
settings := install.MakeClusterSettings()
settings := install.MakeClusterSettings(install.EnvOption([]string{
"COCKROACH_MIN_RANGE_MAX_BYTES=1",
}))
c.Start(ctx, t.L(), option.DefaultStartOpts(), settings, nodes)

// Cleanup stale files generated during recovery. We do this for the case
Expand Down Expand Up @@ -383,7 +385,9 @@ func runHalfOnlineRecoverLossOfQuorum(
workloadHistogramFile := "restored.json"

c.Put(ctx, t.Cockroach(), "./cockroach", c.All())
settings := install.MakeClusterSettings()
settings := install.MakeClusterSettings(install.EnvOption([]string{
"COCKROACH_MIN_RANGE_MAX_BYTES=1",
}))
c.Start(ctx, t.L(), option.DefaultStartOpts(), settings, nodes)

// Cleanup stale files generated during recovery. We do this for the case
Expand Down
13 changes: 8 additions & 5 deletions pkg/sql/colflow/explain_vec.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func convertToVecTree(
flow *execinfrapb.FlowSpec,
localProcessors []execinfra.LocalProcessor,
isPlanLocal bool,
recordingStats bool,
) (opChains execopnode.OpChains, cleanup func(), err error) {
if !isPlanLocal && len(localProcessors) > 0 {
return nil, func() {}, errors.AssertionFailedf("unexpectedly non-empty LocalProcessors when plan is not local")
Expand All @@ -54,10 +55,11 @@ func convertToVecTree(
// execinfra.BatchReceiver, so we always pass in a fakeBatchReceiver to the
// creator.
creator := newVectorizedFlowCreator(
nil /* flowBase */, newNoopFlowCreatorHelper(), nil /* componentCreator */, false, false,
nil, &execinfra.RowChannel{}, &fakeBatchReceiver{}, flowCtx.Cfg.PodNodeDialer, execinfrapb.FlowID{}, colcontainer.DiskQueueCfg{},
flowCtx.Cfg.VecFDSemaphore, flowCtx.NewTypeResolver(flowCtx.Txn),
admission.WorkInfo{},
nil /* flowBase */, newNoopFlowCreatorHelper(), nil, /* componentCreator */
recordingStats, false /* isGatewayNode */, nil, /* waitGroup */
&execinfra.RowChannel{}, &fakeBatchReceiver{}, flowCtx.Cfg.PodNodeDialer,
execinfrapb.FlowID{}, colcontainer.DiskQueueCfg{}, flowCtx.Cfg.VecFDSemaphore,
flowCtx.NewTypeResolver(flowCtx.Txn), admission.WorkInfo{},
)
opChains, _, err = creator.setupFlow(ctx, flowCtx, flow.Processors, localProcessors, nil /*localVectorSources*/, fuseOpt)
cleanup = func() {
Expand Down Expand Up @@ -101,6 +103,7 @@ func ExplainVec(
gatewaySQLInstanceID base.SQLInstanceID,
verbose bool,
distributed bool,
recordingStats bool,
) ([]string, error) {
tp := treeprinter.NewWithStyle(treeprinter.CompactStyle)
root := tp.Child("│")
Expand All @@ -122,7 +125,7 @@ func ExplainVec(
sort.Slice(sortedFlows, func(i, j int) bool { return sortedFlows[i].sqlInstanceID < sortedFlows[j].sqlInstanceID })
for _, flow := range sortedFlows {
var cleanup func()
opChains, cleanup, err = convertToVecTree(ctx, flowCtx, flow.flow, localProcessors, !distributed)
opChains, cleanup, err = convertToVecTree(ctx, flowCtx, flow.flow, localProcessors, !distributed, recordingStats)
// We need to delay the cleanup until after the tree has been
// formatted.
defer cleanup()
Expand Down
5 changes: 4 additions & 1 deletion pkg/sql/distsql_physical_planner.go
Original file line number Diff line number Diff line change
Expand Up @@ -918,10 +918,13 @@ func (p *PlanningCtx) getDefaultSaveFlowsFunc(
flowCtx, cleanup := newFlowCtxForExplainPurposes(ctx, p, planner)
defer cleanup()
getExplain := func(verbose bool) []string {
// When we're collecting the bundle, we're always recording the
// stats.
const recordingStats = true
explain, err := colflow.ExplainVec(
ctx, flowCtx, flows, p.infra.LocalProcessors, opChains,
planner.extendedEvalCtx.DistSQLPlanner.gatewaySQLInstanceID,
verbose, planner.curPlan.flags.IsDistributed(),
verbose, planner.curPlan.flags.IsDistributed(), recordingStats,
)
if err != nil {
// In some edge cases (like when subqueries are present or
Expand Down
6 changes: 5 additions & 1 deletion pkg/sql/explain_vec.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,13 @@ func (n *explainVecNode) startExec(params runParams) error {
}
verbose := n.options.Flags[tree.ExplainFlagVerbose]
willDistribute := physPlan.Distribution.WillDistribute()
// When running EXPLAIN (VEC) we choose the option of "not recording stats"
// since we don't know whether the next invocation of the explained
// statement would result in the collection of execution stats or not.
const recordingStats = false
n.run.lines, err = colflow.ExplainVec(
params.ctx, flowCtx, flows, physPlan.LocalProcessors, nil, /* opChains */
distSQLPlanner.gatewaySQLInstanceID, verbose, willDistribute,
distSQLPlanner.gatewaySQLInstanceID, verbose, willDistribute, recordingStats,
)
if err != nil {
return err
Expand Down
8 changes: 8 additions & 0 deletions pkg/testutils/testcluster/testcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,14 @@ func (tc *TestCluster) WaitForVoters(
return tc.waitForNewReplicas(startKey, true /* waitForVoter */, targets...)
}

// WaitForVotersOrFatal is the same as WaitForVoters but it will Fatal the test
// on error.
func (tc *TestCluster) WaitForVotersOrFatal(
t testing.TB, startKey roachpb.Key, targets ...roachpb.ReplicationTarget,
) {
require.NoError(t, tc.WaitForVoters(startKey, targets...))
}

// waitForNewReplicas waits for each of the targets to have a fully initialized
// replica of the range indicated by startKey.
//
Expand Down

0 comments on commit f9a99a9

Please sign in to comment.