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

bulk: fix incorrect memory handling in the kvBuf #86738

Merged
merged 1 commit into from
Aug 29, 2022

Conversation

adityamaru
Copy link
Contributor

@adityamaru adityamaru commented Aug 24, 2022

This change fixes a memory accounting bug where
we were appending a KV to the kvBuf without accounting
for its memory.

Release note (bug fix): adds a missing memory accounting
call when appending a KV to the underlying kvBuf

Release justification: low risk bug fix that prevents an
import from panicking on non-release builds

@cockroach-teamcity
Copy link
Member

This change is Reviewable

Comment on lines +200 to +202
if b.curBuf.fits(ctx, need, sz(b.maxBufferLimit()), &b.memAcc) {
return b.curBuf.append(key, value)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice find!

@adityamaru adityamaru force-pushed the import-investigation branch 3 times, most recently from 860c286 to be9ce7e Compare August 28, 2022 15:17
This change fixes a memory accounting bug where
we were appending a KV to the kvBuf without accounting
for its memory.

Release note (bug fix): adds a missing memory accounting
call when appending a KV to the underlying kvBuf

Release justification: low risk bug fix that prevents an
import from panicking on non-release builds
@adityamaru adityamaru force-pushed the import-investigation branch from be9ce7e to f3f5cc5 Compare August 28, 2022 15:19
@adityamaru adityamaru marked this pull request as ready for review August 28, 2022 15:19
@adityamaru adityamaru requested a review from a team as a code owner August 28, 2022 15:19
@adityamaru adityamaru requested review from dt and stevendanna August 28, 2022 15:19
@@ -41,8 +41,8 @@ func TestAddBatched(t *testing.T) {
t.Run("batch=default", func(t *testing.T) {
runTestImport(t, 32<<20)
})
t.Run("batch=1", func(t *testing.T) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This test is no longer valid since a 1byte max buf size means we can't grow the kvBuf to be more than that, which means the single KV doesn't fit in that buffer.

@adityamaru
Copy link
Contributor Author

TFTR!

bors r=stevendanna

@craig
Copy link
Contributor

craig bot commented Aug 29, 2022

Build succeeded:

@craig craig bot merged commit 00aa1c4 into cockroachdb:master Aug 29, 2022
@adityamaru adityamaru deleted the import-investigation branch August 30, 2022 16:15
@adityamaru
Copy link
Contributor Author

blathers backport 22.1

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