meilisearch / heed

A fully typed LMDB wrapper with minimum overhead 🐦
https://docs.rs/heed
MIT License
569 stars 52 forks source link

Does the "database was previously opened with different types" error imply that the database might be corrupted? #210

Closed SatoKentaNayoro closed 1 year ago

SatoKentaNayoro commented 1 year ago

🙋 Does the database was previously opened with different types error imply that the database might be corrupted? When I exit the program, an error MDB_BAD_DBI: The specified DBI handle was closed/changed unexpectedly is thrown (likely during commit), and then every time I reopen and access this database, I see the database was previously opened with different types error. By the way, my original code didn't use env.prepare_for_closing().wait(); I'm not sure if that's the reason the exception occurs upon program exit. If the database is indeed corrupted, are there any effective methods for repairing it?🙏

SatoKentaNayoro commented 1 year ago

But when i using env.prepare_for_closing().wait() here, it blocks the exit.😂 Based on the wait,I seem to be unable to identify any remaining missed env at this point.

Kerollmops commented 1 year ago

Hey @hxuchen 👋

Heed keeps the type the databases were opened with e.g. Database<Str, SerdeJson<MyStruct>>. So, when you try to open a database from the same Env, you get this error. It doesn't mean there is corruption but that you tried opening a known database with another type, e.g. Database<U32, Str>.