Skip to content

chore: introduce QuadError and narrow audited error convergence - #961

Merged
jiangzhe merged 2 commits into
mainfrom
narrow-quad-error
Aug 8, 2026
Merged

chore: introduce QuadError and narrow audited error convergence#961
jiangzhe merged 2 commits into
mainfrom
narrow-quad-error

Conversation

@jiangzhe

@jiangzhe jiangzhe commented Aug 8, 2026

Copy link
Copy Markdown
Owner

Closes #960

Summary by CodeRabbit

  • Bug Fixes

    • Preserved fatal storage and runtime errors instead of masking them as lifecycle failures.
    • Improved error reports with clearer operation phases and context for DDL, transactions, maintenance, and file operations.
    • Ensured poisoned engines and runtimes consistently reject new work with the original fatal error.
    • Improved transaction commit, rollback, recovery, and synchronization failure reporting.
  • Reliability

    • Strengthened configuration validation during storage startup and recovery.
    • Preserved existing mutation, retry, conflict detection, indexing, and rollback behavior.

@jiangzhe jiangzhe self-assigned this Aug 8, 2026
@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro Plus

Run ID: c37254a7-e3b0-4706-8b49-83d037819c2d

📥 Commits

Reviewing files that changed from the base of the PR and between 0d06ca1 and a794d88.

⛔ Files ignored due to path filters (3)
  • docs/backlogs/000000-template.md is excluded by none and included by none
  • docs/backlogs/closed/000178-common-multi-domain-error-carrier.md is excluded by none and included by none
  • docs/tasks/000263-introduce-quad-error-and-narrow-audited-error-convergence.md is excluded by none and included by none
📒 Files selected for processing (2)
  • doradb-storage/src/session.rs
  • doradb-storage/src/trx/stmt.rs
🚧 Files skipped from review as they are similar to previous changes (2)
  • doradb-storage/src/trx/stmt.rs
  • doradb-storage/src/session.rs

📝 Walkthrough

Walkthrough

The change adds typed error carriers, validates transaction configuration during bootstrap, preserves fatal errors across admission and completion paths, and migrates catalog, transaction, and table mutation internals to typed result domains.

Changes

Typed error migration

