Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set Timeout for All Select queries in MySQL running on RDS

I want to set a timeout for all the select queries hitting on MySQL Server. So that if the read query is taking a long time then i can throw a timeout exception. I know this feature is provided in MySQL 5.7 by:

SET GLOBAL MAX_STATEMENT_TIME=1000;

or

SET GLOBAL MAX_EXECUTION_TIME=1000;

But the problem is that MySQL 5.7 is not provided in AWS RDS. I am using MySQL 5.6 on RDS. Please tell me is there any alternate way to do this in 5.6 I am a new to mysql and RDS. Please help me out.

like image 692
vjangra Avatar asked Aug 10 '15 07:08

vjangra


1 Answers

I know this question is about MySQL v5.6.1 - but maybe this helps other visitors: You can find out what version/parameter is supported and edit it like this:

1) Go to https://console.aws.amazon.com/rds/ and select "Parameter groups" in the menu on the left.

2) Select the parameter group you used for your database instance and in the dropdown "Parameter group actions" choose "edit".

Now depending on your database version the parameter might be called max_statement_time or in later versions max_execution_time.

3) Search for one of those parameters and click "Edit parameters".

be aware that max_statement_time is in seconds and max_execution_time in milliseconds. So if you want your query to be terminated after 1 second its either:

 max_statement_time = 1

or

 max_execution_time = 1000

To be sure, read the explanation on the right column to see what the parameter does.

4) Then set the new value you want.

5) "Save changes" and wait for the parameter group being applied to the database instance (you might have to select "apply immediately" or just reboot afterwards).

like image 180
GameDroids Avatar answered Sep 27 '22 17:09

GameDroids