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

changefeedccl: use correct channel size in parallelio #118476

Merged
merged 1 commit into from
Jan 30, 2024

Conversation

jayshrivastava
Copy link
Contributor

Previously, the channels used for sending requests and receiving results were too small. This meant that a caller could block on sending a request even after acquiring quota. This change ensures that the size of the channels is large enough so that this blocking does not occur.

Closes: #118463
Closes: #118462
Closes: #118461
Closes: #118460
Closes: #118459
Closes: #118458
Epic: none

Copy link

blathers-crl bot commented Jan 30, 2024

It looks like your PR touches production code but doesn't add or edit any test code. Did you consider adding tests to your PR?

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@jayshrivastava jayshrivastava marked this pull request as ready for review January 30, 2024 15:19
@jayshrivastava jayshrivastava requested a review from a team as a code owner January 30, 2024 15:19
@jayshrivastava jayshrivastava requested review from miretskiy and rharding6373 and removed request for a team January 30, 2024 15:19
@jayshrivastava
Copy link
Contributor Author

I stress tested TestChangefeedEndTimeWithCursor. It would fail consistently before this change. Now --stress passes.

Copy link
Collaborator

@rharding6373 rharding6373 left a comment

Choose a reason for hiding this comment

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

:lgtm: Good find, thanks for the quick fix! I have a question about memory accounting

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @jayshrivastava and @miretskiy)


pkg/ccl/changefeedccl/parallel_io.go line 97 at r1 (raw file):

		// NB: The size of these channels should not be less than the quota. This prevents the producer from
		// blocking on sending requests which have been admitted.
		requestCh: make(chan AdmittedIORequest, quota),

Do we do memory accounting for the channel size?

Copy link
Contributor Author

@jayshrivastava jayshrivastava 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! 1 of 0 LGTMs obtained (waiting on @miretskiy and @rharding6373)


pkg/ccl/changefeedccl/parallel_io.go line 97 at r1 (raw file):

Previously, rharding6373 (Rachael Harding) wrote…

Do we do memory accounting for the channel size?

We don't need to memory account because the requests are batches which contain cdc events and these cdc events are accounted for. The overhead is considered negligible. They get freed by batch.alloc.Release after the result comes back:

handleResult := func(result IOResult) {
req, err := result.Consume()
batch, _ := req.(*sinkBatch)
if err != nil {
s.handleError(err)
} else {
s.metrics.recordEmittedBatch(
batch.bufferTime, batch.numMessages, batch.mvcc, batch.numKVBytes, sinkDoesNotCompress,
)
}
inflight -= batch.numMessages
if (err != nil || inflight == 0) && sinkFlushWaiter != nil {
close(sinkFlushWaiter)
sinkFlushWaiter = nil
}
batch.alloc.Release(ctx)
freeSinkBatchEvent(batch)
}

Event allocs are created here here

alloc, err := b.AcquireMemory(ctx, n)
if err != nil {
return err
}
e.alloc = alloc

Previously, the channels used for sending requests and receiving results were
too small. This meant that a caller could block on sending a request even
after acquiring quota. This change ensures that the size of the channels
is large enough so that this blocking does not occur.

Closes: cockroachdb#118463
Closes: cockroachdb#118462
Closes: cockroachdb#118461
Closes: cockroachdb#118460
Closes: cockroachdb#118459
Closes: cockroachdb#118458
Epic: none
@jayshrivastava
Copy link
Contributor Author

bors r+

@craig craig bot merged commit 38dd16a into cockroachdb:master Jan 30, 2024
8 of 9 checks passed
@craig
Copy link
Contributor

craig bot commented Jan 30, 2024

Build succeeded:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment