[solved] OJS 3.1.0_1 usageEventLogs files are not processed

Hi all, (including @bozana)

I am using OJS 3.1.0_1, php 7

I noticed yesterday that my usageEventLogs files are not processed from January 31, 2018. So, usageStats are not being updated. Things looked good to that point.

I remember applying patch for showing statistics for last twelve months instead of current year but I don’t remember the exact date.

I also started using a new theme ‘oldGregg’ by @Vitaliy currently.

No fatal error in php_error. No data in DB metrics for 2018 february.

usageEventLogs folder shows unprocessed log files from the date I specified above.
image

Archive folder contails logs files only up to the date I specified
image

usageStats error_logs shows a lot of following errors starting from 02 Dec 2017:

[23-Feb-2018 00:15:01 UTC] PHP Fatal error:  Uncaught Error: Call to undefined function import() in /home/jlmcedun/public_html/plugins/generic/usageStats/UsageStatsLoader.inc.php:16
Stack trace:
#0 {main}
  thrown in /home/jlmcedun/public_html/plugins/generic/usageStats/UsageStatsLoader.inc.php on line 16

Link to my website is https://jlmc.edu.np

Looking for help.

Regards,
@anupent

Hi @anupent

Hmmm… That error message is crazy :stuck_out_tongue: – how is it possible that it occurs now and not earlier, and why there are not everywhere? – the function import is used everywhere :open_mouth:
I am not sure about that, but: do you have this code lines: pkp-lib/functions.inc.php at ojs-3_1_0-1 · pkp/pkp-lib · GitHub ?
Also, could you test other pages to see if that error occurs?

Do you use Acron plugin to run the scheduled tasks?
What is the last_run date for UsageStatsLoader in your DB table scheduled_tasks?
Because those usage stats log files are still in the folder usageEventLogs it seems like the processing did not start at all… else they would be in stage or reject or…
Could you then maybe remove the entry from the DB table scheduled_tasks and then run the scheduled tasks again and watch the error logs? – When you use the Acron plugin you would run the scheduled task by calling for example an article page or a journal start page…

Also, do you see anything in you scheduled tasks logs – there should be a folder scheduledTaskLogs in your files folder, and there should be files with names starting with Usagestatisticsfileloadertask-. Are there log files since 31. January? If so, could you take a look at them, are there any error messages there?

Hmmm…
Best,
Bozana

Thanks @bozana for your brainstroming for my problem.

  1. I have the lines L22-L27 in the stated file. They look good.
  2. I did not get what do you mean by “Also, could you test other pages to see if that error occurs?”. I think I have mentioned about geoip error in point 6 below if that has any relevance.
  3. Yes, I do use Acron plugin to run the scheduled tasks?
  4. The last_run date for UsageStatsLoader in DB scheduled_task is 2018-02-22 22:18:10
  5. I removed UsageStatsLoader in DB and ran Acron plugin. New last_run date for UsageStatsLoader now is 2018-02-23 18:42:17
  6. I have a new fatal error in php error_log:
Fatal error:  Cannot redeclare geoip_country_code_by_name_v6() in /home/jlmcedun/public_html/lib/pkp/plugins/generic/usageStats/lib/geoIp/geoip.inc on line 430

Same error Uncaught Error: Call to undefined function import() error_log in usageStats

  1. In scheduledTaskLogs, I see logs of various tasks like CrossREfautomaticregistrationtask and DOAJauto… Reviewreminder till today. But UsageStatsLoadertask is logged only up to Jan 31 2018.

  2. I noticed a warning in DB metrics table as “Current selection does not contain a unique column. Grid edit, checkbox, Edit, Copy and Delete features are not available”. Is it an expected behavior?

  3. I remembered something by the geoip error. I had upgraded to php 7.1 and at the same time activated geoip php module.
    I deactivated it. Deleted DB for last_run date for UsageStatsLoader. Re-ran Acron.

    Voila! all the usage_events.log files got processed and I got all the latest statistics.

Conclusion: Activation of the geoip php module in my server was the problem.

Feeling good.
Thanks @bozana again.

1 Like

Glad it is solved! :ok_hand: :slight_smile:

1 Like

Hi @bozana,
I am not sure shall I ask here or open a new post?

