etix / mirrorbits

Mirrorbits is a geographical download redirector written in Go for distributing files efficiently across a set of mirrors.
MIT License
497 stars 90 forks source link

mirrorbits loses ability to use GeoIP after GeoLite update #93

Open stormi opened 5 years ago

stormi commented 5 years ago

Each time I update the GeoLite2-City.mmdb and GeoLite2-ASN.mmdb files, mirrorbits apparently immediately loses the ability to read them. Any subsequent ?mirrorlist request says We were not able to use your IP to approximate your location, so have chosen the mirrors at random..

Running mirrorbits reload solves it.

etix commented 5 years ago

Replacing the files on disk is enough to trigger the issue?

stormi commented 5 years ago

Yes, I simply copy the new files over the ones that are being used.

ott commented 1 year ago

Most likely, the database is changed in-place. I verified that maxminddb-golang opens the database with os.Open and keeps the file descriptor open. Therefore, the updater should unlink the current database, then write the new database to the path and finally mirrorbits reload should be called (perhaps triggered by a systemd path unit or a comparable mechanism).

@stormi Which updater are you using?

stormi commented 1 year ago

I'm not using an updater. I have a simple script that downloads the database and extracts it then copies files over the the ones known to mirrorbits. The point of this issue is that mirrorbits should ideally, without a manual reload, 1. detect that the database it has opened doesn't exist anymore 2. load the new file... Rather than silently losing any ability to query the database.