erthink / libmdbx

One of the fastest embeddable key-value ACID database without WAL. libmdbx surpasses the legendary LMDB in terms of reliability, features and performance.
https://erthink.github.io/libmdbx/
Other
1.16k stars 110 forks source link

Switch down from mdbx v0.10.5 to v0.10.1 caused error #238

Closed AskAlexSharov closed 2 years ago

AskAlexSharov commented 2 years ago

In next scenario:

db 40Kb: db.zip

I can reproduce it easily.

(FYI: i used a bit patched v0.10.1 - to increase MDBX_READERS_LIMIT: https://github.com/torquem-ch/mdbx-go/compare/v0.19.0...v0.19.2)

erthink commented 2 years ago

This is not a bug, but the feature...

Unfortunately, the v0.10.5 accidentally comes not full-compatible with previous releases:

This cannot be fixed, as it requires fixing past versions, which as a result we will get already existing v0.10.5. however, there are problems with the numbering of version 0.10.5, because if compatibility is broken, then it should be designated as v0.11.0 - I'll think about what to do.

erthink commented 2 years ago

At a whole this gave a false-positive diagnosis of database corruption - I'll think about what to do.

@AskAlexSharov, any ideas are welcome.

AskAlexSharov commented 2 years ago
  1. If it’s not corruption - Is it possible to auto-recover such db if v0.10.5 used? (I mean: create db by v0.10.5, switch to v0.10.1 will fail, switch back to v0.10.5 will recover)?
  2. Can I do this from APP side?
  3. Why v0.10.1 fail only on second opening of db (works after first opening)?
  4. My app has logic of db schema versioning - i can increase major version there and downgraded APP will reject to start. But, it also storing version inside db, and will open db to read it :-) probably I need store mdbx schema version outside of mdbx.
  5. Maybe mdbx can do same logic: If db created/last-used by major version X, then mdbx of major version < X can reject to open/update it?
  6. I have db which can't recover by v0.10.5 mdbx_chk. I did mdbx_chk -v -0 -t -w and got = Performing turn to the specified meta-page (0) due to successful check!, but can't open this db by v0.10.5. Kind of "false-positive".
erthink commented 2 years ago

Basically, seems just the single solution - don't mix new and old versions since shit bugs happens.

AskAlexSharov commented 2 years ago

How? (I mean - we don't control our installations, users can downgrade us). By storing last used MDBX version outside of mdbx and check it before open db?

erthink commented 2 years ago

I will change the DB format' signature and release version 0.11:

AskAlexSharov commented 2 years ago

love it

erthink commented 2 years ago

https://github.com/erthink/libmdbx/tree/v0.11.0

AskAlexSharov commented 2 years ago

Looks like signature update doesn't happen when switching to new version

erthink commented 2 years ago

Sorry, I didn't finish the work but I closed this issue by mistake.

AskAlexSharov commented 2 years ago

it works