maxmind / MaxMind-DB-Reader-java

Java reader for the MaxMind DB format
https://maxmind.github.io/MaxMind-DB-Reader-java/
Apache License 2.0
114 stars 43 forks source link

InvalidDatabaseException The MaxMind DB file's search tree is corrupt: contains pointer larger than the database. #87

Closed Aashima89 closed 3 years ago

Aashima89 commented 3 years ago

Hi, I am using maxmind reader to resolve ips but getting error on one of my EC2 containers. Though rest of them are able to read from the file successfully. Had a question on when do we see such error? I did go through the code but couldn't understand the reasoning of when such case can happen! This is how I am initializing the reader

final File mappingFile = new File(mappingFilePath.toString());
return new Reader(mappingFile, Reader.FileMode.MEMORY_MAPPED, NoCache.getInstance()));
oschwald commented 3 years ago

As the exception message suggests, it sounds like the file is corrupt.

Aashima89 commented 3 years ago

The other containers running parallely were able to access the file from the same mappingFilePath

oschwald commented 3 years ago

I am not really in a position to debug why the one container was different. That exception is thrown on an invalid database. Perhaps there is corruption that only affects a particular record or perhaps the file was being updated/written when the container opened it.

oschwald commented 3 years ago

Closing as there is not enough information in this issue to further debug it. Feel free to reopen with more details.

Aashima89 commented 3 years ago

Thanks @oschwald for addressing. Found out that the file was replaced from below and the reader was initialized with old file reference so on replacement it started throwing the above error