3

We are running Percona Server 5.6.36-82.1-log and PHP 7.0.19.

The database is setup using max_statement_time to automatically timeout queries after 10 seconds. And when running (very) slow queries in PHPMyAdmin they timeout with the proper mysql error.

But when running the queries in our webapp, using PDO. The query just stops after the timeout, but without raising an error / throwing an exception. The query just stops and has no results, just like a regular query stops without any results.

The PDO object is created with the ATTR_TIMEOUT = 1 option. And later we add ATTR_ERRMODE = ERRMORE_EXCEPTION, ATTR_DEFAULT_FETCH_MODE = FETCH_ASSOC ATTR_EMULATE_PREPARES = false

What is needed for this situation to throw an Exception like expected?

Bram
  • 53
  • 5
  • What's the actual question? – Martijn Gastkemper Nov 10 '17 at 09:25
  • It may be possible to speed up the query; let's see that SQL. – Rick James Nov 13 '17 at 18:40
  • 3
    So the question is, why is an exception not thrown for queries that exceed the MAX_STATEMENT_TIME set in the DB global or session variables. I can confirm this behavior with some trivial SQL: `SET SESSION MAX_STATEMENT_TIME=2; SELECT SLEEP(10);` The statement does indeed timeout in 2 seconds, however, for some reason when `ATTR_ERRMODE = ERRMORE_EXCEPTION` the query is again retired after timeout and then just completes with no exception like nothing happened. So, with our example above, we would process for 4 seconds, 2x two second timeout. This sounds like just like PHP. #HalfBaked – Alex Barker Jun 06 '19 at 00:08

0 Answers0