-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
roachtest: remove direct go calls #134644
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ import ( | |
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/option" | ||
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/registry" | ||
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/roachtestutil" | ||
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/roachtestutil/task" | ||
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/spec" | ||
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/test" | ||
"github.com/cockroachdb/cockroach/pkg/roachprod/install" | ||
|
@@ -81,18 +82,10 @@ func registerAllocator(r registry.Registry) { | |
c.Start(ctx, t.L(), startOpts, install.MakeClusterSettings(), c.Range(start+1, nodes)) | ||
c.Run(ctx, option.WithNodes(c.Node(1)), "./cockroach workload init kv --drop {pgurl:1}") | ||
for node := 1; node <= nodes; node++ { | ||
node := node | ||
// TODO(dan): Ideally, the test would fail if this queryload failed, | ||
// but we can't put it in monitor as-is because the test deadlocks. | ||
go func() { | ||
t.Go(func(taskCtx context.Context, _ *logger.Logger) error { | ||
cmd := fmt.Sprintf("./cockroach workload run kv --tolerate-errors --min-block-bytes=8 --max-block-bytes=127 {pgurl%s}", c.Node(node)) | ||
l, err := t.L().ChildLogger(fmt.Sprintf(`kv-%d`, node)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like this logger was previously unused? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, had to look twice before removing, and in actual fact was dead code. |
||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
defer l.Close() | ||
_ = c.RunE(ctx, option.WithNodes(c.Node(node)), cmd) | ||
}() | ||
return c.RunE(taskCtx, option.WithNodes(c.Node(node)), cmd) | ||
}, task.Name(fmt.Sprintf(`kv-%d`, node))) | ||
} | ||
|
||
// Wait for 3x replication, we record the time taken to achieve this. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,9 +14,11 @@ import ( | |
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/cluster" | ||
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/option" | ||
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/registry" | ||
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/roachtestutil/task" | ||
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/spec" | ||
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/test" | ||
"github.com/cockroachdb/cockroach/pkg/roachprod/install" | ||
"github.com/cockroachdb/cockroach/pkg/roachprod/logger" | ||
"github.com/cockroachdb/cockroach/pkg/util/cancelchecker" | ||
"github.com/cockroachdb/cockroach/pkg/util/randutil" | ||
"github.com/cockroachdb/cockroach/pkg/util/timeutil" | ||
|
@@ -66,30 +68,32 @@ func registerCancel(r registry.Registry) { | |
// (either query execution error or an error indicating the | ||
// absence of expected cancellation error). | ||
errCh := make(chan error, 1) | ||
go func(queryNum int) { | ||
runnerConn := c.Conn(ctx, t.L(), 1) | ||
t.Go(func(taskCtx context.Context, l *logger.Logger) error { | ||
runnerConn := c.Conn(taskCtx, l, 1) | ||
defer runnerConn.Close() | ||
setupQueries := []string{"USE tpch;"} | ||
if !useDistsql { | ||
setupQueries = append(setupQueries, "SET distsql = off;") | ||
} | ||
for _, setupQuery := range setupQueries { | ||
t.L().Printf("executing setup query %q", setupQuery) | ||
l.Printf("executing setup query %q", setupQuery) | ||
if _, err := runnerConn.Exec(setupQuery); err != nil { | ||
errCh <- err | ||
close(sem) | ||
return | ||
// Errors are handled in the main goroutine. | ||
return nil //nolint:returnerrcheck | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: it's not immediately obvious that returning errors in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree with Darryl's comment; we should make this explicit in the interface doc. Also, this test could technically be refactored further to explicitly return There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had the same thought, will need to make it clear that returning an error from a task will result in a test failure. We could alternatively provide a version of the Go/GoWithCancel methods that does not take an error return. From the footprint perspective, I didn't want to fiddle too much with already working code. But we could definitely make some of these more ergonomic. I'll create an issue for it, since engineers tend to borrow from existing code, it would be better if the examples are improved. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
No bother, it's not that hard to add |
||
} | ||
} | ||
query := tpch.QueriesByNumber[queryNum] | ||
t.L().Printf("executing q%d\n", queryNum) | ||
l.Printf("executing q%d\n", queryNum) | ||
close(sem) | ||
_, err := runnerConn.Exec(query) | ||
if err == nil { | ||
err = errors.New("query completed before it could be canceled") | ||
} | ||
errCh <- err | ||
}(queryNum) | ||
return nil | ||
}, task.Name("query-runner")) | ||
|
||
// Wait for the query-runner goroutine to start as well as | ||
// to execute setup queries. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ import ( | |
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/roachtestutil" | ||
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/test" | ||
"github.com/cockroachdb/cockroach/pkg/roachprod/install" | ||
"github.com/cockroachdb/cockroach/pkg/roachprod/logger" | ||
"github.com/cockroachdb/cockroach/pkg/server/authserver" | ||
"github.com/cockroachdb/cockroach/pkg/server/serverpb" | ||
"github.com/cockroachdb/cockroach/pkg/util/httputil" | ||
|
@@ -87,11 +88,11 @@ func runClusterInit(ctx context.Context, t test.Test, c cluster.Cluster) { | |
t.L().Printf("checking that the SQL conns are not failing immediately") | ||
errCh := make(chan error, len(dbs)) | ||
for _, db := range dbs { | ||
db := db | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good riddance :) |
||
go func() { | ||
t.Go(func(taskCtx context.Context, _ *logger.Logger) error { | ||
var val int | ||
errCh <- db.QueryRow("SELECT 1").Scan(&val) | ||
}() | ||
errCh <- db.QueryRowContext(taskCtx, "SELECT 1").Scan(&val) | ||
return nil | ||
}) | ||
} | ||
|
||
// Give them time to get a "connection refused" or similar error if | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto!