Skip to content
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: rationalize cluster destruction #35585

Merged
merged 2 commits into from
Apr 23, 2019

Conversation

andreimatei
Copy link
Contributor

Cluster destruction can be initiated from two places: tests finishing
and a signal being received. Some synchronization is required for
handling races on this destruction. This patch makes this
synchronization nicer. Before this patch, the case where a signal was
received and then a test finishes was handled OK, but the reverse I
think was not.

This patch also kills a global containing a list of all the clusters and
encapsulates it in a nicer clusterRegistry.

Release note: None

@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Contributor Author

@andreimatei andreimatei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

friendly ping

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @petermattis)

@andreimatei
Copy link
Contributor Author

Bob do you want to be my pal here?

Copy link
Member

@bobvawter bobvawter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 2 of 2 files at r1, 1 of 1 files at r2.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @andreimatei and @petermattis)


pkg/cmd/roachtest/cluster.go, line 255 at r1 (raw file):

	select {
	case <-done:
	case <-time.After(5 * time.Minute):

Should this be done by calling context.WithTimeout on the Context passed into destroyAllClusters?


pkg/cmd/roachtest/cluster.go, line 680 at r1 (raw file):

	// destroyed is used to coordinate between different goroutines that want to
	// destroy a cluster.
	destroyed chan struct{}

Maybe change the type here to <-chan struct{} since the only useful thing to do here is to select or close()?


pkg/cmd/roachtest/cluster.go, line 695 at r1 (raw file):

		return false
	}
	c.destroyState.mu.destroying = true

It seems odd that a should function would mutate the state of the cluster; the name sounds idempotent. Maybe rename it to beginDestroy or something and document that this function is a one-shot.


pkg/cmd/roachtest/cluster.go, line 1072 at r1 (raw file):

// destroyInner implements the logic for Destroy but without closing c.l.
func (c *cluster) destroyInner(ctx context.Context) {

The name of this method is confusing w.r.t. doDestroy. Can the main Destroy method defer to a single doDestroy() that has a parameter that controls whether or not to close the associated logger?

Copy link
Contributor Author

@andreimatei andreimatei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @bobvawter and @petermattis)


pkg/cmd/roachtest/cluster.go, line 255 at r1 (raw file):

Previously, bobvawter (Bob Vawter) wrote…

Should this be done by calling context.WithTimeout on the Context passed into destroyAllClusters?

done


pkg/cmd/roachtest/cluster.go, line 680 at r1 (raw file):

Previously, bobvawter (Bob Vawter) wrote…

Maybe change the type here to <-chan struct{} since the only useful thing to do here is to select or close()?

well you can't close a receive-only channel. Morally this reference (which is the only reference to this chan) is used both for receiving and for sending (i.e. closing).


pkg/cmd/roachtest/cluster.go, line 695 at r1 (raw file):

Previously, bobvawter (Bob Vawter) wrote…

It seems odd that a should function would mutate the state of the cluster; the name sounds idempotent. Maybe rename it to beginDestroy or something and document that this function is a one-shot.

see now


pkg/cmd/roachtest/cluster.go, line 1072 at r1 (raw file):

Previously, bobvawter (Bob Vawter) wrote…

The name of this method is confusing w.r.t. doDestroy. Can the main Destroy method defer to a single doDestroy() that has a parameter that controls whether or not to close the associated logger?

I don't know what I was drinking when I wrote this. See now.

Copy link
Member

@bobvawter bobvawter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 2 of 2 files at r3, 1 of 1 files at r4.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @andreimatei and @petermattis)


pkg/cmd/roachtest/cluster.go, line 1166 at r3 (raw file):

	c.destroyState.mu.Lock()
	close(c.destroyState.mu.destroyed)
	ch := c.destroyState.mu.destroyed

Move assignment of ch one line up and call close(ch)?

Cluster destruction can be initiated from two places: tests finishing
and a signal being received. Some synchronization is required for
handling races on this destruction. This patch makes this
synchronization nicer. Before this patch, the case where a signal was
received and then a test finishes was handled OK, but the reverse I
think was not.

This patch also kills a global containing a list of all the clusters and
encapsulates it in a nicer clusterRegistry.

Release note: None
To be used in the future where I want to get rid of subtests by
flattening everything and thus producing tests with longer names, at
which point I'll somehow truncate the names of their clusters to the
length limit allowed by GCE and so it'll be more likely to end with
duplicates if nobody's watching.

Release note: None
Copy link
Contributor Author

@andreimatei andreimatei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TFTR!

bors r+

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @bobvawter and @petermattis)


pkg/cmd/roachtest/cluster.go, line 1166 at r3 (raw file):

Previously, bobvawter (Bob Vawter) wrote…

Move assignment of ch one line up and call close(ch)?

done

@craig
Copy link
Contributor

craig bot commented Apr 23, 2019

Build failed (retrying...)

@craig
Copy link
Contributor

craig bot commented Apr 23, 2019

Build failed (retrying...)

craig bot pushed a commit that referenced this pull request Apr 23, 2019
35585: roachtest: rationalize cluster destruction r=andreimatei a=andreimatei

Cluster destruction can be initiated from two places: tests finishing
and a signal being received. Some synchronization is required for
handling races on this destruction. This patch makes this
synchronization nicer. Before this patch, the case where a signal was
received and then a test finishes was handled OK, but the reverse I
think was not.

This patch also kills a global containing a list of all the clusters and
encapsulates it in a nicer clusterRegistry.

Release note: None

36967: exec: add cancellation check to operators r=yuzefovich a=yuzefovich

We introduce a CancelChecker operator that wraps all other operators
and performs a cancellation check on every batch. Also, sorter and
hash joiner do additional checks themselves since they can spend
a lot of time in certain phases of execution.

Release note: None

Co-authored-by: Andrei Matei <[email protected]>
Co-authored-by: Yahor Yuzefovich <[email protected]>
@craig
Copy link
Contributor

craig bot commented Apr 23, 2019

Build succeeded

@craig craig bot merged commit 7c1ac1c into cockroachdb:master Apr 23, 2019
@andreimatei andreimatei deleted the roachtest.cluster-registry branch April 25, 2019 19:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants