Skip to content

Fix memtable use-after-free in getLogFileInfoBySeq() - #230

Merged
greensky00 merged 1 commit into
masterfrom
junahn_pr2
Nov 13, 2026
Merged

greensky00 merged 1 commit into
masterfrom
junahn_pr2

Conversation

@greensky00

Copy link
Copy Markdown
Contributor
  • Seq numbers of a log file were read before grabbing it, so the log reclaimer could purge (free) its memtable in the middle.

  • Grab the log file first, and release it on the not-found paths.

  • Load the purged memtable afterwards if needed, by grabbing it once more with the loading option and releasing the extra reference.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are recorded for the log-file reference-handling change.

No open issues 🎉

What changed in this PR

This PR addresses a memtable use-after-free race in getLogFileInfoBySeq() by holding a log-file reference before reading sequence numbers.

Changes:

  • Grab the log file before sequence-number checks to prevent concurrent memtable purging.
  • Release the reference on not-found paths.
  • Load a purged memtable when needed using a temporary extra reference.
File Description
src/​log_manifest.cc Adjusts reference acquisition, cleanup, and memtable loading in getLogFileInfoBySeq().

Review effort: Balanced

* Seq numbers of a log file were read before grabbing it, so the log
reclaimer could purge (free) its memtable in the middle.

* Grab the log file first, and release it on the not-found paths.

* Load the purged memtable afterwards if needed, by grabbing it once
more with the loading option and releasing the extra reference.
@greensky00
greensky00 merged commit 5e16065 into master Nov 13, 2026
1 check passed
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