bevy_pkv
bevy_pkv copied to clipboard
Failed to init key value store: UpgradeRequired(1) after upgrading from 0.11 to 0.12
I was using 0.11 with my bevy game. Now after upgrading to 0.12 I got the following error
thread 'main' panicked at /Users/[...]/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_pkv-0.12.0/src/redb_store.rs:82:44:
Failed to init key value store: UpgradeRequired(1)
The error cause the game panic. It would be better to auto upgrade the store file, or let the client to decide how to deal with the error.
+1 also ran into this, in the long term it'd be nice to be able to gracefully handle but for now even being able to just catch the error and delete + recreate the store (losing all data) would be nice
I've also encountered this,
couldn't reset the database by calling PkvStore::new("...", "..").pkv.clear(); either.
The only way I managed to resolve this is to delete the config file.
The actual location is by https://github.com/johanhelsing/bevy_pkv/blob/cb931e683b5eaf2bcd287124b90c31d8713f15ce/src/lib.rs#L88 https://github.com/johanhelsing/bevy_pkv/blob/cb931e683b5eaf2bcd287124b90c31d8713f15ce/src/path.rs#L9
I also digged into the latest repo, I suppose that is the one used, and on linux the following logic builds up the path:
https://codeberg.org/dirs/directories-rs/src/commit/66be8f092d618407a193ef9565d0ade9f0df3ae6/src/lin.rs#L69
which is using https://docs.rs/directories/latest/directories/struct.ProjectDirs.html
Iit follows operation system standards, and I found the one on linux: ~/.local/share
And the folder with the name of the project inside!
Once I deleted the file, the application ran normally with an empty database.
In case the data needs to be kept, it is stored in this format: https://github.com/cberner/redb/blob/master/docs/design.md
A bit unsure what would be the best approach here
Probably not everyone would want to delete data.
I guess maybe a config option on the plugin with what to do on failures would be nice.
Or maybe log an error and move it?
If it doesn't affect functionality I wouldn't panic on it, just log it and move it upwards.