Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update redb to v2 #2120

Merged
merged 17 commits into from
Apr 9, 2024
Merged

feat: update redb to v2 #2120

merged 17 commits into from
Apr 9, 2024

Conversation

Frando
Copy link
Member

@Frando Frando commented Mar 23, 2024

Description

redb 2.0.0 was released: https://github.com/cberner/redb/releases/tag/v2.0.0

most relevant for us:

2.0.0 uses a new file format that optimizes len() to be constant time. This means that it is not backwards compatible with 1.x. To upgrade, consider using a pattern like that shown in the upgrade_v1_to_v2 test.

and some nice API changes that will simplify the iroh-sync codebase (no more ouroboros for self-refential structs needed!)

  • Remove lifetimes from read-only tables
  • Remove lifetime from WriteTransaction and ReadTransaction

and some further API changes, see the notes.


  • Update iroh-bytes to redb v2
    • Did some crude search&replaces to remove now unneeded lifetime bounds. Compiles now, let's see what test says.
  • Migration for iroh-bytes db
  • Update iroh-sync to redb v2
    • This will be a bit more involved as iroh-bytes because we hit more API changes, but also great because we can remove ouroborous because iterators can now own a range
  • Migration for iroh-sync db

The migrations likely need a dependency to redb v1 to read the old database, so at least for one release cycle we'll have to depend on both redb v2 and v1.

Notes & open questions

This currently includes an extra-safeguard by preserving the old databases for sync and blobs as docs.redb.backup-redb-v1 and blobs.db-backup-redb-v1 - do we want this or delete the backups after successfull migration?

Change checklist

  • Self-review.
  • Documentation updates if relevant.
  • Tests if relevant.

@Frando Frando changed the title deps: update redb to v2 in iroh-bytes and iroh-base deps: update redb to v2 Mar 23, 2024
@Frando Frando requested a review from rklaehn March 26, 2024 10:44
let rtx = old_db.begin_read()?;
let wtx = new_db.begin_write()?;

migrate_table!(rtx, wtx, old::AUTHORS_TABLE, new::AUTHORS_TABLE);
Copy link
Contributor

Choose a reason for hiding this comment

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

why not a function?

Copy link
Member Author

@Frando Frando Mar 27, 2024

Choose a reason for hiding this comment

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

I failed to get the quite complex, nested generics right, and the macro doesn't need these.

@rklaehn
Copy link
Contributor

rklaehn commented Mar 28, 2024

FYI I tried this out locally, works fine except that now my store is stuck on 2.0 :-)

@rklaehn
Copy link
Contributor

rklaehn commented Mar 28, 2024

We should probably wait a bit more with merging this in case there are some issues with redb v2. One week or so?

@dignifiedquire dignifiedquire added this to the v0.14.0 milestone Apr 2, 2024
@Frando
Copy link
Member Author

Frando commented Apr 4, 2024

I'm wondering - would this also be a good time to remove old db migrations in iroh-sync, and panic with a message like "You need to update to iroh v0.12 before updating to v0.13"?

@dignifiedquire
Copy link
Contributor

I'm wondering - would this also be a good time to remove old db migrations in iroh-sync, and panic with a message like "You need to update to iroh v0.12 before updating to v0.13"?

seems reasonable

let (key, values) = entry?;
let key = key.value();
if i > 0 && i % 1000 == 0 {
info!(" {name} {i:>ind$}/{len}");
Copy link
Contributor

Choose a reason for hiding this comment

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

Screenshot 2024-04-04 at 17 05 04

Dunno how it is supposed to work, but it looks like this

@rklaehn
Copy link
Contributor

rklaehn commented Apr 8, 2024

I looked at redb issues. Nothing was opened in the last week, and also no closed issues related to the 1.0 -> 2.0 transition. So maybe now is time to merge it?

@dignifiedquire dignifiedquire changed the title deps: update redb to v2 feat: update redb to v2 Apr 9, 2024
@dignifiedquire dignifiedquire added this pull request to the merge queue Apr 9, 2024
Merged via the queue into main with commit ceaf168 Apr 9, 2024
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

4 participants