Hi,
Sometimes I get questions on how to control queries running for longer than intended on the wikireplicas. Since MariaDB 10.1 (the version used on tools and the new wikireplicas), one can run:
SET max_statement_time = 300; [0]
And all subsequent queries on the same connection will be killed if the run longer than 5 minutes. For example:
mariadb[(none)]> SET max_statement_time = 10; Query OK, 0 rows affected (0.00 sec)
mariadb[(none)]> SELECT sleep(20); +-----------+ | sleep(20) | +-----------+ | 1 | +-----------+ 1 row in set (10.00 sec)
It works on quarry, too! [1] But not on the old wikireplicas.
This is of course not required, but 1) it will win you karma, by making your requests not run longer you intended (making resources available for others), and 2) it can limit the execution on web-based tools, as it is unlikely that a user will wait for longer than 1-5 minutes on a browser- an error will be a better feedback and a freezed loading page.
Regards,
[0] url:https://mariadb.com/kb/en/library/server-system-variables/#max_statement_time [1] url:https://quarry.wmflabs.org/query/22003
Great tip Jaime!
(This page needs some massaging and improving but...) I put this tip here https://wikitech.wikimedia.org/wiki/Help:Toolforge/Database#Query_Limits
Cheers. Hope your weekend goes well.
On Fri, Oct 6, 2017 at 9:35 AM, Jaime Crespo jcrespo@wikimedia.org wrote:
Hi,
Sometimes I get questions on how to control queries running for longer than intended on the wikireplicas. Since MariaDB 10.1 (the version used on tools and the new wikireplicas), one can run:
SET max_statement_time = 300; [0]
And all subsequent queries on the same connection will be killed if the run longer than 5 minutes. For example:
mariadb[(none)]> SET max_statement_time = 10; Query OK, 0 rows affected (0.00 sec)
mariadb[(none)]> SELECT sleep(20); +-----------+ | sleep(20) | +-----------+ | 1 | +-----------+ 1 row in set (10.00 sec)
It works on quarry, too! [1] But not on the old wikireplicas.
This is of course not required, but 1) it will win you karma, by making your requests not run longer you intended (making resources available for others), and 2) it can limit the execution on web-based tools, as it is unlikely that a user will wait for longer than 1-5 minutes on a browser- an error will be a better feedback and a freezed loading page.
Regards,
[0] url:https://mariadb.com/kb/en/library/server-system- variables/#max_statement_time [1] url:https://quarry.wmflabs.org/query/22003
-- Jaime Crespo http://wikimedia.org
Cloud mailing list Cloud@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/cloud
About the long waiting time for web tools, it depends strongly on the tool. For example for query.wikidata.org it would be nice that some query could be run even if it would spend one hour or even one full day instead of timeout at something like 5 minutes. Sometimes a long waiting result is better than no result at all.
Le 6 oct. 2017 16:35, "Jaime Crespo" jcrespo@wikimedia.org a écrit :
Hi,
Sometimes I get questions on how to control queries running for longer than intended on the wikireplicas. Since MariaDB 10.1 (the version used on tools and the new wikireplicas), one can run:
SET max_statement_time = 300; [0]
And all subsequent queries on the same connection will be killed if the run longer than 5 minutes. For example:
mariadb[(none)]> SET max_statement_time = 10; Query OK, 0 rows affected (0.00 sec)
mariadb[(none)]> SELECT sleep(20); +-----------+ | sleep(20) | +-----------+ | 1 | +-----------+ 1 row in set (10.00 sec)
It works on quarry, too! [1] But not on the old wikireplicas.
This is of course not required, but 1) it will win you karma, by making your requests not run longer you intended (making resources available for others), and 2) it can limit the execution on web-based tools, as it is unlikely that a user will wait for longer than 1-5 minutes on a browser- an error will be a better feedback and a freezed loading page.
Regards,
[0] url:https://mariadb.com/kb/en/library/server-system- variables/#max_statement_time [1] url:https://quarry.wmflabs.org/query/22003
-- Jaime Crespo http://wikimedia.org
_______________________________________________ Cloud mailing list Cloud@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/cloud