My archive cronjob always breaks for a specific tracked URL. In DataTable.php I found that function unserializeRows (line 1465) always evaluates $rows to false, i.e throws “The unserialization has failed!” even if there is a regular looking array.
Testing archivephp with other tracked URLs returns regular json:
{“idarchives”:[296176],“nb_visits”:1166}
I used the following console command for testing archivephp:
/usr/bin/php /var/www/piwik/console climulti:request --matomo-domain=“https://xxx” --superuser “module=API&method=CoreAdminHome.archiveReports&idSite=58&period=year&date=2024-01-01&format=json&trigger=archivephp”
I already tried increasing memory and max_execution. I am working with Matomo 5.1.2 and php 8.3; charset for all table is utf8m4 and collation utf8mb4_general_ci.
Has anyone an idea where to check more for the error?
Thank you
Hi @mucctecc
In my case, to increase archiving process resilience, I limited the number of sites being archived in one archiving process thanks to max-websites-to-process
parameter:
Dear Philippe,
thank you for your hint. I already tried using max-values-to-process with different values, I also tried the concurrent options with different values, e.g.
/usr/bin/php -d memory_limit=20G -d max_execution_time=0 /var/www/piwik/console core:archive --concurrent-requests-per-website=1 --concurrent-archivers=1 --url=https://xxx
That doesn’t work either. It is this unserialization error in core/DataTable.php, I checked the charset and the collation of the tables, they are as defined in config.ini.php.
Hi @mucctecc
For which kind of archive do you encounter the issue? daily, weekly, monthly, yearly? Specific defined period? (check the cron log)
What is the daily tracking volume? How many segments? How many installed Matomo plugins?
Can you see some errors in the Matomo error log file?
Hi Philippe,
thank you for your help!
-
kind of archive: yearly
-
daily tracking volume:
Visits Overview 02 - 04 Dezember 2024
10,922 visits, 7,239 unique visitors -64.9%
5 min 12s average visit duration -8%
23% visits have bounced (left the website after one page) -4.2%
5.8 actions (page views, downloads, outlinks and internal site searches) per visit -1.7%
230 max actions in one visit -36.8%
54,361 pageviews, 41,723 unique pageviews -65.8%
150 total searches on your website, 77 unique keywords -67.1%
53 downloads, 49 unique downloads -70.4%
8,358 outlinks, 7,610 unique outlinks -65.1%
-
segments: no segments defined (as far as I see as an admin)
-
installed Matomo plugins: about 50 activated plugins
-
Matomo error log file:
INFO [2024-11-22 07:30:39] 1236 Error: Got invalid response from API request: ?module=API&method=CoreAdminHome.archiveReports&idSite=59&period=year&date=2024-01-01&format=json&trigger=archivephp. Response was ‘{“result”:“error”,“message”:"The unserialization has failed! - in plugin Actions. #0 /var/www/dbuser/core/ArchiveProcessor/Loader.php(317): Piwik\ArchiveProcessor\PluginsArchiver->callAggregateAllPlugins() #1 /var/www/dbuser/core/ArchiveProcessor/Loader.php(186): Piwik\ArchiveProcessor\Loader->prepareAllPluginsArchive() #2 /var/www/dbuser/core/ArchiveProcessor/Loader.php(165): Piwik\ArchiveProcessor\Loader->insertArchiveData() #3 /var/www/dbuser/core/ArchiveProcessor/Loader.php(105): Piwik\ArchiveProcessor\Loader->prepareArchiveImpl() #4 /var/www/dbuser/core/Context.php(76): Piwik\ArchiveProcessor\Loader->Piwik\ArchiveProcessor\{closure}() #5 /var/www/dbuser/core/ArchiveProcessor/Loader.php(102): Piwik\Context::changeIdSite() #6 /var/www/dbuser/plugins/CoreAdminHome/API.php(306): Piwik\ArchiveProcessor\Loader->prepareArchive() #7 [internal function]: Piwik\Plugins\CoreAdminHome\API->archiveReports() #8 /var/www/dbuser/core/API/Proxy.php(255): call_user_func_array() #9 /var/www/dbuser/core/Context.php(29): Piwik\API\Proxy->Piwik\API\{closure}() #10 /var/www/dbuser/core/API/Proxy.php(158): Piwik\Context::executeWithQueryParameters() #11 /var/www/dbuser/core/API/Request.php(274): Piwik\API\Proxy->call() #12 /var/www/dbuser/plugins/API/Controller.php(46): Piwik\API\Request->process() #13 [internal function]: Piwik\Plugins\API\Controller->index() #14 /var/www/dbuser/core/FrontController.php(645): call_user_func_array() #15 /var/www/dbuser/core/FrontController.php(169): Piwik\FrontController->doDispatch() #16 /var/www/dbuser/core/dispatch.php(33): Piwik\FrontController->dispatch() #17 /var/www/dbuser/index.php(25): require_once(’…‘) #18 /var/www/dbuser/core/CliMulti/RequestCommand.php(76): require_once(’…‘) #19 /var/www/dbuser/core/Plugin/ConsoleCommand.php(109): Piwik\CliMulti\RequestCommand->doExecute() #20 /var/www/dbuser/vendor/symfony/console/Command/Command.php(298): Piwik\Plugin\ConsoleCommand->execute() #21 /var/www/dbuser/core/Plugin/ConsoleCommand.php(124): Symfony\Component\Console\Command\Command->run() #22 /var/www/dbuser/vendor/symfony/console/Application.php(1040): Piwik\Plugin\ConsoleCommand->run() #23 /var/www/dbuser/vendor/symfony/console/Application.php(301): Symfony\Component\Console\Application->doRunCommand() #24 /var/www/dbuser/core/Console.php(113): Symfony\Component\Console\Application->doRun() #25 [internal function]: Piwik\Console->originDoRun() #26 /var/www/dbuser/core/Console.php(152): call_user_func() #27 /var/www/dbuser/core/Access.php(672): Piwik\Console->Piwik\{closure}() #28 /var/www/dbuser/core/Console.php(150): Piwik\Access::doAsSuperUser() #29 /var/www/dbuser/core/Console.php(92): Piwik\Console->doRunImpl() #30 /var/www/dbuser/vendor/symfony/console/Application.php(171): Piwik\Console->doRun() #31 /var/www/dbuser/console(32): Symfony\Component\Console\Application->run() #32 {main}, caused by: The unserialization has failed! #0 /var/www/dbuser/core/DataTable.php(1494): Piwik\DataTable->unserializeRows() #1 /var/www/dbuser/core/DataTable.php(1987): Piwik\DataTable->addRowsFromSerializedArray() #2 /var/www/dbuser/core/ArchiveProcessor.php(403): Piwik\DataTable::fromSerializedArray() #3 /var/www/dbuser/core/ArchiveProcessor.php(378): Piwik\ArchiveProcessor->getAggregatedDataTableMapFromBlobs() #4 /var/www/dbuser/core/ArchiveProcessor.php(234): Piwik\ArchiveProcessor->aggregateDataTableRecord() #5 /var/www/dbuser/core/ArchiveProcessor/RecordBuilder.php(205): Piwik\ArchiveProcessor->aggregateDataTableRecords() #6 /var/www/dbuser/core/Plugin/Archiver.php(247): Piwik\ArchiveProcessor\RecordBuilder->buildForNonDayPeriod() #7 /var/www/dbuser/core/ArchiveProcessor/PluginsArchiver.php(190): Piwik\Plugin\Archiver->callAggregateMultipleReports() #8 /var/www/dbuser/core/ArchiveProcessor/Loader.php(317): Piwik\ArchiveProcessor\PluginsArchiver->callAggregateAllPlugins() #9 /var/www/dbuser/core/ArchiveProcessor/Loader.php(186): Piwik\ArchiveProcessor\Loader->prepareAllPluginsArchive() #10 /var/www/dbuser/core/ArchiveProcessor/Loader.php(165): Piwik\ArchiveProcessor\Loader->insertArchiveData() #11 /var/www/dbuser/core/ArchiveProcessor/Loader.php(105): Piwik\ArchiveProcessor\Loader->prepareArchiveImpl() #12 /var/www/dbuser/core/Context.php(76): Piwik\ArchiveProcessor\Loader->Piwik\ArchiveProcessor\{closure}() #13 /var/www/dbuser/core/ArchiveProcessor/Loader.php(102): Piwik\Context::changeIdSite() #14 /var/www/dbuser/plugins/CoreAdminHome/API.php(306): Piwik\ArchiveProcessor\Loader->prepareArchive() #15 [internal function]: Piwik\Plugins\CoreAdminHome\API->archiveReports() #16 /var/www/dbuser/core/API/Proxy.php(255): call_user_func_array() #17 /var/www/dbuser/core/Context.php(29): Piwik\API\Proxy->Piwik\API\{closure}() #18 /var/www/dbuser/core/API/Proxy.php(158): Piwik\Context::executeWithQueryParameters() #19 /var/www/dbuser/core/API/Request.php(274): Piwik\API\Proxy->call() #20 /var/www/dbuser/plugins/API/Controller.php(46): Piwik\API\Request->process() #21 [internal function]: Piwik\Plugins\API\Controller->index() #22 /var/www/dbuser/core/FrontController.php(645): call_user_func_array() #23 /var/www/dbuser/core/FrontController.php(169): Piwik\FrontController->doDispatch() #24 /var/www/dbuser/core … n#39 /var/www/dbuser/console(32): Symfony\Component\Console\Application->run()\n#40 {main}"}’
The problem is solved when
a) in core/DataTable.php, function unserializeRows.php, add right before ‘return $rows’: if(!is_array($rows)) { $rows = array(); }
b) in core/DataAccess/ArchiveSelector.php, function querySingleBlob, change line 646 to: if(is_array($blobs)) { ksort($blobs); }
There seems to be empty data rows which at least has to be an empty array.
If this is true, how does it happen, what is the best was to clean the data?
Thank you again!
Hi @mucctecc
I suggest you create an issue at: