[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: MDB_INVALID: File is not an LMDB file



Hi,

On Wed, May 30, 2018 at 11:10:41AM -0400, Chris Trenkamp wrote:
> My program suddenly started returning this error, "MDB_INVALID: File
> is not an LMDB file" whenever it tries to open the database file.  It
> is running on Windows.
> 
> I made a copy of the database, compiled lmdb with MDB_DEBUG set to 2
> and ran this program:
> 
> #include <stdio.h>
> #include "lmdb.h"
> 
> int main(int argc, char* argv[]) {
>   int rc;
>   MDB_env *env;
>   rc = mdb_env_create(&env);
>   printf("%d\n", rc);
>   rc = mdb_env_open(env, "./brokedb", 0, 0644);
>   printf("%d\n", rc);
> }
> 
> And it gave this output:
> 0
> mdb_env_read_header:4040 page 0 not a meta page
> -30793
> 
> Does anyone know how this might have happened, and things to look for
> in my program that might have caused this?  Is there a way to recover
> the data from the file?

I think you should use this form of mdb_env_open:

mdb_env_open(env, "./brokedb", MDB_WRITEMAP | MDB_NOSUBDIR, 0664);

see:

http://www.lmdb.tech/doc/group__mdb.html
CTRL-F - mdb_env_open -> parameters -> flags



Regards,


a.