From 11d27996e4472882096bfdb2504061448f689672 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 19 Feb 2014 21:40:15 +0100 Subject: [PATCH] increment and get the query_id atomically, otherwise two concurrent threads might end up having the same query id --- sql/sql_parse.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 20fba8e49ae..61c822f0d69 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -917,9 +917,10 @@ bool dispatch_command(enum enum_server_command command, THD *thd, DEBUG_SYNC(thd,"dispatch_command_before_set_time"); thd->set_time(); - thd->set_query_id(get_query_id()); - if (!(server_command_flags[command] & CF_SKIP_QUERY_ID)) - next_query_id(); + if (server_command_flags[command] & CF_SKIP_QUERY_ID) + thd->set_query_id(get_query_id()); + else + thd->set_query_id(next_query_id()); inc_thread_running(); if (!(server_command_flags[command] & CF_SKIP_QUESTIONS))