Expose error recovery events in C listener API#14809
Conversation
✅ clang-tidy: No findings on changed linesCompleted in 159.0s. |
Codex Code Review - OBSOLETESuperseded by a newer AI review. Expand to see the original review.🟡 Codex Code ReviewAuto-triggered after CI passed — reviewing commit 9ba7526 ❌ 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 9ba7526 SummaryClean, additive C API change that exposes error recovery listener events. The implementation is functionally correct and maintains backward compatibility. Two design-level concerns warrant attention before merge. High-severity findings (2):
Full review (click to expand)Findings🔴 HIGHH1. Exposes DEPRECATED
|
| Context | Code executes? | Assumptions hold? | Action needed? |
|---|---|---|---|
| WritePreparedTxnDB | Yes (if listener registered) | Yes | Safe |
| ReadOnly DB | No (no background errors) | N/A | Safe |
| CompactionService | Yes (if listener registered) | Yes | Safe |
| User-defined timestamps | Yes (if listener registered) | Yes | Safe |
| FIFO/Universal compaction | Yes (if listener registered) | Yes | Safe |
This is a pure C API wrapper -- no core logic changes. All execution contexts are safe.
Positive Observations
- Backward compatibility is well preserved via delegation pattern
- Null-checking for new optional callbacks is the right call (prevents crash when old constructor is used)
- Stack allocation for
rocksdb_status_ptr_tis slightly more efficient than the heap pattern used byOnBackgroundError PermitUncheckedError()is correctly placed in both new callbacks- Severity enum values correctly match C++
Status::Severity - Test follows existing C API test conventions
ℹ️ 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
9ba7526 to
ad3243e
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 ad3243e ❌ 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 ad3243e SummaryClean, well-structured C API addition that follows existing patterns. The delegation from High-severity findings (1):
Full review (click to expand)Findings🔴 HIGHH1. Test helpers exposed in public API --
|
| Context | Executes? | Safe? | Notes |
|---|---|---|---|
| WritePreparedTxnDB | Yes | Yes | No interaction with transaction visibility |
| ReadOnly DB | Unlikely | Yes | Callbacks are no-ops if not registered |
| CompactionService | Yes | Yes | Listeners execute locally |
| FIFO/Universal compaction | Yes | Yes | Error recovery is compaction-style agnostic |
Positive Observations
- Static asserts for severity constants are excellent practice.
- Stack-local allocation is safer and more efficient than the existing heap pattern.
- Clean backwards-compatible delegation from old to new constructor.
- Good test coverage of successful/failed recovery, severity, auto_recovery toggling, and destructor.
ℹ️ 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
53ada4e to
f88fc70
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 f88fc70 ❌ 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 f88fc70 SummaryAdditive C API exposing High-severity findings (1):
Full review (click to expand)Findings🔴 HIGHH1. Null function pointer dereference for non-recovery callbacks --
|
| Context | Does code execute? | Assumptions hold? | Action needed? |
|---|---|---|---|
| WritePreparedTxnDB | YES (inherits listeners) | YES | Safe -- C wrapper just forwards |
| ReadOnly DB | YES (error handler exists) | YES | Safe -- pre-existing C++ behavior |
| CompactionService | YES | YES | Safe -- listener ownership follows DB |
| User-defined timestamps | N/A | N/A | No interaction |
| Old snapshots | N/A | N/A | No interaction |
The NotifyOnBackgroundError call sequence (line 62-66 of event_helpers.cc) is single-threaded within the listener loop iteration. The OnBackgroundError receives a mutable Status* and OnErrorRecoveryBegin receives *bg_error by value. This is intentional C++ API behavior -- the C wrapper correctly mirrors it. No data race exists because calls are sequential.
The PermitUncheckedError() calls on const BackgroundErrorRecoveryInfo& members are valid because PermitUncheckedError() is a const method that modifies mutable checked_.
Positive Observations
- Backwards compatibility preserved: The old
rocksdb_eventlistener_create()delegates cleanly to the new constructor with nullptr for recovery callbacks. No ABI break. - static_assert guards: Severity enum values are validated at compile time against the C++ enum, preventing silent drift.
- Stack allocation improvement: Using stack-local
rocksdb_status_ptr_tinstead of heap allocation is a performance improvement over the existingOnBackgroundErrorpattern. - PermitUncheckedError placement: Correctly placed outside the null-check guard, ensuring Status objects are always marked as checked regardless of whether a callback is registered.
- Comprehensive C++ test: The
CApiErrorRecoveryCallbackstest in listener_test.cc thoroughly validates the callback wiring, parameter conversion, and auto_recovery propagation. - on_background_error_cb typedef change: Adding parameter names is a source- and ABI-compatible improvement that aids 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
Expose EventListener::OnErrorRecoveryEnd through the C listener wrapper instead of the deprecated OnErrorRecoveryCompleted hook. The C callback now receives an opaque BackgroundErrorRecoveryInfo wrapper so callers can inspect both the old and new background error status, including severity. Add compile-time severity alignment checks and cover the new C listener recovery callbacks without adding test-only helper functions to the RocksDB C library ABI. c_test verifies public C API construction and ownership, while listener_test deterministically exercises status severity access, auto_recovery propagation, recovery-end old/new status handling, null recovery callbacks through the legacy constructor, and null callback slots through the new constructor. Make C event-listener callback slots optional before forwarding, so callers that only register a subset of callbacks cannot crash on unrelated listener events.
f88fc70 to
75cce31
Compare
🟡 Codex Code ReviewAuto-triggered after CI passed — reviewing commit 75cce31 ❌ Codex review failed before producing findings. ℹ️ About this responseGenerated by Codex CLI. Limitations:
Commands:
|
✅ Claude Code ReviewAuto-triggered after CI passed — reviewing commit 75cce31 SummarySolid, well-structured addition to the C API that follows existing patterns and maintains backward compatibility. The null-safety improvements and heap-to-stack optimization in High-severity findings (1):
Full review (click to expand)Findings🔴 HIGHH1. Missing pointer lifetime documentation for callback parameters --
|
| Context | Executes? | Safe? | Notes |
|---|---|---|---|
| WritePreparedTxnDB | YES | YES | Same listener mechanism |
| ReadOnly DB | NO | N/A | No error recovery events |
| CompactionService | YES | YES | Listeners forwarded |
| Concurrent writers | YES | YES | Stack-local per call |
| Multiple listeners | YES | YES | auto_recovery skip behavior is existing C++ semantics |
Positive Observations
- Heap-to-stack optimization in
OnBackgroundErroreliminates unnecessarynew/delete - Null-safety for all callbacks enables selective callback registration without crashes
static_assertfor severity constants provides compile-time validation- Proper
auto_recoverybridging with null-safety and!= 0back-conversion - Good test coverage: happy path, null safety, and legacy compatibility
- Consistent pointer-wrapper pattern matching
rocksdb_status_ptr_t
ℹ️ 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
Summary
Testing