When running a report, column last run is updated with current date-time. We should avoid using NOW(), better calculated date-time in perl. With NOW(), when importing a backup dump, you get current date-time in all rows. Also, sometimes we see errors in plack logs : DBD::mysql::db do failed: Lock wait timeout exceeded; try restarting transaction [for Statement "UPDATE saved_sql SET last_run = NOW() WHERE id = ?"] at /home /koha/src/C4/Reports/Guided.pm line 576. Replacing NOW() should avoid this.
See that NOW() has been replaces in C4::Stats by Bug 24151
Created attachment 115565 [details] [review] Bug 27511: Don't use NOW() in saved sql last run update When running a report, column last run is updated with current date-time. We should avoid using NOW(), better calculated date-time in perl. With NOW(), when importing a backup dump, you get current date-time in all rows. Also, sometimes we see errors in plack logs : DBD::mysql::db do failed: Lock wait timeout exceeded; try restarting transaction [for Statement "UPDATE saved_sql SET last_run = NOW() WHERE id = ?"] at /home /koha/src/C4/Reports/Guided.pm line 576. Replacing NOW() should avoid this. Test plan: 1) Run a sql report 2) Check last run date and time is OK
Or maybe we should use Koha::Report (ORM) ? with $report->last_run($date)->store();
Created attachment 119050 [details] [review] Bug 27511: Don't use NOW() in saved sql last run update When running a report, column last run is updated with current date-time. We should avoid using NOW(), better calculated date-time in perl. With NOW(), when importing a backup dump, you get current date-time in all rows. Also, sometimes we see errors in plack logs : DBD::mysql::db do failed: Lock wait timeout exceeded; try restarting transaction [for Statement "UPDATE saved_sql SET last_run = NOW() WHERE id = ?"] at /home /koha/src/C4/Reports/Guided.pm line 576. Replacing NOW() should avoid this. Test plan: 1) Run a sql report 2) Check last run date and time is OK Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr>
(In reply to Fridolin Somers from comment #3) > Or maybe we should use Koha::Report (ORM) ? > with $report->last_run($date)->store(); I don't have any opinion about that point, the way the patch is written works fine to me.
(In reply to Séverine Queune from comment #5) > (In reply to Fridolin Somers from comment #3) > > Or maybe we should use Koha::Report (ORM) ? > > with $report->last_run($date)->store(); > > I don't have any opinion about that point, the way the patch is written > works fine to me. QA will tell ;) Thanks a lot for testing
We had this discussion on #koha IIRC, a couple of weeks ago. We don't think this is actually needed. The timezone we use from the DBMS and the perl code should be the same and so this patch won't have any effects and is not fixing a bug. Feel free to reopen if you have an example of what you are trying to fix.
Additionally, I don't think replacing NOW will fix the error "Lock wait timeout exceeded". The problem must be somewhere else.
Ok no problem. One known consequence of NOW() is that when re-import a dump, you loose the original date. But it is not really important.