Closed garnould closed 3 weeks ago
Why not just read in the file and use FromBytes
instead of Open
?
Yes, modifying an opened mmap'd file will cause issues, but you shouldn't need to modify a file in the first place. If you are updating the database to a new version, I would suggest atomically replacing the file, which won't modify the existing mapped data.
Hi Gregory,
I completely missed the point I could use FromBytes() instead of Open(), which will do the job perfectly.
Sorry for this unusefull PR, and thank you for your work and this really helping answer :)
Closing this PR
Adding a build tag 'maxminddisablemmap' to force in-memory loaded database, even when mmap() is supported.
Maxmind database file content (ex: GeoIP2-Country.mmdb) being modified/updated 'on the fly' while it is opened by Reader with mmap() can lead to unexpected and catastrophic behaviour.
This patch modifies slightly "reader_memory.go" & "reader_mmap.go" to provide a way to disable mmap() usage in maxminddb-golang, using '-tags maxminddisablemmap' (ex: go run -tags maxminddisablemmap)