Skip to content

fix(tauri): keep the retired SQLite copy complete and skip its preflight once native is authoritative - #2193

Merged
shm11C3 merged 1 commit into
developfrom
fix/native-retirement-wal-and-preflight
Sep 21, 2026
Merged

shm11C3 merged 1 commit into
developfrom
fix/native-retirement-wal-and-preflight

Conversation

@shm11C3

@shm11C3 shm11C3 commented Sep 21, 2026 •

Copy link
Copy Markdown
Owner

Summary

Follow-up to #2164, which merged while two of its review findings were still open. Both are small.

  • Do not ignore a failed WAL rename. retire_sqlite_source renamed the main file first and moved -wal/-shm best effort, then logged success regardless. A SQLite -wal can hold committed pages the main file lacks (normally only after a crash mid-write, since Core closes its pool after every operation), so the .retired recovery copy could be incomplete while looking complete. The write-ahead log now moves first, a failed move of the main file puts it back, and success is logged only when both moved. That order is also crash-safe: a process killed between the two renames leaves the source in place, and the next boot finishes the job. -shm stays best effort because SQLite rebuilds it. The rename is injected into a private retire_with so the rollback can be tested.
  • Gate the SQLite compatibility preflight on SQLite authority. check_db_compatibility opened the SQLite file in every state. With the native database authoritative, an unreadable or newer-schema recovery copy set db_error, so is_db_ok went false and the dispatch-backed producers did not start even though native adoption had succeeded. It is now gated on sqlite_source_is_authoritative, the same condition that already gates the migrations.

Nothing here is user-visible: release builds exclude duckdb-archive.

Related Issues

Refs #2135, #2164.

Type of Change

  • Bug fix (fix/ branch)
  • New feature (feat/ branch)
  • Refactoring (refactor/ branch)
  • Performance (perf/ branch)
  • Documentation (docs/ branch)
  • Dependencies update
  • Other (chore/ branch)

Screenshots / Videos

Not applicable.

Test Plan

  • cargo fmt --all -- --check
  • cargo clippy -p hardware_visualizer --all-targets -- -D warnings, with and without duckdb-archive
  • cargo test -p hardware_visualizer --features duckdb-archive --release --lib -- app::native_ --test-threads=1 (24 passed), including three new retirement tests: a failed main-file rename puts the log back, a failed log rename leaves everything in place, and a retirement interrupted after the log moved finishes on the next call
  • cargo test -p hardware_visualizer --features duckdb-archive --release --test native_dispatch_conversion --test native_dispatch_restart

Note for reviewers: CI runs cargo test -p hardware_visualizer without the feature, so none of the App's duckdb-archive tests, including these, run in CI today. They were run locally.

Checklist

  • Self-reviewed the code
  • Linting and formatting pass
  • Tests pass
  • No new warnings or errors

Summary by CodeRabbit

  • Bug Fixes
    • Native startup is no longer blocked by SQLite compatibility recovery errors when native storage is already authoritative.
    • Improved database retirement reliability by preserving the original source if a file move fails.
    • Recovery now restores supporting database files when an interruption occurs during retirement.
    • Supporting files are handled more safely after successful database retirement.

…ght once native is authoritative

Two review findings on #2164 that were still open when it merged. Retirement now treats the SQLite write-ahead log as part of the operation: it moves first, a failed move of the main file puts it back, and success is only logged when both moved, so the .retired recovery copy can no longer be silently incomplete. The order is also crash-safe, since a process killed between the two renames leaves the source in place for the next boot to finish. The SQLite compatibility preflight is gated on the same condition as the migrations, so an unreadable or newer-schema recovery copy cannot set db_error and stop the dispatch-backed producers on a native database that opened fine.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-21T17:50:03.468602Z 4b93dfa PR opened
🔒 Security Review ✅ Completed 2026-09-21T17:51:22.416376Z 4b93dfa PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Understand this PR’s impact

Explore downstream dependencies and potential security impact with Blast Radius.

View blast radius →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: shm11C3/HardwareVisualizer/.coderabbit.yml

Review profile: CHILL

Plan: Team

Run ID: 92369277-e151-464b-8f3a-4d1f0eda216d

📥 Commits

Reviewing files that changed from the base of the PR and between 1e538f3 and 4b93dfa.

