Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matomo ignore month/week scheduler for geolocation database update #18353

Closed
kvas11 opened this issue Nov 19, 2021 · 11 comments
Closed

Matomo ignore month/week scheduler for geolocation database update #18353

kvas11 opened this issue Nov 19, 2021 · 11 comments
Labels
worksforme The issue cannot be reproduced and things work as intended.

Comments

@kvas11
Copy link

kvas11 commented Nov 19, 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
@kvas11 kvas11 added the Potential Bug Something that might be a bug, but needs validation and confirmation it can be reproduced. label Nov 19, 2021
@sgiehl
Copy link
Member

sgiehl commented Nov 19, 2021

@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
Copy link
Author

kvas11 commented Nov 19, 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
Copy link
Member

sgiehl commented Nov 19, 2021

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
Copy link
Author

kvas11 commented Nov 20, 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
Copy link
Member

sgiehl commented Nov 20, 2021

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

@kvas11
Copy link
Author

kvas11 commented Nov 21, 2021

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

@sgiehl
Copy link
Member

sgiehl commented Nov 22, 2021

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
Copy link
Author

kvas11 commented Nov 22, 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
Copy link
Member

sgiehl commented Nov 22, 2021

@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
Copy link
Author

kvas11 commented Nov 22, 2021

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

@sgiehl
Copy link
Member

sgiehl commented Nov 22, 2021

No problem. Good to hear it works as expected.

@sgiehl sgiehl closed this as completed Nov 22, 2021
@sgiehl sgiehl added worksforme The issue cannot be reproduced and things work as intended. and removed Potential Bug Something that might be a bug, but needs validation and confirmation it can be reproduced. labels Nov 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
worksforme The issue cannot be reproduced and things work as intended.
Projects
None yet
Development

No branches or pull requests

2 participants