Stop query loop on reconnect.

imre posted 5 years ago in Running SQL scripts

If i run a script with many queries and connection is lost then heidy automatically reconnects and continues the query loop from next(?) item.

This is a problem for me.
For example if i use transactions then after reconnect the script does not run in transaction anymore and yields inconsistent result.
Same case when using variables / temporary tables.

What do you think of making query loop to not continue in case of reconnects or at least make it optional?

Thank you.
ansgar posted 5 years ago
Reconnecting is done *before* executing a query. Queries are never skipped. The only situation when that can happen is if the query itself produces a huge query or takes longer to finish as idle_timeout allows. What was the cause of your reconnect?
imre posted 5 years ago
For example, when thread is killed.

runnign the script:
set @a:=null;
select @a:=concat_ws(',',@a,sleep(5)+1);
select @a:=concat_ws(',',@a,sleep(5)+2);
select @a:=concat_ws(',',@a,sleep(5)+3);
select @a:=concat_ws(',',@a,sleep(5)+4);

set @a:=null;
select @a:=concat_ws(',',@a,sleep(2)+1);
select @a:=concat_ws(',',@a,sleep(2)+2);
/* Connection to closed at 2010-12-30 15:16:17 */
/* Connecting to via TCP/IP, username imre, using password: Yes ... */
/* Connected. Thread-ID: 78 */
/* Characterset: utf8 */
SHOW VARIABLES LIKE 'version_compile_os';
USE `insurance`;
select @a:=concat_ws(',',@a,sleep(2)+3);
select @a:=concat_ws(',',@a,sleep(2)+4);
/* 0 rows affected, 4 rows found. Duration for 5 queries: 6,438 sec. */

Result tabs:
Result #1: 1
Result #2: 1,3  // i dont know why 3 here, there should be no result. 
Result #3: 3
Result #4: 3,4
ansgar posted 5 years ago
Ok - the query was somehow causing a disconnect. But a query should not get executed again if when that happens. That would mean you are stuck in some endless loop, would it?
imre posted 5 years ago
I agree.

Just to clarify again:
In that example I opened the second Heidi instance and killed the server thread manually while it was running the 2nd query.

If i just plug the network cable then it gets timeout in around 5 seconds and works as expexted.
So its not that critical than i thought, but still i must take into account i cannot kill the server thread to stop execution

which means killing the heidisql.exe is the only option.

Please login to leave a reply, or register at first.