Skip to content

refactor(storage): db switch to readonly mode when save failed#13584

Merged
jerrykingxyz merged 1 commit intomainfrom
jerry/storage
Apr 2, 2026
Merged

refactor(storage): db switch to readonly mode when save failed#13584
jerrykingxyz merged 1 commit intomainfrom
jerry/storage

Conversation

@jerrykingxyz
Copy link
Copy Markdown
Contributor

@jerrykingxyz jerrykingxyz commented Apr 2, 2026

Summary

  • If the database fails to save data, the data will be rollback and the database will be switched to readonly mode to protect the database data security and prevent data loss due to incremental save logic.

Related links

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

@jerrykingxyz jerrykingxyz requested a review from hardfist as a code owner April 2, 2026 06:45
Copilot AI review requested due to automatic review settings April 2, 2026 06:45
@github-actions github-actions Bot added release: refactor team The issue/pr is created by the member of Rspack. labels Apr 2, 2026
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: c05771b1af

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread crates/rspack_storage/src/filesystem/db/mod.rs
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Refactors the persistent storage transaction layer to improve crash recovery behavior and introduces a “readonly mode” that disables further cache writes after a save failure. It also extends the Node/Rust filesystem bridge to support cp so transactions can copy staged files into the committed store.

Changes:

  • Add cp support across the JS filesystem adapters, NAPI typings, and Rust NodeFileSystem binding.
  • Replace scoped “move” with “copy” for committing staged transaction files, and add Transaction::ensure_committed() for recovery.
  • Update DB save flow to rollback on per-bucket save failures and switch DB into readonly mode on save failure.

Reviewed changes

Copilot reviewed 12 out of 13 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/rspack/src/util/fs.ts Extends intermediate FS extra typings with cp.
packages/rspack/src/FileSystem.ts Wires fs.cp into ThreadsafeIntermediateNodeFS and NOOP FS.
crates/rspack_storage/src/filesystem/scope_fs.rs Replaces move_to with copy_to and updates tests accordingly.
crates/rspack_storage/src/filesystem/db/transaction/mod.rs Splits crash recovery into ensure_committed, changes commit to copy, adds rollback.
crates/rspack_storage/src/filesystem/db/mod.rs Adds recovery call on load and readonly mode on save failures.
crates/rspack_storage/src/filesystem/db/bucket/pack/generator.rs Generalizes extend to accept any iterator.
crates/rspack_storage/src/filesystem/db/bucket/mod.rs Simplifies pack generation using iterator-based extend.
crates/rspack_fs/src/native_fs.rs Updates IntermediateFileSystemExtras implementation from rename→copy.
crates/rspack_fs/src/memory_fs.rs Implements copy semantics for the in-memory filesystem.
crates/rspack_fs/src/intermediate.rs Changes IntermediateFileSystemExtras API from rename to copy.
crates/rspack_binding_api/src/fs_node/write.rs Routes Rust-side copy to JS-side cp threadsafe function.
crates/rspack_binding_api/src/fs_node/node.rs Adds cp to the ThreadsafeNodeFS napi object.
crates/node_binding/napi-binding.d.ts Exposes cp in the generated TypeScript definitions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread crates/rspack_storage/src/filesystem/db/mod.rs
Comment thread crates/rspack_storage/src/filesystem/db/transaction/mod.rs
Comment thread packages/rspack/src/FileSystem.ts Outdated
Comment thread crates/rspack_storage/src/filesystem/scope_fs.rs Outdated
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 2, 2026

Merging this PR will not alter performance

✅ 9 untouched benchmarks
⏩ 26 skipped benchmarks1


Comparing jerry/storage (7c418d3) with main (713b798)

Open in CodSpeed

Footnotes

  1. 26 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 2, 2026

Rsdoctor Bundle Diff Analysis

Found 5 projects in monorepo, 0 projects with changes.

📊 Quick Summary
Project Total Size Change
react-10k 5.7 MB 0
react-1k 826.3 KB 0
react-5k 2.7 MB 0
rome 984.2 KB 0
ui-components 2.3 MB 0

Generated by Rsdoctor GitHub Action

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 2, 2026

📦 Binary Size-limit

Comparing 7c418d3 to refactor(watcher): clean up stale entries from watch_patterns after unwatch (#13511) by Lee Jaeha / Adam

🎉 Size decreased by 1.84KB from 49.09MB to 49.09MB (⬇️0.00%)

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 2, 2026

⏳ Triggered benchmark: Open

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread crates/rspack_storage/src/filesystem/db/transaction/mod.rs
Comment thread crates/rspack_storage/src/filesystem/db/transaction/mod.rs
Comment thread crates/rspack_storage/src/filesystem/db/transaction/mod.rs
Comment thread crates/rspack_storage/src/filesystem/db/transaction/mod.rs
Comment thread crates/rspack_storage/src/filesystem/db/mod.rs
Comment thread crates/rspack_storage/src/filesystem/db/mod.rs
@jerrykingxyz jerrykingxyz merged commit 619d007 into main Apr 2, 2026
55 of 57 checks passed
@jerrykingxyz jerrykingxyz deleted the jerry/storage branch April 2, 2026 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release: refactor team The issue/pr is created by the member of Rspack.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants