Skip to content

Commit 4645452

Browse files
authored
feat: upgrade database to redb v3 compatible format (n0-computer#174)
## Description The recently released redb v3 has incompatible changes to the database format. The recommended upgrade procedure is to upgrade the database with `Database::upgrade` on redb v2.6+. The upgrade has to be done on redb v2, not v3. See https://github.com/cberner/redb/blob/master/CHANGELOG.md#removes-support-for-file-format-v2. This updates redb to 2.6 and performs the upgrade when opening the database. Calling upgrade on an already upgraded database is a no-op. With this merged in the next release, we can then update redb to v3 in the version after. ## Breaking Changes <!-- Optional, if there are any breaking changes document them, including how to migrate older code. --> ## Notes & open questions <!-- Any notes, remarks or open questions you have to make about the PR. --> ## Change checklist - [ ] Self-review. - [ ] Documentation updates following the [style guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text), if relevant. - [ ] Tests if relevant. - [ ] All breaking changes documented.
1 parent ac1e509 commit 4645452

File tree

5 files changed

+12
-7
lines changed

5 files changed

+12
-7
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ jobs:
204204
- uses: actions/checkout@v5
205205
- uses: dtolnay/rust-toolchain@master
206206
with:
207-
toolchain: nightly-2024-11-30
207+
toolchain: nightly-2025-09-28
208208
- name: Install sccache
209209
uses: mozilla-actions/[email protected]
210210

.github/workflows/docs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
- uses: actions/checkout@v5
3333
- uses: dtolnay/rust-toolchain@master
3434
with:
35-
toolchain: nightly-2024-11-30
35+
toolchain: nightly-2025-09-28
3636
- name: Install sccache
3737
uses: mozilla-actions/[email protected]
3838

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ genawaiter = { version = "0.99.1", features = ["futures03"] }
4242
iroh-base = "0.92"
4343
irpc = { version = "0.8.0", features = ["rpc", "quinn_endpoint_setup", "spans", "stream", "derive"], default-features = false }
4444
iroh-metrics = { version = "0.35" }
45-
redb = { version = "=2.4", optional = true }
45+
redb = { version = "2.6.3", optional = true }
4646
reflink-copy = { version = "0.1.24", optional = true }
4747

4848
[dev-dependencies]

src/store/fs/meta.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ mod proto;
3636
pub use proto::*;
3737
pub(crate) mod tables;
3838
use tables::{ReadOnlyTables, ReadableTables, Tables};
39-
use tracing::{debug, error, info_span, trace, Span};
39+
use tracing::{debug, error, info, info_span, trace, warn, Span};
4040

4141
use super::{
4242
delete_set::DeleteHandle,
@@ -475,13 +475,18 @@ impl Actor {
475475
options: BatchOptions,
476476
) -> anyhow::Result<Self> {
477477
debug!("creating or opening meta database at {}", db_path.display());
478-
let db = match redb::Database::create(db_path) {
478+
let mut db = match redb::Database::create(db_path) {
479479
Ok(db) => db,
480480
Err(DatabaseError::UpgradeRequired(1)) => {
481481
return Err(anyhow::anyhow!("migration from v1 no longer supported"));
482482
}
483483
Err(err) => return Err(err.into()),
484484
};
485+
match db.upgrade() {
486+
Ok(true) => info!("Database was upgraded to redb v3 compatible format"),
487+
Ok(false) => {}
488+
Err(err) => warn!("Database upgrade to redb v3 compatible format failed: {err:#}"),
489+
}
485490
let tx = db.begin_write()?;
486491
let ftx = ds.begin_write();
487492
Tables::new(&tx, &ftx)?;

0 commit comments

Comments
 (0)