Skip to content

Write tombstones on delete so SSTable data is correctly masked#104

Open
mweiden wants to merge 1 commit intomainfrom
claude/fix-delete-tombstone-MvFam
Open

Write tombstones on delete so SSTable data is correctly masked#104
mweiden wants to merge 1 commit intomainfrom
claude/fix-delete-tombstone-MvFam

Conversation

@mweiden
Copy link
Copy Markdown
Owner

@mweiden mweiden commented Feb 20, 2026

delete() and delete_ns() previously only removed the key from the in-memory memtable, leaving any value written to an SSTable in a prior flush permanently visible to subsequent reads.

Fix by writing a timestamped tombstone record (the 8-byte timestamp followed by the TOMBSTONE sentinel) through insert_internal, which persists the deletion to the WAL and, on the next flush, to an SSTable so it can mask older versions of the key on disk.

Update get() and scan_ns() to recognise tombstone values and return None / exclude them from results. Also filter tombstones from scan() so the public API does not expose deletion markers to callers.

https://claude.ai/code/session_011eyXTLxHcSEAeV6PRG3izJ

delete() and delete_ns() previously only removed the key from the
in-memory memtable, leaving any value written to an SSTable in a
prior flush permanently visible to subsequent reads.

Fix by writing a timestamped tombstone record (the 8-byte timestamp
followed by the TOMBSTONE sentinel) through insert_internal, which
persists the deletion to the WAL and, on the next flush, to an SSTable
so it can mask older versions of the key on disk.

Update get() and scan_ns() to recognise tombstone values and return
None / exclude them from results. Also filter tombstones from scan()
so the public API does not expose deletion markers to callers.

https://claude.ai/code/session_011eyXTLxHcSEAeV6PRG3izJ
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: db29c4b9ba

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/lib.rs
const TOMBSTONE: &[u8] = b"\x00TOMBSTONE";

fn is_tombstone(val: &[u8]) -> bool {
val.len() == 8 + TOMBSTONE.len() && &val[8..] == TOMBSTONE
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Distinguish tombstones from legitimate payload bytes

is_tombstone identifies deletions solely by checking whether the stored value bytes equal timestamp + "\x00TOMBSTONE", which means any client that legitimately writes that exact binary payload (e.g., via insert/insert_ts with raw bytes) will have its data treated as deleted by get, scan, and scan_ns. This introduces a silent correctness bug for binary values; tombstones need an encoding that cannot collide with user data.

Useful? React with 👍 / 👎.

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.

2 participants