Page MenuHomePhabricator

MediaWiki should support setting a read query time limit
Closed, DuplicatePublic

Description

MariaDB (and MySQL) supports setting max_statement_time (see https://mariadb.com/kb/en/aborting-statements/) to limit how long a query can run for. For known slow read queries (only SELECT), this would be useful in addition to the automated query killer to limit runtime to <= 60 seconds.

This could be seen as somewhat analogous to the wall clock limit we have for shell commands. I did not look to see whether Postgres/SQLite also support similar features, but I think that's fine initially as this is an optional/platform-dependent hardening measure (again, like how we limit shell commands).

Event Timeline

For known slow queries, this would be useful in addition to the automated query killer to limit runtime to <= 60 seconds.

This could also work in the opposite direction, have a global limit that's low, but increase it for known slow queries.

For known slow queries, this would be useful in addition to the automated query killer to limit runtime to <= 60 seconds.

This could also work in the opposite direction, have a global limit that's low, but increase it for known slow queries.

I favor this approach, FWIW.

I also think it is reasonable to only set max_statement_time on non-mutating queries (SELECT etc). Catches most of the known bad cases but also means we don't have to worry about violating existing durability guarantees.

FWIW, if I had created this bug, I would have titled it "Mediawiki must send a max_statement_time on every non-mutating database query" :)

Legoktm renamed this task from MediaWiki should support setting a query time limit to MediaWiki should support setting a read query time limit.Oct 16 2021, 4:26 AM
Legoktm updated the task description. (Show Details)

(I realise this issue is closed, but i just wanted to respond to this suggestion)

For known slow queries, this would be useful in addition to the automated query killer to limit runtime to <= 60 seconds.

This could also work in the opposite direction, have a global limit that's low, but increase it for known slow queries.

The issue there is that this global limit would apply to all queries, regardless of user or type of query. Assuming we don't want writes to timeout, all mutating queries would need to be updated to disable the limit. And a lot of dba manual maintenance work would now require the dba to remember to type 'set session.max_statement_limit=0;' at the start of every mysql session.