Intermittent archiving error

I’m getting emails from the archive cron that seem to be processing the data, but end with this notice:


Fatal error: 1 total errors during this script execution, please investigate and try and fix these errors. 
First error was: Got invalid response from API request: http://mysite.net/index.php?module=API&method=VisitsSummary.getVisits&idSite=8&period=month&date=last2&format=php&token_auth=nnnnnnnc&trigger=archivephp
The response was empty. 
This usually means a server error (for example, PHP reached the maximum memory_limit). 
Please check your Web server Error Log file for more detai in /piwik/misc/cron/archive.php on line 556

But there are no errors in the error log. Where else should I check to figure out what is causing this?

Also, I’ve been getting this error more frequently ever since the update to 1.8.3b6. Previously, I was getting it about once a week, but now I’ve received 4-5 notices in the past 18hrs.

When you open the URL manually in your browser, do you also see empty?

if you can please try update php as it might somehow be a php bug…
there should be something in the error log…

The error when I click on the link is:


Fatal error: Out of memory (allocated 256376832) (tried to allocate 262144 bytes) in /piwik/core/DataTable/Manager.php on line 121

So, it looks like the database is up to 248Mb, and the process is now hitting the 256Mb limit? Which is strange, because this error doesn’t happen every hour… maybe 3-4 times a day.

Also, from what I read in the Hostgator docs, I doesn’t look like I change this limit with the hosting account I have.

edit: the most 2 recent cron errors actually included the out of memory error, first time I’ve seen it in there, so I’m wondering what the other error might have been.

Since the archiving is being processed rather quickly, I’m going to change the auto-archiving to happen every 30 minutes instead of every hour, see if processing less data each time helps any.

Okay, changing that to every half hour didn’t help, only made things worse, now the archiving is failing all the time.

I had switched it back to manual archive processing, and it still cannot finish.

I had set things to delete old logs every 30 days, but it hasn’t quite been 30 days yet, and now I have no way to go into Settings and change that down to 28 or 21 days because I keep getting the Memory allocation error.

What do I need to manually cull from the mysql tables in order to get this operational again?

It seems that deleting old logs from the database doesn’t help, and I would need to delete old reports in order to be able to get Piwik to display stats again.

This is disappointing because it means that we can’t collect historical data more than 30 days… which was the point of me setting this up in the first place. It’s starting to look like I need to pay for a much more expensive hosting option, and that’s not possible at this time.

Is there anything I can do to get my stats working again, or do I have to scrap this entire project and go back to Google Analytics?

I remember someone having similiar problems, though his/her reports messed up with the daily-processing of Piwik-data mostly at night… I don’t recall it in detail, but try to set the cron to 2 hours, it should’ve the opposite effect of what you did: Less failures instead of more failures (as you set it to 30min).

So long,
A.Kalkhoff

Do you use 1.8.3 final ?

we recommend to setup as explained in the doc, every hour should be fine. try to set the Timeout to 3600 seconds at least in the UI (or 7200 or more). See: How to Set up Auto-Archiving of Your Reports - Analytics Platform - Matomo

Yes, I upgraded to 1.8.3 final.

Any kind of archiving at all will not complete because of the memory error, neither automatic or manual, so I cannot view any sort of analytics overviews, nor any at all for my higher traffic websites (10-20k per week).

Am waiting to see what happens with the cron set to every other hour…

Not sure what else to do, because the reports are going to keep generating, but if I cannot keep them more than a month, then Piwik isn’t the solution I can use on this hosting account, alas.

Increasing to 7200 did not help, and now all archiving is failing each time, both manual and cron (changed from intermittent to persistent), so I think I’ve reached the end of where I can use Piwik.

For my main website I’d only be able to keep one month’s worth of reports, and even if I removed that site, all of my other sites together would require me to remove reports after about 3-4 months, which also doesn’t fit the goals I was hoping for.

I do love this application, and please please keep up the good work. Maybe someday I’ll be able to come back to it. It’s a real shame I never got to try import that 25Gb access_log file :slight_smile:

your memory limit error is 24M which is way too small, please increase to at least 128M

Unless my math is off, that error says it cannot allocate that extra amount because it’s already allocated 244Mb, and the limit is set to 256Mb by the hosting server.

Yep, just used an online calculator. 256376832 bytes = 244.5 Mb

Note: We are working on a new code that will improve memory usage (in next release hopefully): "Ranking Query" to decrease archiving memory consumption and transfered data between MySQL and PHP · Issue #3330 · matomo-org/matomo · GitHub

How many visits/pageviews do you get per day, that 250M are not enough? please try increase to 512 or so, until we improve further piwik memory usage

At the time, I had 10 sites being tracked, for a total of maybe 15-20,000 visits per day.

When I was using version 1.8.2, the database was only at about 40-60Mb. WIthin a week of upgrading to 1.8.3, the database size jumped to 200Mb, and a few days after that I wasn’t able to use Piwik anymore.

The shared hosting package I have does not allow me to use more than 256Mb for PHP, and I confirmed that 256Mb setting with the phpinfo script in the Piwik install.

Would it be possible for me to downgrade to 1.8.2? Losing that fix for the missing sites that 1.8.3 fixed will be annoying, but it would be better than not being able to use the system at all.

I guess this is a constant archiving error now? :slight_smile:

I applied the patch you’d posted, but I’d also deleted many of the previous logs, so I think my August stats are going to be mostly useless, but if it can self-correct, that will be fine for moving forward.

