@kvas11 opened this Issue on November 19th 2021

Matomo downloads database file from https://download.db-ip.com every hour (same time as console archive job is executed) instead of scheduled period (week or month).

Expected Behavior

Matomo download geoip db on scheduled period week or month.

Current Behavior

Matomo download geoip db every hour.

Steps to Reproduce (for Bugs)

Setup automatic geo ip download for DBIP / GeoIP 2 (Php)

Your Environment

  • Matomo Version: 4.4.1
  • PHP Version: 7.4.3
  • Server Operating System: ubuntu 20.04
@sgiehl commented on November 19th 2021 Member

@kvas11 Thanks for creating this issue. I'll try to investigate this.
Are you able to see if the geoip database file in misc folder is actually updated?
Maybe it fails updating that file and fails silently and so tries to update it again with the next run

@kvas11 commented on November 19th 2021

You are probably right, the 'DBIP-City.mmdb' file was last changed at September 9 - probably due to lack of write file permissions. I just set the correct file permission to the user, who's cron is executing archive job and will let you now if something changed.

Thanks for the help

@sgiehl commented on November 19th 2021 Member

Ah, that might be a "typical" issue. If you set up GeoIP via the UI, it downloads the file with the webserver user. If your cron runs with another user, it might not be able to write the file...

@kvas11 commented on November 20th 2021

Sorry for the "false alarm", everything is OK now, Db file was correctly downloaded and the message in the UI says: "It is next scheduled to run on 2021-12-01".

Maybe some warning message about the errors during file update could be useful, similar like "System check" messages.

@sgiehl commented on November 20th 2021 Member

@kvas11 didn't the run of the scheduled task return an error or warning, that indicated that the file couldn't be written?

@kvas11 commented on November 21st 2021

No, I could not find any info/error/warning about failed db update process in matomo cron job log

@sgiehl commented on November 22nd 2021 Member

Just checked that locally, and when the file is not writable the task actually outputs this:

INFO [2021-11-22 17:11:01] 24193  Scheduler: executing task Piwik\Plugins\GeoIp2\GeoIP2AutoUpdater.update...
INFO [2021-11-22 17:11:01] 24193  Downloading https://download.db-ip.com/free/dbip-city-lite-2021-11.mmdb.gz to /srv/matomo/tmp/latest/DBIP-City.mmdb.gz.download.
INFO [2021-11-22 17:11:24] 24193  GeoIP2AutoUpdater: successfully downloaded 'https://download.db-ip.com/free/dbip-city-lite-2021-11.mmdb.gz'
WARNING [2021-11-22 17:11:25] 24193  /srv/matomo/plugins/GeoIp2/GeoIP2AutoUpdater.php(339): Warning - copy(/tmp/DBIP-City.mmdb): failed to open stream: Permission denied - Matomo 4.6.0-rc2 - Please report this message in the Matomo forums: https://forum.matomo.org (please do a search first as it might have been reported already)
INFO [2021-11-22 17:11:25] 24193  GeoIP2AutoUpdater: successfully updated GeoIP 2 database 'https://download.db-ip.com/free/dbip-city-lite-2021-11.mmdb.gz'

So for me, there is an error displayed

@kvas11 commented on November 22nd 2021

Stefan, you are right, when I fixed file/dir permissions, DB update process output was logged in cron log file. Now I would like to test it again with missing write permissions. How do I force GeoIP2AutoUpdater again in the next run? In Matomo UI, there are just 2 options (week, month).

@sgiehl commented on November 22nd 2021 Member

@kvas11 There should be a database record in option table with option_name = geoip2.updater_last_run_time. Setting that one to 0, should indicate the downloader when it was last updated.
Btw. You can also directly run the task using ./console scheduled-tasks:run "Piwik\Plugins\GeoIp2\GeoIP2AutoUpdater.update"

@kvas11 commented on November 22nd 2021

Stefan, it works like described in your comment above. I apologize for stealing your time. Please, close this issue.

@sgiehl commented on November 22nd 2021 Member

No problem. Good to hear it works as expected.

This Issue was closed on November 22nd 2021
Powered by GitHub Issue Mirror