Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aborting query is not supported #344

Closed
fdiary opened this issue Sep 3, 2020 · 2 comments
Closed

aborting query is not supported #344

fdiary opened this issue Sep 3, 2020 · 2 comments

Comments

@fdiary
Copy link
Member

fdiary commented Sep 3, 2020

MariaDB has max_statement_time variable with which any query taking longer than this time (seconds) will be aborted. MySQL also has max_execution_time variable with which SELECT query taking longer than this time (millseconds) will be aborted.

Currently, these values do not affect Mroonga, thus queries will be aborted after whole mroonga process finishes. So if we get lots of queries which match too many results, it can cause DoS.

Here are MariaDB implementation for this functionality (by @kou) :

Groonga supports request timeout but it cannot be used from Mroonga for now.

@fdiary
Copy link
Member Author

fdiary commented Sep 4, 2020

I also checked how long groonga process took by srv/mariadb/groonga.log

with 5 seconds timeout, but terminated in 9.8 seconds

$ time ./bin/mysql test_db -e "set global mroonga_log_level='INFO'; set statement max_statement_time=5 for select count(uid) from full_text where match(SearchableText) against('000' in boolean mode);"
ERROR 1969 (70100) at line 1: Query execution was interrupted (max_statement_time exceeded)

real    0m9.786s
user    0m0.008s
sys     0m0.008s

2020-09-04 09:45:51.441758|i|29187|786e9700: [object][search][index][key][exact] <full_text#SearchableText.index>
2020-09-04 09:45:51.441800|i|29187|786e9700: grn_ii_sel > (000)
2020-09-04 09:45:51.443885|i|29187|786e9700: n=2 (000)
2020-09-04 09:45:59.673364|i|29187|786e9700: exact: 5106810
2020-09-04 09:45:59.673393|i|29187|786e9700: hits=5106810

and here groonga takes 8.2 seconds.

without timeout, finished in 18.1 seconds

$ time ./bin/mysql test_db -e "set global mroonga_log_level='INFO'; select count(uid) from full_text where match(SearchableText) against('000' in boolean mode);"
+------------+
| count(uid) |
+------------+
|    5106810 |
+------------+

real    0m18.116s
user    0m0.006s
sys     0m0.008s

2020-09-04 09:46:18.420389|i|29513|2e9d9700: [object][search][index][key][exact] <full_text#SearchableText.index>
2020-09-04 09:46:18.420429|i|29513|2e9d9700: grn_ii_sel > (000)
2020-09-04 09:46:18.422516|i|29513|2e9d9700: n=2 (000)
2020-09-04 09:46:26.588881|i|29513|2e9d9700: exact: 5106810
2020-09-04 09:46:26.588926|i|29513|2e9d9700: hits=5106810

and here groonga takes 8.2 seconds.

So it seems that whole groonga process is executed regardless query timeout in MariaDB side.

@kou kou closed this as completed in e7987d8 Oct 6, 2022
@kou
Copy link
Member

kou commented Oct 6, 2022

I've implemented this. :-)

NexediGitlab pushed a commit to SlapOS/slapos that referenced this issue Nov 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants