Closed Daimon04 closed 2 years ago
Does this happen when the database is being updated or shortly thereafter? If so, how is the database being updated? If you are not replacing the file atomically, issues like this could occur.
Yes, you are right. This happens when the database is updated. To update we use the program https://github.com/maxmind/geoipupdate
geoipupdate
should replace the file atomically if the OS and file system support it. What OS and file system are you using?
OS: Ubuntu 20.04 File system: Ext4
Interesting. We have been using this on similar systems with similar loads and updated by geoipupdate
. We have never experienced a SIGBUS.
To confirm, this is a local file system, right? Network drives potentially could introduce issues with a mmap'd file.
Are you certain nothing but geoipupdate
is modifying the files while this is running? What version of geoipupdate
are you using?
I suppose a workaround that is not particularly satisfying is to load the database into memory rather than using a memory-mapped file. You can do this by using geoip2.FromBytes
instead of geoip2.Open
.
sorry for the long answer. geoipupdate version 4.6.0
"To confirm, this is a local file system, right" - yes, is a local file system
Your recommendation to use geoip2.FromBytes helped me, the error disappeared. Thank you very much.
Given that I am unable to reproduce this and it sounds like a mmap problem that is not specific to this library, I am going to close this issue.
The program crashed due to memory access violation. Stacktrace:
My code:
I have about 500 RPS, this crash happens 1-2 times a month on the production server. The DB file is updated 1 time per week. I tried to specifically reproduce this problem, but I did not succeed.