Allow FullMergeV3 to produce a deletion result via std::monostate#14607
Allow FullMergeV3 to produce a deletion result via std::monostate#14607zaidoon1 wants to merge 1 commit into
Conversation
|
| Check | Count |
|---|---|
concurrency-mt-unsafe |
2 |
performance-inefficient-vector-operation |
1 |
| Total | 3 |
Details
db/db_merge_operator_test.cc (1 warning(s))
db/db_merge_operator_test.cc:2854:5: warning: 'emplace_back' is called inside a loop; consider pre-allocating the container capacity before the loop [performance-inefficient-vector-operation]
db_stress_tool/db_stress_tool.cc (2 warning(s))
db_stress_tool/db_stress_tool.cc:259:7: warning: function is not thread safe [concurrency-mt-unsafe]
db_stress_tool/db_stress_tool.cc:266:7: warning: function is not thread safe [concurrency-mt-unsafe]
30c844c to
f66c937
Compare
988e992 to
7ecc3ef
Compare
Codex Code Review - OBSOLETESuperseded by a newer AI review. Expand to see the original review.🟡 Codex Code ReviewAuto-triggered after CI passed — reviewing commit 7ecc3ef ❌ Codex review failed before producing findings. ℹ️ About this responseGenerated by Codex CLI. Limitations:
Commands:
|
Claude Code Review - OBSOLETESuperseded by a newer AI review. Expand to see the original review.✅ Claude Code ReviewAuto-triggered after CI passed — reviewing commit 7ecc3ef SummaryWell-structured PR that adds a fourth High-severity findings (1):
Full review (click to expand)Findings🔴 HIGHH1. GetContext::PostprocessMerge mishandles merge-deletion as corruption --
|
| Context | Safe? | Action? |
|---|---|---|
| WritePreparedTxnDB | YES | None |
| ReadOnly DB | YES | None |
| User-defined timestamps | YES | None |
| BlobDB | YES (tested) | None |
| Prefix seek | YES (tested) | None |
| Old snapshots | YES (tested) | None |
| GetContext single-level merge | NO | Fix required (H1) |
Positive Observations
- Comprehensive test coverage: ~1800 lines covering iteration, compaction, snapshots, MultiGet, WBWI, transactions, range tombstones, multi-CF, blob storage, wide columns, and stress testing.
- Sound on-disk format: Standard
kTypeDeletionentries -- backward compatible with older RocksDB. - Correct variant ordering with static_assert: Enforces
std::stringfirst,std::monostatelast. - Careful iterator lifecycle:
ReleaseTempPinnedData()and removal of redundantvalid_ = trueshow attention to detail. - Bottommost compaction: Skip-older-entries loop correctly prevents stale versions from resurfacing.
ℹ️ About this response
Generated by Claude Code.
Review methodology: claude_md/code_review.md
Limitations:
- Claude may miss context from files not in the diff
- Large PRs may be truncated
- Always apply human judgment to AI suggestions
Commands:
/claude-review [context]— Request a code review/claude-query <question>— Ask about the PR or codebase
a673fcf to
e18bb9b
Compare
Codex Code Review - OBSOLETESuperseded by a newer AI review. Expand to see the original review.🟡 Codex Code ReviewAuto-triggered after CI passed — reviewing commit e18bb9b ❌ Codex review failed before producing findings. ℹ️ About this responseGenerated by Codex CLI. Limitations:
Commands:
|
Claude Code Review - OBSOLETESuperseded by a newer AI review. Expand to see the original review.✅ Claude Code ReviewAuto-triggered after CI passed — reviewing commit e18bb9b SummaryWell-designed feature that adds High-severity findings (0): No high-severity findings. Full review (click to expand)Findings🔴 HIGHNo high-severity findings. All initially flagged critical issues were reconciled against the diff and found to be addressed (see reconciliation notes below). 🟡 MEDIUMM1. Breaking API Change --
|
| Context | Addressed in Diff? | Notes |
|---|---|---|
| Get/MultiGet point lookups | Yes | GetContext::PostprocessMerge (inferred from truncated diff + test assertions) |
| Forward iteration (DBIter) | Yes | FindNextUserEntryInternal deletion-skip loop |
| Backward iteration (DBIter) | Yes | FindValueForCurrentKey + FindValueForCurrentKeyUsingSeek |
| Compaction (bottommost) | Yes | MergeUntil drops key + skips older entries |
| Compaction (non-bottommost) | Yes | MergeUntil emits kTypeDeletion tombstone |
| Merge-on-write (max_successive_merges) | Yes | write_batch.cc MergeCF handles kTypeDeletion |
| Snapshots | Yes | Tests verify snapshot isolation |
| WAL recovery | Yes | Test MergeDeletionRecovery covers this |
| WriteBatchWithIndex | Uncertain | Tests exist; code changes in truncated diff |
| Transactions | Uncertain | Test MergeDeletionTransactionGet exists |
| Blob storage | Yes | Test MergeDeletionWithBlobStorage + MergeWithBlobBaseValue fix |
| Wide columns | Yes | Test MergeDeletionOverWideColumnEntity |
| Range tombstones | Yes | Test MergeDeletionWithRangeTombstones |
| Multi-CF | Yes | Test MergeDeletionMultiColumnFamilies |
| Prefix bloom | Yes | Test MergeDeletionWithPrefixBloom |
| Compaction filter | Yes | Test MergeDeletionWithCompactionFilter |
| User-defined timestamps | No | Not tested |
| ReadOnly DB | No | Not tested |
| PartialMerge | No | Not tested |
Reconciliation Notes
Many agent findings were initially classified as HIGH/CRITICAL but were reconciled as false positives after careful diff analysis:
- "Missing kTypeDeletion in SetValueAndColumnsFromMergeResult" -- Present in diff (
db/db_iter.cc) - "Version::MultiGet unchecked PinSelf" -- Fixed in diff (
db/version_set.ccwraps instatus->ok()check) - "PostprocessMerge corruption bug" -- Likely fixed in truncated diff (
get_context.cc); testMergeDeletionSingleLevelGetReturnsNotFoundexplicitly assertsASSERT_FALSE(s.IsCorruption())) - "Tombstone sequence number incorrect" -- Correct; uses newest merge operand's sequence, matching compaction semantics
- "Bottommost level drops snapshot-protected keys" -- CompactionIterator handles snapshot filtering before calling MergeUntil
- "user_key_to_skip copy unnecessary" -- Necessary; documented in code
Positive Observations
- Thorough iterator coverage: The diff handles all iterator paths (forward, backward, seek, direction change, seek-optimization fast path) with careful attention to pinned data lifecycle (
ReleaseTempPinnedDatain the deletion-skip loop). - Well-commented code: Every significant code change includes detailed comments explaining the "why" (e.g., the
user_key_to_skipcopy rationale, the at-bottom vs non-bottom distinction, the crash-recovery contract in write_batch.cc). - Defensive assertions: The debug-mode assertion that
op_failure_scope == kDefaultwhen monostate is set catches confused merge operators early. - Comprehensive stress testing:
MergeDeletionStressandMergeDeletionConcurrentReadersAndWritersprovide good probabilistic coverage. - Cross-feature tests: 16 cross-feature tests covering WBWI, transactions, range tombstones, blob storage, wide columns, prefix bloom, compaction filter, and max_successive_merges demonstrate thoroughness.
- Correct compaction semantics: The at-bottom path correctly skips older entries (preventing resurrection of old values after merge-deletion), and the non-bottom path emits a standard kTypeDeletion tombstone.
ℹ️ About this response
Generated by Claude Code.
Review methodology: claude_md/code_review.md
Limitations:
- Claude may miss context from files not in the diff
- Large PRs may be truncated
- Always apply human judgment to AI suggestions
Commands:
/claude-review [context]— Request a code review/claude-query <question>— Ask about the PR or codebase
e18bb9b to
95c31c6
Compare
Codex Code Review - OBSOLETESuperseded by a newer AI review. Expand to see the original review.🟡 Codex Code ReviewAuto-triggered after CI passed — reviewing commit 95c31c6 ❌ Codex review failed before producing findings. ℹ️ About this responseGenerated by Codex CLI. Limitations:
Commands:
|
Claude Code Review - OBSOLETESuperseded by a newer AI review. Expand to see the original review.✅ Claude Code ReviewAuto-triggered after CI passed — reviewing commit 95c31c6 SummaryWell-designed feature that adds merge-operator-driven deletion via High-severity findings (2):
Full review (click to expand)Findings🔴 HIGHH1. GetContext::PostprocessMerge must handle kMergeOperatorDeletion --
|
| Context | Handling | Verified? |
|---|---|---|
| WritePreparedTxnDB | Merge at read time, unaffected | No explicit test |
| BlobDB | Explicit test exists | YES |
| Snapshots | Multiple tests | YES |
| WBWI / Transactions | Explicit tests | YES |
| max_successive_merges | Explicit test | YES |
| Prefix seek | Explicit test | YES |
Positive Observations
- Thorough test suite (~1900 lines) covering 40+ scenarios
- Correct use-after-free prevention in MergeUntil skip-loop
- Proper pinned-data lifecycle management in iterator deletion loop
- Consistent perf counter bumping in both iteration directions
- Correct WAL replay contract documentation
ℹ️ About this response
Generated by Claude Code.
Review methodology: claude_md/code_review.md
Limitations:
- Claude may miss context from files not in the diff
- Large PRs may be truncated
- Always apply human judgment to AI suggestions
Commands:
/claude-review [context]— Request a code review/claude-query <question>— Ask about the PR or codebase
95c31c6 to
ea3d3ce
Compare
Codex Code Review - OBSOLETESuperseded by a newer AI review. Expand to see the original review.🟡 Codex Code ReviewAuto-triggered after CI passed — reviewing commit ea3d3ce ❌ Codex review failed before producing findings. ℹ️ About this responseGenerated by Codex CLI. Limitations:
Commands:
|
Claude Code Review - OBSOLETESuperseded by a newer AI review. Expand to see the original review.✅ Claude Code ReviewAuto-triggered after CI passed — reviewing commit ea3d3ce SummaryOverall solid PR implementing merge-operator-driven deletion via High-severity findings (2):
Full review (click to expand)Findings🔴 HIGHH1. Heap allocation in MergeUntil at-bottom skip-loop --
|
| Context | Affected? | Analysis |
|---|---|---|
| WritePreparedTxnDB | Yes | Safe -- visibility is upstream of merge resolution |
| ReadOnly DB | Yes | Works if PostprocessMerge updated (truncated diff) |
| User-defined timestamps | Yes | Untested (M1) |
| BlobDB | Yes | Tested. Works. |
| FIFO/Universal compaction | Yes | Same CompactionIterator path. Safe. |
| MemPurge | Possibly | Untested but should propagate correctly |
| Snapshots | Yes | Tested extensively. Skip-loop respects boundaries. |
Positive Observations
- Thorough test suite (40+ cases) covering iteration, snapshots, WBWI, transactions, blobs, wide columns, prefix bloom, concurrent access
- Clean two-overload design separating iterator/compaction vs point-lookup return conventions
- Careful memory management with explicit user_key copy before keys_.clear()
- Well-documented code changes throughout
ℹ️ About this response
Generated by Claude Code.
Review methodology: claude_md/code_review.md
Limitations:
- Claude may miss context from files not in the diff
- Large PRs may be truncated
- Always apply human judgment to AI suggestions
Commands:
/claude-review [context]— Request a code review/claude-query <question>— Ask about the PR or codebase
ea3d3ce to
68bfca7
Compare
🟡 Codex Code ReviewAuto-triggered after CI passed — reviewing commit 68bfca7 ❌ Codex review failed before producing findings. ℹ️ About this responseGenerated by Codex CLI. Limitations:
Commands:
|
✅ Claude Code ReviewAuto-triggered after CI passed — reviewing commit 68bfca7 SummaryThis PR adds High-severity findings (3):
Full review (click to expand)Findings🔴 HIGHH1. Missing infrastructure changes (truncated diff) --
|
| Context | Assessment |
|---|---|
| WritePreparedTxnDB | Safe -- deletion resolves before visibility checks |
| User-defined timestamps | Safe -- skip loop uses matching comparison logic; tested |
| BlobDB | Safe -- delegates correctly; tested |
| ReadOnly DB | Safe -- read-path only |
| Concurrent writes | Safe -- per-thread resolution; tested |
Positive Observations
- Extensive test coverage (~1900 lines): iteration, snapshots, compaction, UDT, WAL recovery, WBWI, transactions, blobs, wide columns, range tombstones, multi-CF, prefix bloom, concurrent access
- Correct use-after-free prevention via
user_key_to_skip_ SetValueAndColumnsFromMergeResultas single authority forvalid_from merge results- Both forward and backward seek-optimization paths covered
The full review has been written to review-findings.md.
ℹ️ About this response
Generated by Claude Code.
Review methodology: claude_md/code_review.md
Limitations:
- Claude may miss context from files not in the diff
- Large PRs may be truncated
- Always apply human judgment to AI suggestions
Commands:
/claude-review [context]— Request a code review/claude-query <question>— Ask about the PR or codebase
68bfca7 to
4108990
Compare
Add std::monostate as a fourth alternative to MergeOperationOutputV3::NewValue. When a merge operator sets this variant, the key is treated as deleted: - Get()/MultiGet() return Status::NotFound() - Iterators skip the key (forward and backward) - Compaction produces a deletion tombstone, or drops the key entirely when the full history has been seen at the bottommost level This enables use cases like counter auto-delete-at-zero, conditional mutations, and Cassandra-style row expiration without requiring a separate compaction filter. Closes facebook#14593
4108990 to
919cdda
Compare
Add std::monostate as a fourth alternative to
MergeOperationOutputV3::NewValue. When a merge operator sets this variant, the key is treated as deleted:
This enables use cases like counter auto-delete-at-zero, conditional mutations, and Cassandra-style row expiration without requiring a separate compaction filter.
Closes #14593