Skip to content

Commit

Permalink
Merge #75638
Browse files Browse the repository at this point in the history
75638: sql: de-flake TestDistSQLFlowsVirtualTables r=irfansharif a=irfansharif

Fixes #75208 (speculatively). Wasn't able to repro the original failure,
so here's a blind stab at fixing it. See [this](github.com//issues/75208#issuecomment-1023800242) for the theory; I think
it's possible for the query this test fires off to error out + get
dequeued concurrently with when the assertions are made about it being
enqueued. We should relax our assertions accordingly.

Release note: None

Co-authored-by: irfan sharif <[email protected]>
  • Loading branch information
craig[bot] and irfansharif committed Jan 28, 2022
2 parents 71becf3 + eb2a5cf commit 39d728b
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions pkg/sql/crdb_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import (
"github.com/cockroachdb/cockroach/pkg/sql/tests"
"github.com/cockroachdb/cockroach/pkg/testutils"
"github.com/cockroachdb/cockroach/pkg/testutils/serverutils"
"github.com/cockroachdb/cockroach/pkg/testutils/skip"
"github.com/cockroachdb/cockroach/pkg/testutils/sqlutils"
"github.com/cockroachdb/cockroach/pkg/testutils/testcluster"
"github.com/cockroachdb/cockroach/pkg/util/ctxgroup"
Expand Down Expand Up @@ -517,7 +516,6 @@ UPDATE system.namespace SET id = 12345 WHERE id = %d;

func TestDistSQLFlowsVirtualTables(t *testing.T) {
defer leaktest.AfterTest(t)()
skip.UnderRaceWithIssue(t, 75208, "flaky test under race")
defer log.Scope(t).Close(t)

const numNodes = 3
Expand Down Expand Up @@ -686,8 +684,18 @@ func TestDistSQLFlowsVirtualTables(t *testing.T) {
if maxRunningFlows == 1 {
expRunning, expQueued = expQueued, expRunning
}
if getNum(db, clusterScope, runningStatus) != expRunning || getNum(db, clusterScope, queuedStatus) != expQueued {
t.Fatalf("unexpected output from cluster_distsql_flows on node %d", nodeID+1)
gotRunning, gotQueued := getNum(db, clusterScope, runningStatus), getNum(db, clusterScope, queuedStatus)
if gotRunning != expRunning {
t.Fatalf("unexpected output from cluster_distsql_flows on node %d (running=%d)", nodeID+1, gotRunning)
}
if maxRunningFlows == 1 {
if gotQueued != expQueued {
t.Fatalf("unexpected output from cluster_distsql_flows on node %d (queued=%d)", nodeID+1, gotQueued)
}
} else {
if gotQueued > expQueued { // it's possible for the query to have already errored out
t.Fatalf("unexpected output from cluster_distsql_flows on node %d (queued=%d)", nodeID+1, gotQueued)
}
}

// Check node level table.
Expand All @@ -700,8 +708,18 @@ func TestDistSQLFlowsVirtualTables(t *testing.T) {
if maxRunningFlows == 1 {
expRunning, expQueued = expQueued, expRunning
}
if getNum(db, nodeScope, runningStatus) != expRunning || getNum(db, nodeScope, queuedStatus) != expQueued {
t.Fatalf("unexpected output from node_distsql_flows on node %d", nodeID+1)
gotRunning, gotQueued = getNum(db, nodeScope, runningStatus), getNum(db, nodeScope, queuedStatus)
if gotRunning != expRunning {
t.Fatalf("unexpected output from node_distsql_flows on node %d (running=%d)", nodeID+1, gotRunning)
}
if maxRunningFlows == 1 {
if gotQueued != expQueued {
t.Fatalf("unexpected output from node_distsql_flows on node %d (queued=%d)", nodeID+1, gotQueued)
}
} else {
if gotQueued > expQueued { // it's possible for the query to have already errored out
t.Fatalf("unexpected output from node_distsql_flows on node %d (queued=%d)", nodeID+1, gotQueued)
}
}
}
}
Expand Down

0 comments on commit 39d728b

Please sign in to comment.