Skip to content

changefeedccl: Add pushback duration metric to blocking buffer.#68256

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
miretskiy:sink_pushback
Jul 30, 2021
Merged

changefeedccl: Add pushback duration metric to blocking buffer.#68256
craig[bot] merged 1 commit intocockroachdb:masterfrom
miretskiy:sink_pushback

Conversation

@miretskiy
Copy link
Copy Markdown
Contributor

Add a blocking buffer metric which keeps track of the amount
of time waited for resource aquisition.

Release Notes: None

@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

Copy link
Copy Markdown
Collaborator

@stevendanna stevendanna 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 @ajwerner and @miretskiy)

a discussion (no related file):
Seems like a reasonable metric to add to me. Looks like there are some CI issues but otherwise seems good.



pkg/ccl/changefeedccl/kvevent/blocking_buffer_test.go, line 30 at r1 (raw file):

	"github.com/cockroachdb/cockroach/pkg/util/log"
	"github.com/cockroachdb/cockroach/pkg/util/mon"
	"github.com/cockroachdb/cockroach/pkg/util/randutil"

You likely need to make bazel-generate after these import changes.


pkg/ccl/changefeedccl/kvevent/blocking_buffer_test.go, line 93 at r1 (raw file):

	}

	// Keep consuming events until buffer enters pushback.

thoughts: It looks to me like this test depends on the 10 goroutines started above filling the buffer faster than our one goroutine can cosume the events (seems very likely given the small size of the buffer and the size of the messages). If we broke the accounting though, I think this would fail by timing out. That's probably OK given how many tests we have that operate that way but perhaps a comment to remind us would be good.

I can't think of a way to guarantee the buffer enters pushback without some testing hooks inside the blocking buffer. But, we might be able to reduce the (already small) chance of this flaking out by synchronously pre-filling the buffer before starting the async producers (or waiting to start the consumer until some number of messages have been pushed).

@miretskiy miretskiy requested a review from stevendanna July 30, 2021 15:26
Copy link
Copy Markdown
Contributor Author

@miretskiy miretskiy 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 @ajwerner and @stevendanna)

a discussion (no related file):

Previously, stevendanna (Steven Danna) wrote…

Seems like a reasonable metric to add to me. Looks like there are some CI issues but otherwise seems good.

ack.



pkg/ccl/changefeedccl/kvevent/blocking_buffer_test.go, line 30 at r1 (raw file):

Previously, stevendanna (Steven Danna) wrote…

You likely need to make bazel-generate after these import changes.

One day I'll remember to do that. But not today.


pkg/ccl/changefeedccl/kvevent/blocking_buffer_test.go, line 93 at r1 (raw file):

Previously, stevendanna (Steven Danna) wrote…

thoughts: It looks to me like this test depends on the 10 goroutines started above filling the buffer faster than our one goroutine can cosume the events (seems very likely given the small size of the buffer and the size of the messages). If we broke the accounting though, I think this would fail by timing out. That's probably OK given how many tests we have that operate that way but perhaps a comment to remind us would be good.

I can't think of a way to guarantee the buffer enters pushback without some testing hooks inside the blocking buffer. But, we might be able to reduce the (already small) chance of this flaking out by synchronously pre-filling the buffer before starting the async producers (or waiting to start the consumer until some number of messages have been pushed).

I think you made a good comment, calling out my "laziness". Turns out there is a perfectly nice way of accomplishing good what this test is trying to accomplish without testing hooks.

Copy link
Copy Markdown
Contributor Author

@miretskiy miretskiy 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 @ajwerner and @stevendanna)


pkg/ccl/changefeedccl/kvevent/blocking_buffer_test.go, line 93 at r1 (raw file):

Previously, miretskiy (Yevgeniy Miretskiy) wrote…

I think you made a good comment, calling out my "laziness". Turns out there is a perfectly nice way of accomplishing good what this test is trying to accomplish without testing hooks.

Done.

Copy link
Copy Markdown
Contributor Author

@miretskiy miretskiy 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 @ajwerner and @stevendanna)


pkg/ccl/changefeedccl/kvevent/blocking_buffer_test.go, line 30 at r1 (raw file):

Previously, miretskiy (Yevgeniy Miretskiy) wrote…

One day I'll remember to do that. But not today.

Done.

Copy link
Copy Markdown
Collaborator

@stevendanna stevendanna 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 @ajwerner, @miretskiy, and @stevendanna)


pkg/ccl/changefeedccl/kvevent/blocking_buffer_test.go, line 76 at r2 (raw file):

	// Arrange for mem buffer to notify us when it waits for resources.
	var waitMu syncutil.Mutex
	waited := sync.NewCond(&waitMu)

up to you: we could use a chan struct{} here instead. Not sure which people generally find easier to read.

Copy link
Copy Markdown
Contributor Author

@miretskiy miretskiy 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 @ajwerner and @stevendanna)


pkg/ccl/changefeedccl/kvevent/blocking_buffer_test.go, line 76 at r2 (raw file):

Previously, stevendanna (Steven Danna) wrote…

up to you: we could use a chan struct{} here instead. Not sure which people generally find easier to read.

I was worried that I would have multiple write attempts; or read attempts; or close attempts...
I think condition here is good.

@miretskiy
Copy link
Copy Markdown
Contributor Author

tftr
bors r=stevendanna

@miretskiy
Copy link
Copy Markdown
Contributor Author

bors r-

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Jul 30, 2021

Canceled.

@miretskiy miretskiy requested a review from a team as a code owner July 30, 2021 19:16
Add a blocking buffer metric which keeps track of the amount
of time waited for resource aquisition.

Release Notes: None
@miretskiy
Copy link
Copy Markdown
Contributor Author

@stevendanna @ajwerner I made some changes suggested by Andrew re not keeping track of additional state in the blocking buffer and just making few minor changes in quota pool so that we can leverage existing functionality.
PTAL.

Copy link
Copy Markdown
Contributor

@ajwerner ajwerner left a comment

Choose a reason for hiding this comment

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

LGTM

@miretskiy
Copy link
Copy Markdown
Contributor Author

bors r+

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Jul 30, 2021

Build succeeded:

@craig craig bot merged commit cfc525f into cockroachdb:master Jul 30, 2021
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.

4 participants