Skip to content

kv: don't mutate tscache arena when serializing#118665

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
nvb:nvanbenschoten/fix118614
Feb 2, 2024
Merged

kv: don't mutate tscache arena when serializing#118665
craig[bot] merged 1 commit intocockroachdb:masterfrom
nvb:nvanbenschoten/fix118614

Conversation

@nvb
Copy link
Copy Markdown
Contributor

@nvb nvb commented Feb 2, 2024

Fixes #118614.
Fixes #118620.
Fixes #118618.

This commit fixes a bug where a call to sklPage.serialize could unintentionally mutate other keys in the sklPage's skiplist. This was possible because the append was called on a key that unexpectedly had extra capacity.

We could use slices.Clip to fix this and mandate a memory copy, but we instead use encoding.BytesNext, which has a useful fast-path.

While here, we do the same thing in mergeSpans to avoid an similar issues.

Release note: None

Fixes cockroachdb#118614.
Fixes cockroachdb#118620.
Fixes cockroachdb#118618.

This commit fixes a bug where a call to `sklPage.serialize` could
unintentionally mutate other keys in the sklPage's skiplist. This
was possible because the append was called on a key that unexpectedly
had extra capacity.

We could use `slices.Clip` to fix this and mandate a memory copy, but we
instead use `encoding.BytesNext`, which has a useful fast-path.

While here, we do the same thing in `mergeSpans` to avoid an similar
issues.

Release note: None
@nvb nvb requested a review from arulajmani February 2, 2024 18:38
@nvb nvb requested a review from a team as a code owner February 2, 2024 18:38
@blathers-crl
Copy link
Copy Markdown

blathers-crl bot commented Feb 2, 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
Copy Markdown
Member

This change is Reviewable

Copy link
Copy Markdown
Collaborator

@arulajmani arulajmani 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 4 of 4 files at r1, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @nvanbenschoten)

@nvb
Copy link
Copy Markdown
Contributor Author

nvb commented Feb 2, 2024

bors r+

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Feb 2, 2024

Build succeeded:

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.

roachtest: import/mixed-versions failed roachtest: change-replicas/mixed-version failed kv/kvserver: TestDecommission failed

3 participants