Whay is your say about point 8 above, i.e

  1. I noticed a warning in DB metrics table as “Current selection does not contain a unique column. Grid edit, checkbox, Edit, Copy and Delete features are not available”. Is it an expected behavior?

Regards,
@anupent

Hi @anupent

Yes, that is correct…

Thanks!
Bozana

1 Like

Hi @bozana ,

We are running a version of 3.1.0 which recently migrated from 2.4.6. We have some old usagestats log files that we want to manually process them in the new installation by moving them to files/usagestats/stage folder and running:
php tools/runScheduledTasks.php lib/pkp/plugins/generic/usageStats/scheduledTasks.xml

All the article, issue, and homepage metrics are moved to metrics table except the download counts. I realized there is bug in lib/pkp/plugins/generic/usageStats/PKPUsageStatsLoader.inc.php. getAssoc function line 371 is missing handling ASSOC_TYPE_SUBMISSION_FILE case. I added below block and it successfully added download counts to metrics table also.

case ASSOC_TYPE_SUBMISSION_FILE:
                                $representation_id = $args[1];
                                $representationDao = Application::getRepresentationDAO();
                                $galley = $representationDao->getById($representation_id, $args[0]);
                                if ($galley) {
                                        $assocId = $galley->getFileId();
                                }
                                break;

If you approve it, please consider to add it to the next release.

Thanks
Ghazal

Hi @salehig

Hmmm… That check is there, in the child class, s. https://github.com/pkp/ojs/blob/master/plugins/generic/usageStats/UsageStatsLoader.inc.php#L61. But it could maybe be that you had this problem: consider missing submission file in usage stats loader · Issue #3332 · pkp/pkp-lib · GitHub i.e. that this change was missing: pkp/pkp-lib#3332 consider missing submission file in usage stats loader by bozana · Pull Request #1816 · pkp/ojs · GitHub?

Best,
Bozana

Hi @bozana,

I traced the code exactly, in my case getAssoc from the parent is called and not from the child. As soon as I added the check in PKPUsageStatsLoader the files metrics were added to the database.

Regards
Ghazal

I just ran into the same issue as @salehig with 3.1.1 where I tried to reprocess OJS2 logs and the downloads were empty. I added that case to the getAssoc function in lib/pkp/plugins/generic/usageStats/PKPUsageStatsLoader.inc.php and the download counts got added to the metrics table.

Hmmm… Somehow I do not understand why would that be necessary in the parent class, when it is in the child class:
First this function is called: ojs/UsageStatsLoader.inc.php at ojs-3_1_1-1 · pkp/ojs · GitHub.
Then that function in the parent class is called here: ojs/UsageStatsLoader.inc.php at ojs-3_1_1-1 · pkp/ojs · GitHub. And that function should return array with nulls, because no such type (ASSOC_TYPE_SUBMISSION_FILE) is considered there, so that the function execution in UsageStatsLoader would continue and this switch statement executed ojs/UsageStatsLoader.inc.php at ojs-3_1_1-1 · pkp/ojs · GitHub and this case found ojs/UsageStatsLoader.inc.php at ojs-3_1_1-1 · pkp/ojs · GitHub.
Hmmm…
Does maybe your parent class not return array of nulls so that this if statement is not passed: ojs/UsageStatsLoader.inc.php at ojs-3_1_1-1 · pkp/ojs · GitHub? But why would that be? Hmmm… :thinking:

I’ll try to test it locally…

Hmmm… :open_mouth:
Bozana

Hi @bozana,

I believe definitely this has to be looked at. Without having that block of code when I run runScheduledTasks.php script I get a couple of hundreds of rejected items and hundreds of below errors in scheduledtasklogs:
[Error] Cannot load record: submission file is not associated with a representation object.

Regards
Ghazal

Hi @salehig

Would it be possible for you to perform a few tests and send me the results?
For example: could you print out these variables: $assocTypeToReturn, $assocId and $assocType
at this code line: ojs/UsageStatsLoader.inc.php at ojs-3_1_1-1 · pkp/ojs · GitHub
when that code block/part is not in PKPUsageStatsLoader, but just in UsageStatsLoader
and you process a log file
?

Or would it even be possible that you send me such a problematic usage stats log file and your anonymized DB dump?

Thanks a lot!
Bozana

can u help Usage statistic files are stuck in 'processing' folder ?