Commit 776a58e
committed
Address PR 2230 review: non-blocking integrity_check + replica guard
Three fixes surfaced in code-review of PR 2230:
1. integrity_check (namespace/mod.rs):
Move the PRAGMA quick_check/integrity_check PRAGMA run from the
current Tokio worker onto the blocking thread pool via
spawn_blocking. On a large DB, integrity_check can take seconds
and would otherwise stall async tasks on that worker. Matches the
pattern already used for checkpoint() and vacuum_if_needed() on
LegacyConnection and for block_in_place in admin_shell.
2. reset_replication replica guard (namespace/store.rs):
Reject calls with 400 NotAPrimary unless db_kind is Primary. On a
replica, the ReplicaConfigurator does not consume .sentinel, so
the re-init path would not actually rebuild anything and we'd
destroy wallog/snapshots the replica still needs.
3. Async filesystem check (namespace/store.rs):
Replace sync Path::exists() with tokio::fs::try_exists to avoid
blocking the Tokio worker on a filesystem stat.
Also leaves a TODO comment on the string-based corruption
classification in the checkpoint error path — follow-up tracked to
replace it with typed rusqlite::ErrorCode matching (or a dedicated
Error::DatabaseCorrupt variant) once the Error enum plumbing is
updated.
Verified: cargo check clean, all 7 reset/integrity turmoil tests
pass (reset_replication_preserves_data_on_healthy_namespace,
reset_replication_on_nonexistent_namespace_returns_404,
reset_replication_is_idempotent,
reset_replication_response_includes_elapsed_ms,
integrity_check_on_healthy_namespace,
integrity_check_defaults_to_quick_when_full_omitted,
integrity_check_on_nonexistent_namespace_returns_404).1 parent d706429 commit 776a58e
2 files changed
Lines changed: 46 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
126 | 137 | | |
127 | 138 | | |
128 | 139 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
267 | 267 | | |
268 | 268 | | |
269 | 269 | | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
270 | 280 | | |
271 | 281 | | |
272 | 282 | | |
| |||
308 | 318 | | |
309 | 319 | | |
310 | 320 | | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
311 | 331 | | |
312 | 332 | | |
313 | 333 | | |
| |||
370 | 390 | | |
371 | 391 | | |
372 | 392 | | |
373 | | - | |
374 | | - | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
375 | 398 | | |
376 | 399 | | |
377 | 400 | | |
| |||
0 commit comments