📒 Files selected for processing (2)
  • src-tauri/src/app/native_maintenance.rs
  • src-tauri/src/lib.rs

Included review availability: 5 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 8 reviews per hour.


📝 Walkthrough

Walkthrough

SQLite source retirement now handles WAL and SHM sidecars during rename failures. Startup skips SQLite compatibility preflight when native storage is authoritative.

Changes

SQLite maintenance flow

Layer / File(s) Summary
WAL-aware source retirement
src-tauri/src/app/native_maintenance.rs
retire_sqlite_source uses an injectable rename workflow. It moves the WAL before the database, restores the WAL if the database move fails, and best-effort moves the SHM sidecar after success. Tests cover rename failures and interrupted retirement recovery.
Authority-gated startup preflight
src-tauri/src/lib.rs
run performs SQLite compatibility checks only when SQLite is authoritative. Native-authoritative startup leaves db_error unset.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 77.78% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes both main changes: preserving the retired SQLite copy and skipping SQLite preflight when native authority is selected.
Description check ✅ Passed The description follows the required template, explains the changes and rationale, lists related issues, identifies the change type, documents testing, and completes the checklist.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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

@github-actions github-actions Bot added change:fix PR: bug-fix branch work area:tauri Area: Tauri app, commands, app wiring, or bundling labels Sep 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Rust Tauri Coverage Report

