https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43381 Bug ID: 43381 Summary: Report row count query ( nb_rows ) ignores report_sql_max_statement_time_seconds Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: major Priority: P5 - low Component: Reports Assignee: koha-bugs@lists.koha-community.org Reporter: kyle@bywatersolutions.com QA Contact: testopia@bugs.koha-community.org CC: lisette@bywatersolutions.com Target Milestone: --- Bug 39164 added report_sql_max_statement_time_seconds, which wraps report SQL in a SET STATEMENT max_statement_time so the database kills a runaway report. It works for the query that fetches the results, but not for the query that counts them. C4::Reports::Guided::execute_query() applies the limit to its own copy of the SQL, so the caller's copy is untouched. reports/guided_reports.pl then hands that original SQL to nb_rows(), which runs SELECT COUNT(*) FROM $sql with no time limit. If that wrapper fails ( e.g. "Duplicate column name" ), nb_rows falls back to running the report a second time and counting every row by hand, also with no limit. Test Plan: 1) Apply the first patch 2) prove t/db_dependent/Reports/Guided.t 3) Note the 'nb_rows() tests' subtest fails! 4) Apply the remaining patches 5) prove t/db_dependent/Reports/Guided.t 6) Note the tests pass now! 7) Add this to koha-conf.xml: <report_sql_max_statement_time_seconds>2<report_sql_max_statement_time_seconds> 8) Restart all the things! 9) Create a report with the SQL: SELECT b1.borrowernumber FROM borrowers b1, borrowers b2 WHERE SLEEP(0.005) = 0 10) Run the report 11) Note the page comes back in about 2 seconds, the first 20 rows are shown, and "Total number of results" is *not* displayed! 12) Comment out report_sql_max_statement_time_seconds in koha-conf.xml 13) Restart plack again 14) Run the report again 15) Note the page now takes about 20 seconds and "Total number of results" is displayed! -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.