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

[dnm] kvserver: use SingleDelete for raft log compaction #134355

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pav-kv
Copy link
Collaborator

@pav-kv pav-kv commented Nov 6, 2024

Epic: none
Release note: none

Copy link

blathers-crl bot commented Nov 6, 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

@pav-kv pav-kv changed the title kvserver: use SingleDelete for raft log compaction [dnm] kvserver: use SingleDelete for raft log compaction Nov 6, 2024
Copy link
Collaborator

@sumeerbhola sumeerbhola 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 @pav-kv)


pkg/kv/kvserver/replica_raft.go line 2986 at r1 (raw file):

		// avoid allocating when constructing Raft log keys (16 bytes).
		prefix := prefixBuf.RaftLogPrefix()
		for idx := currentTruncatedState.Index + 1; idx <= suggestedTruncatedState.Index; idx++ {

What code paths are used to delete the raft log when

  • a range snapshot is received
  • the range is dropped
    Is my understanding correct in that in both the above cases all the raft log entries are wiped out.

I think we could more safely make this change if we centralized the logic that modifies the raft log entries into one package. Maybe logstore?

logstore.logAppend will need some attention. storage.MVCCPut when overwriting an existing Raft entry will eventually do storage.Writer.PutUnversioned, which will layer a Pebble SET on top of an existing SET, which cannot be later deleted using a SINGLEDEL.

Copy link
Collaborator Author

@pav-kv pav-kv 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 @sumeerbhola)


pkg/kv/kvserver/replica_raft.go line 2986 at r1 (raw file):

Previously, sumeerbhola wrote…

What code paths are used to delete the raft log when

  • a range snapshot is received
  • the range is dropped
    Is my understanding correct in that in both the above cases all the raft log entries are wiped out.

I think we could more safely make this change if we centralized the logic that modifies the raft log entries into one package. Maybe logstore?

logstore.logAppend will need some attention. storage.MVCCPut when overwriting an existing Raft entry will eventually do storage.Writer.PutUnversioned, which will layer a Pebble SET on top of an existing SET, which cannot be later deleted using a SINGLEDEL.

Also, there is a write in logstore package that you mention which I glossed over in this prototype because it's rare. When overwriting an entry (we always know when we're about to), we could SINGLEDEL+SET instead of just SET.

Agree that logstore/etc needs to be cleaned up as part of this work (and also relatedly to sep-raft-log). Right now, it's scattered across the codebase: logstore, replica_raftlog.go, and a few places writing raft state to storage directly.

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