Coverage Details
Filename                                             Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
_tests/commands/background_image_test.rs                  39                 0   100.00%           6                 0   100.00%          21                 0   100.00%           0                 0         -
_tests/commands/settings_test.rs                         265                 0   100.00%          21                 0   100.00%         207                 0   100.00%           0                 0         -
adapters/tray.rs                                         127               127     0.00%          14                14     0.00%          87                87     0.00%           0                 0         -
adapters/window.rs                                       601               114    81.03%          44                11    75.00%         515                79    84.66%           0                 0         -
app/database_availability.rs                               6                 6     0.00%           2                 2     0.00%           6                 6     0.00%           0                 0         -
app/startup.rs                                           188                87    53.72%          10                 3    70.00%         114                58    49.12%           0                 0         -
cli/mod.rs                                               155                18    88.39%          18                 0   100.00%         109                 9    91.74%           0                 0         -
commands/ambient_sensor.rs                                63                 5    92.06%           8                 3    62.50%          57                 8    85.96%           0                 0         -
commands/background_image.rs                              22                 7    68.18%          11                 5    54.55%          19                 7    63.16%           0                 0         -
commands/cooling_insight.rs                               63                63     0.00%          19                19     0.00%          65                65     0.00%           0                 0         -
commands/external_component_guidance.rs                   42                42     0.00%           9                 9     0.00%          45                45     0.00%           0                 0         -
commands/external_component_setup.rs                      41                41     0.00%          11                11     0.00%          35                35     0.00%           0                 0         -
commands/hardware.rs                                     400               339    15.25%          76                66    13.16%         328               288    12.20%           0                 0         -
commands/settings.rs                                     982               952     3.05%         157               154     1.91%         827               802     3.02%           0                 0         -
commands/system.rs                                        58                44    24.14%          18                15    16.67%          50                37    26.00%           0                 0         -
commands/ui.rs                                            17                17     0.00%           2                 2     0.00%          13                13     0.00%           0                 0         -
commands/updater.rs                                       97                97     0.00%          15                15     0.00%          66                66     0.00%           0                 0         -
enums/error.rs                                            91                 0   100.00%           7                 0   100.00%          76                 0   100.00%           0                 0         -
enums/hardware.rs                                        184                 3    98.37%          15                 0   100.00%         111                 2    98.20%           0                 0         -
enums/settings.rs                                        423                17    95.98%          27                 2    92.59%         279                10    96.42%           0                 0         -
infrastructure/database/migration.rs                     860                 0   100.00%          57                 0   100.00%         698                 0   100.00%           0                 0         -
infrastructure/database/migration_definitions.rs          32                 0   100.00%           2                 0   100.00%         474                 0   100.00%           0                 0         -
lib.rs                                                   396               396     0.00%          17                17     0.00%         270               270     0.00%           0                 0         -
lifecycle.rs                                             307               258    15.96%          35                31    11.43%         219               196    10.50%           0                 0         -
main.rs                                                    8                 8     0.00%           1                 1     0.00%           6                 6     0.00%           0                 0         -
models/archive_history.rs                                115                50    56.52%          10                 7    30.00%         116                58    50.00%           0                 0         -
models/cooling_insight.rs                               1089                34    96.88%          73                 3    95.89%        1098                35    96.81%           0                 0         -
models/environmental_sensors.rs                           52                 0   100.00%           6                 0   100.00%          45                 0   100.00%           0                 0         -
models/external_component_guidance.rs                     60                 4    93.33%           6                 0   100.00%          52                 4    92.31%           0                 0         -
models/external_component_setup.rs                       187                23    87.70%          13                 1    92.31%         156                20    87.18%           0                 0         -
models/hardware.rs                                       481                 3    99.38%          24                 0   100.00%         343                 3    99.13%           0                 0         -
models/hardware_archive.rs                                 8                 0   100.00%           2                 0   100.00%          10                 0   100.00%           0                 0         -
models/settings.rs                                       381                 0   100.00%          21                 0   100.00%         351                 0   100.00%           0                 0         -
models/storage_health.rs                                   7                 0   100.00%           2                 0   100.00%           9                 0   100.00%           0                 0         -
services/archive_history_service.rs                       65                65     0.00%          21                21     0.00%         101               101     0.00%           0                 0         -
services/background_image_service.rs                     208               128    38.46%          21                10    52.38%         115                71    38.26%           0                 0         -
services/cooling_insight_service.rs                       40                40     0.00%          18                18     0.00%          46                46     0.00%           0                 0         -
services/external_component_guidance_service.rs          187                16    91.44%          18                 1    94.44%         120                11    90.83%           0                 0         -
services/external_component_setup_service.rs             167                57    65.87%          17                 5    70.59%         106                32    69.81%           0                 0         -
services/gpu_service.rs                                   45                45     0.00%           7                 7     0.00%          33                33     0.00%           0                 0         -
services/hardware_service.rs                             210               123    41.43%          28                12    57.14%         161                94    41.61%           0                 0         -
services/language_service.rs                             149                 0   100.00%          24                 0   100.00%          87                 0   100.00%           0                 0         -
services/memory_service.rs                                 9                 9     0.00%           2                 2     0.00%           5                 5     0.00%           0                 0         -
services/motherboard_service.rs                            9                 9     0.00%           2                 2     0.00%           5                 5     0.00%           0                 0         -
services/network_service.rs                               34                13    61.76%           4                 1    75.00%          23                 6    73.91%           0                 0         -
services/settings_service.rs                             861               231    73.17%          92                28    69.57%         699               205    70.67%           0                 0         -
services/system_service.rs                                57                57     0.00%           7                 7     0.00%          40                40     0.00%           0                 0         -
services/ui_service.rs                                    45                45     0.00%           8                 8     0.00%          36                36     0.00%           0                 0         -
tray/surface/mod.rs                                        8                 8     0.00%           2                 2     0.00%           5                 5     0.00%           0                 0         -
tray/surface/tauri_surface.rs                             80                80     0.00%           6                 6     0.00%          48                48     0.00%           0                 0         -
tray/widget.rs                                           610                 5    99.18%          51                 1    98.04%         542                 3    99.45%           0                 0         -
utils/color.rs                                            66                 1    98.48%           4                 0   100.00%          26                 0   100.00%           0                 0         -
utils/file.rs                                            224                 5    97.77%          14                 0   100.00%         144                 4    97.22%           0                 0         -
utils/formatter.rs                                        55                 0   100.00%           5                 0   100.00%          39                 0   100.00%           0                 0         -
utils/logger.rs                                           71                71     0.00%           1                 1     0.00%          38                38     0.00%           0                 0         -
utils/tauri.rs                                           311                22    92.93%          42                 1    97.62%         195                14    92.82%           0                 0         -
webview_memory.rs                                         20                20     0.00%           4                 4     0.00%          13                13     0.00%           0                 0         -
workers/mod.rs                                            64                64     0.00%           2                 2     0.00%          36                36     0.00%           0                 0         -
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                                  11442              3869    66.19%        1159               530    54.27%        9540              3055    67.98%           0                 0         -

@github-actions

Copy link
Copy Markdown
Contributor

CI telemetry

Commit 4b93dfa · updated 2026-09-21 17:53 UTC