Layer / File(s) Summary
Error carriers and completion conversion
doradb-storage/src/error.rs, doradb-storage/src/file/mod.rs, doradb-storage/src/log/mod.rs
Adds QuadError and LifecycleOrFatalError. Completion paths preserve native error domains and add runtime context for physical failures.
Validated configuration and engine bootstrap
doradb-storage/src/conf/*, doradb-storage/src/engine.rs, doradb-storage/src/trx/sys.rs
Validates transaction configuration once, stores the resolved redo-log prefix, and uses typed results during startup and recovery.
Fatal-aware runtime, session, and transaction paths
doradb-storage/src/runtime/mandatory.rs, doradb-storage/src/engine.rs, doradb-storage/src/session.rs, doradb-storage/src/trx/mod.rs, doradb-storage/src/trx/sys.rs
Preserves fatal poison errors during admission, completion, maintenance waits, checkout, and commit. Lifecycle results remain for shutdown and closed-state rejection.
Typed DDL and table mutation boundaries
doradb-storage/src/catalog/*, doradb-storage/src/table/access.rs, doradb-storage/src/trx/stmt.rs, doradb-storage/src/trx/stream_stmt.rs
Migrates index planning and table mutation paths to typed carriers. Disclosure remains at public or callback-facing boundaries.

Estimated code review effort: 5 (Critical) | ~120 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Session
  participant EngineInner
  participant MandatoryRuntime
  participant TransactionSystem
  Session->>EngineInner: request admission
  EngineInner->>MandatoryRuntime: check health and completion state
  MandatoryRuntime-->>EngineInner: return Lifecycle or Fatal result
  EngineInner-->>Session: preserve the original error domain
  Session->>TransactionSystem: submit transaction or DDL operation
  TransactionSystem-->>Session: return typed runtime, operation, or fatal result
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Linked Issues check ❓ Inconclusive The core #960 carrier migration and fatal-error preservation are evidenced, but the approved public-error convergence inventory refresh is not shown. Provide evidence that the approved public-error convergence inventory was refreshed, or include the required inventory changes.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the primary changes: adding QuadError and narrowing internal error convergence.
Out of Scope Changes check ✅ Passed The reviewed changes support #960 error-carrier migration, configuration validation, fatal preservation, and related test updates; no unrelated scope is evident.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch narrow-quad-error

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 2 medium

Results:
2 new issues

Category Results
Complexity 2 medium

View in Codacy

🟢 Metrics 50 complexity · 26 duplication

Metric Results
Complexity 50
Duplication 26

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@greptile-apps

greptile-apps Bot commented Aug 8, 2026

Copy link
Copy Markdown

Greptile Summary

The PR introduces closed typed error carriers and moves error convergence toward public ownership boundaries while preserving fatal, lifecycle, runtime, and operation classifications.

  • Adds QuadError and LifecycleOrFatalError with typed completion replay.
  • Moves transaction configuration validation and redo-prefix resolution into engine bootstrap.
  • Narrows error propagation across catalog, maintenance, table mutation, and transaction paths.
  • Updates the error specification, coding guidance, task records, and disclosure audit.

Confidence Score: 5/5

The PR appears safe to merge because no blocking failure remains.

No blocking failure remains.

Important Files Changed

Filename Overview
doradb-storage/src/error.rs Adds frame-less four-domain and lifecycle/fatal carriers plus typed completion replay that preserves native roots and physical source chains.
doradb-storage/src/engine.rs Moves transaction configuration validation and normalized redo-prefix ownership to the public bootstrap boundary.
doradb-storage/src/runtime/mandatory.rs Keeps mandatory completion observation typed and preserves fatal errors during poison-aware admission.
doradb-storage/src/session.rs Replays mandatory completion failures into constrained carriers and discloses them at public session boundaries.
doradb-storage/src/trx/mod.rs Narrows transaction commit and rollback error propagation while retaining public disclosure at transaction APIs.
doradb-storage/src/trx/sys.rs Consumes validated transaction configuration and propagates commit completion failures through typed carriers.
doradb-storage/src/table/access.rs Replaces broad internal public-error convergence with narrower typed mutation results while retaining callback error transport.
doradb-storage/src/conf/trx.rs Introduces validated transaction configuration containing normalized settings and a resolved redo-file prefix.

Reviews (2): Last reviewed commit: "resolve task" | Re-trigger Greptile

@codecov

codecov Bot commented Aug 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.65217% with 86 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.49%. Comparing base (f4b2493) to head (a794d88).

Files with missing lines Patch % Lines
doradb-storage/src/error.rs 87.25% 45 Missing ⚠️
doradb-storage/src/session.rs 93.37% 11 Missing ⚠️
doradb-storage/src/engine.rs 95.53% 8 Missing ⚠️
doradb-storage/src/runtime/mandatory.rs 76.47% 8 Missing ⚠️
doradb-storage/src/table/access.rs 89.04% 8 Missing ⚠️
doradb-storage/src/trx/mod.rs 86.20% 4 Missing ⚠️
doradb-storage/src/trx/sys.rs 92.85% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #961      +/-   ##
==========================================
+ Coverage   93.47%   93.49%   +0.02%     
==========================================
  Files         154      154              
  Lines      131555   132064     +509     
==========================================
+ Hits       122967   123474     +507     
- Misses       8588     8590       +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
doradb-storage/src/trx/stmt.rs (1)

652-658: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Write-path disclosures lack the operation=/table_id= context that sibling read paths add.

table_insert_mvcc, table_upsert_unique_mvcc, table_update_unique_mvcc, and table_delete_unique_mvcc each call .disclose() directly on the result of the underlying mvcc method. table_scan_mvcc, table_lookup_unique_mvcc, table_index_lookup_mvcc, and table_index_scan_mvcc in the same file all add .attach_with(|| format!("operation={OPERATION}, table_id={table_id}...")) before .disclose().

Add the same attachment to the four write paths. Without it, a failure in the most frequent DML paths does not carry the operation name or table_id in its report, unlike every read path in this file.

🩹 Proposed fix for `table_insert_mvcc` (apply the equivalent change to the other three methods)
     table
         .accessor_with_layout(&layout)
         .insert_mvcc(rt, effects, cols)
         .await
+        .attach_with(|| format!("operation={OPERATION}, table_id={table_id}"))
         .disclose()
 }

Also applies to: 698-704, 743-749, 781-787

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@doradb-storage/src/trx/stmt.rs` around lines 652 - 658, Update
table_insert_mvcc, table_upsert_unique_mvcc, table_update_unique_mvcc, and
table_delete_unique_mvcc to attach the same operation and table_id context used
by the sibling read paths before calling disclose(). Preserve each underlying
MVCC call and add the attachment consistently to all four write-path error
reports.
🧹 Nitpick comments (1)
doradb-storage/src/session.rs (1)

1001-1007: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Repeated mandatory-completion disclosure pattern is a good extraction candidate.

Each of these ten sites repeats the same chain: observer.wait().await.map_err(|error| error.into_quad(RuntimeError::X)).attach_with(|| ...).disclose(). Only the RuntimeError variant and the attachment message differ.

Extract a small private helper that takes the CompletionResult, the RuntimeError context, and a closure producing the attachment message, then calls disclose() internally. This reduces the duplication without changing behavior.

♻️ Proposed helper to remove duplication
#[inline]
fn disclose_mandatory_completion<T>(
    result: CompletionResult<T>,
    context: RuntimeError,
    attachment: impl FnOnce() -> String,
) -> Result<T> {
    result
        .map_err(|error| error.into_quad(context))
        .attach_with(attachment)
        .disclose()
}

Then, for example, create_table becomes:

-        observer
-            .wait()
-            .await
-            .map_err(|error| error.into_quad(RuntimeError::CatalogAccess))
-            .attach("operation=create_table, phase=wait_mandatory_completion")
-            .disclose()
+        disclose_mandatory_completion(
+            observer.wait().await,
+            RuntimeError::CatalogAccess,
+            || "operation=create_table, phase=wait_mandatory_completion".to_owned(),
+        )

Also applies to: 1044-1060, 1090-1106, 1129-1138, 1166-1173, 1201-1208, 1236-1241, 1379-1388, 1419-1428, 1571-1580

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@doradb-storage/src/session.rs` around lines 1001 - 1007, Extract a private
helper such as disclose_mandatory_completion that accepts CompletionResult<T>, a
RuntimeError context, and an attachment-message closure, then performs the
existing map_err, attach_with, and disclose chain. Replace the repeated
mandatory-completion chains in the listed call sites, including create_table,
passing each site’s existing error variant and attachment message without
changing behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@doradb-storage/src/session.rs`:
- Around line 3287-3301: Update both poisoner.ensure_healthy() checks in
wait_for_maintenance_boundary, including the pre-listener check and
post-listener recheck, to attach the same boundary.name() and target_ts context
used by the adjacent shutdown error before propagating the
LifecycleOrFatalError.

---

Outside diff comments:
In `@doradb-storage/src/trx/stmt.rs`:
- Around line 652-658: Update table_insert_mvcc, table_upsert_unique_mvcc,
table_update_unique_mvcc, and table_delete_unique_mvcc to attach the same
operation and table_id context used by the sibling read paths before calling
disclose(). Preserve each underlying MVCC call and add the attachment
consistently to all four write-path error reports.

---

Nitpick comments:
In `@doradb-storage/src/session.rs`:
- Around line 1001-1007: Extract a private helper such as
disclose_mandatory_completion that accepts CompletionResult<T>, a RuntimeError
context, and an attachment-message closure, then performs the existing map_err,
attach_with, and disclose chain. Replace the repeated mandatory-completion
chains in the listed call sites, including create_table, passing each site’s
existing error variant and attachment message without changing behavior.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro Plus

Run ID: 02fcec8b-f32f-451c-b363-4313ef03eb97

📥 Commits

Reviewing files that changed from the base of the PR and between f4b2493 and 0d06ca1.

⛔ Files ignored due to path filters (5)
  • docs/error-spec.md is excluded by none and included by none
  • docs/process/coding-guidance.md is excluded by none and included by none
  • docs/public-error-audit.csv is excluded by !**/*.csv and included by none
  • docs/tasks/000263-introduce-quad-error-and-narrow-audited-error-convergence.md is excluded by none and included by none
  • docs/tasks/next-id is excluded by none and included by none
📒 Files selected for processing (15)
  • doradb-storage/src/catalog/index.rs
  • doradb-storage/src/catalog/table.rs
  • doradb-storage/src/conf/mod.rs
  • doradb-storage/src/conf/trx.rs
  • doradb-storage/src/engine.rs
  • doradb-storage/src/error.rs
  • doradb-storage/src/file/mod.rs
  • doradb-storage/src/log/mod.rs
  • doradb-storage/src/runtime/mandatory.rs
  • doradb-storage/src/session.rs
  • doradb-storage/src/table/access.rs
  • doradb-storage/src/trx/mod.rs
  • doradb-storage/src/trx/stmt.rs
  • doradb-storage/src/trx/stream_stmt.rs
  • doradb-storage/src/trx/sys.rs

Comment thread doradb-storage/src/session.rs
@jiangzhe
jiangzhe merged commit 916471d into main Aug 8, 2026
12 checks passed
@jiangzhe
jiangzhe deleted the narrow-quad-error branch August 8, 2026 06:53
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.

Task: Introduce QuadError and Narrow Audited Error Convergence

1 participant