One of the things I’d done to try to get archiving to work was remove some sites, so Site 4 and Site 6 don’t exist anymore.

Since applying the patch, here’s the error I’m receiving from the archive cron:


Notes
- Reports for today will be processed at most every 7200 seconds. You can change this value in Piwik UI > Settings > General Settings.
- Reports for the current week/month/year will be refreshed at most every 3600 seconds.
- Archiving was last executed without error 10 days 2 hours ago
Will process 8 websites with new visits since 10 days 2 hours , IDs: 1, 2, 3, 5, 7, 8, 9, 10
---------------------------
START
Starting Piwik reports archiving...
Archived website id = 1, period = day, Time elapsed: 0.760s
Archived website id = 1, period = week, 387 visits, Time elapsed: 0.405s
Archived website id = 1, period = month, 1590 visits, Time elapsed: 0.495s
Archived website id = 1, period = year, 1590 visits, Time elapsed: 0.336s
Archived website id = 2, period = day, Time elapsed: 0.284s
Archived website id = 2, period = week, 833 visits, Time elapsed: 0.375s
Archived website id = 2, period = month, 3531 visits, Time elapsed: 0.327s
Archived website id = 2, period = year, 3531 visits, Time elapsed: 0.306s
Archived website id = 3, period = day, Time elapsed: 0.259s
Archived website id = 3, period = week, 112 visits, Time elapsed: 0.264s
Archived website id = 3, period = month, 415 visits, Time elapsed: 0.317s
Archived website id = 3, period = year, 415 visits, Time elapsed: 0.278s
Archived website id = 5, period = day, Time elapsed: 0.263s
Archived website id = 5, period = week, 79 visits, Time elapsed: 0.259s
Archived website id = 5, period = month, 296 visits, Time elapsed: 0.280s
Archived website id = 5, period = year, 296 visits, Time elapsed: 0.298s
Archived website id = 7, period = day, Time elapsed: 0.251s
Archived website id = 7, period = week, 131 visits, Time elapsed: 0.254s
Archived website id = 7, period = month, 515 visits, Time elapsed: 0.334s
Archived website id = 7, period = year, 515 visits, Time elapsed: 0.286s
Archived website id = 8, period = day, Time elapsed: 0.259s
Archived website id = 8, period = week, 73396 visits, Time elapsed: 0.373s
ERROR: Got invalid response from API request: module=API&method=VisitsSummary.getVisits&idSite=8&period=month&date=last12&format=php&token_auth=blahblahblah&trigger=archivephp. Response was '<br />
<b>Fatal error</b>:  Out of memory (allocated 257949696) (tried to allocate 71 bytes) in <b>public_html/piwik/core/DataTable.php</b> on line <b>1071</b><br />
'
Archived website id = 8, period = month, 0 visits, Time elapsed: 22.981s
ERROR: Got invalid response from API request: module=API&method=VisitsSummary.getVisits&idSite=8&period=year&date=last12&format=php&token_auth=blahblahblah&trigger=archivephp. Response was '<br />
<b>Fatal error</b>:  Out of memory (allocated 257949696) (tried to allocate 32 bytes) in <b>public_html/piwik/core/DataTable.php</b> on line <b>1071</b><br />
'
Archived website id = 8, period = year, 0 visits, Time elapsed: 17.844s
Archived website id = 9, period = day, Time elapsed: 0.246s
Archived website id = 9, period = week, 14 visits, Time elapsed: 0.258s
Archived website id = 9, period = month, 90 visits, Time elapsed: 0.276s
Archived website id = 9, period = year, 90 visits, Time elapsed: 0.256s
Archived website id = 10, period = day, Time elapsed: 0.274s
Archived website id = 10, period = week, 31 visits, Time elapsed: 0.250s
Archived website id = 10, period = month, 61 visits, Time elapsed: 0.293s
Archived website id = 10, period = year, 61 visits, Time elapsed: 0.267s
Done archiving!
---------------------------
SUMMARY
Total daily visits archived: 304
Archived today's reports for 8 websites
Archived week/month/year for 8 websites.
Skipped 0 websites: no new visit since the last script execution
Skipped 0 websites day archiving: existing daily reports are less than 7200 seconds old
Skipped 0 websites week/month/year archiving: existing periods reports are less than 3600 seconds old
Total API requests: 32
done: 8/8 100%, 304 v, 8 wtoday, 8 wperiods, 32 req, 50220 ms, 2 errors. eg. 'Got invalid response from API request: module=API&method=VisitsSummary.getVisits&idSite=8&period=month&date=last12&format=php&token_auth=blahblahblah&trigger=archivephp. Response was '<br />
<b>Fatal error</b>:  Out of memory (allocated 257949696) (tried to allocate 71 bytes) in <b>public_html/piwik/core/DataTable.php</b>'
Time elapsed: 50.220s

My total database size is down to 70Mb again, but since I’m limited to 256Mb by the host, does this mean that I still won’t be able to process all of the outstanding data for Site 8, no matter what I try?

Please wait for next release, I hope this ticket will help you to run on 256M of memory: "Ranking Query" to decrease archiving memory consumption and transfered data between MySQL and PHP · Issue #3330 · matomo-org/matomo · GitHub

Meanwhile, is there a way to selectively choose to archive only one site at a time? I’d like to see if perhaps that might bring the memory usage down to where I can use Piwik again. Getting Site 8 alone to process might get rid of this error and allow normal cron archiving to proceed again.

Thanks!

The archive.php already processes each site separately in a different request.