Workflow Result Wall time Longest queue Jobs
CI ✅ success 6m 20s 12s 14
PR Branch Name ✅ success 19s 13s 1
CodeQL Advanced ⏳ in progress – – –
CI · 14 jobs · 11 skipped
Job Result Queue Duration CPU avg / p95 Mem peak Disk peak Caches
test-e2e-native ✅ 2s 5m 05s 66% / 100% · 2.6/4T
T 66 · 69 · 64 · 65
3.0 / 15.6 GiB 67 / 145 GiB target exact · npm exact
test-build (windows-latest) ✅ 3s 4m 11s 47% / 90% · 1.9/4T
T 44 · 47 · 53 · 45
4.7 / 16.0 GiB 6 / 220 GiB target exact · sccache Rust 90% (525/582) · C/C++ n/a
lint-tauri (windows-latest) ✅ 2s 3m 26s 38% / 78% · 1.5/4T
T 40 · 32 · 47 · 35
7.1 / 16.0 GiB 15 / 150 GiB target exact · sccache Rust n/a · C/C++ n/a
test-tauri (windows-latest) ✅ 2s 3m 11s 38% / 99% · 1.5/4T
T 39 · 33 · 45 · 35
6.2 / 16.0 GiB 10 / 150 GiB target exact · sccache Rust 100% (1/1) · C/C++ n/a
test-build (ubuntu-22.04) ✅ 2s 2m 29s 32% / 53% · 1.3/4T
T 28 · 30 · 39 · 30
2.6 / 15.6 GiB 65 / 145 GiB target exact · sccache Rust 100% (630/630) · C/C++ 100% (17/17)
test-build (macos-latest) ✅ 6s 2m 22s 70% / 89% · 2.1/3T
T 74 · 68 · 66
4.5 / 7.0 GiB 230 / 320 GiB target exact · sccache Rust 100% (569/569) · C/C++ 100% (15/15)
test-tauri (ubuntu-22.04) ✅ 2s 2m 05s 29% / 64% · 1.2/4T
T 32 · 29 · 31 · 23
2.4 / 15.6 GiB 68 / 145 GiB target exact · sccache Rust 100% (1/1) · C/C++ n/a
lint-tauri (macos-latest) ✅ 10s 1m 53s 81% / 99% · 2.4/3T
T 84 · 81 · 79
4.2 / 7.0 GiB 234 / 320 GiB target exact · sccache Rust n/a · C/C++ n/a
lint-tauri (ubuntu-22.04) ✅ 2s 1m 49s 29% / 50% · 1.2/4T
T 25 · 33 · 28 · 29
2.0 / 15.6 GiB 72 / 145 GiB target exact · sccache Rust n/a · C/C++ n/a
test-tauri (macos-latest) ✅ 9s 1m 43s 79% / 99% · 2.4/3T
T 82 · 79 · 77
4.2 / 7.0 GiB 229 / 320 GiB target exact · sccache Rust 100% (1/1) · C/C++ n/a
check-tauri-bindings ✅ 2s 1m 38s 28% / 66% · 1.1/4T
T 24 · 30 · 28 · 32
2.3 / 15.6 GiB 66 / 145 GiB target exact · sccache Rust 100% (1/1) · C/C++ n/a
change-detection ✅ 9s 25s – – – –
Merge Gate ✅ 12s 25s – – – –
rust-format ✅ 2s 16s 30% / 32% · 1.2/4T
T 35 · 59 · 16 · 9
1.2 / 15.6 GiB 59 / 144 GiB –

Slowest steps

Step Duration
test-e2e-native › Run native E2E smoke 3m 59s
test-build (windows-latest) › Build Tauri Rust crate (CI optimized for PR) 2m 46s
lint-tauri (windows-latest) › Setup Rust 1m 41s
test-build (macos-latest) › Build Tauri Rust crate (CI optimized for PR) 1m 36s
test-tauri (windows-latest) › Run Tauri tests 1m 34s

Generated by the CI telemetry workflow from the GitHub API and job log markers. Queue = time from job creation to start. N/MT = average busy threads of M logical CPUs; T = per-thread average %.

@shm11C3
shm11C3 merged commit 0504d2b into develop Sep 21, 2026
37 checks passed
@shm11C3
shm11C3 deleted the fix/native-retirement-wal-and-preflight branch September 21, 2026 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:tauri Area: Tauri app, commands, app wiring, or bundling change:fix PR: bug-fix branch work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant