From e12156e7b68e72affbfbf95969ac2bcd4ede000d Mon Sep 17 00:00:00 2001 From: Arun Kuruvila Date: Thu, 10 Apr 2014 11:10:31 +0530 Subject: [PATCH] Description: When we execute a correlated subquery on an archive table which is using an auto increment column, the server hangs. In order to recover the mysqld process, it has to be terminated abnormally using SIGKILL. The problem is observed in mysql-5.5. Bug #18065452 "PREPARING" STATE HOGS CPU WITH ARCHIVE + SUBQUERY Analysis: This happens because the server is trapped inside an infinite loop in the function, "subselect_indexsubquery_engine::exec()". This function resolves the correlated suquery by doing an index lookup for the appropriate engine. In case of archive engine, after reaching the end of records, "table->status" is not set to STATUS_NOT_FOUND. As a result the loop is not terminated. Fix: The "table->status" is set to STATUS_NOT_FOUND when the end of records is reached. --- storage/archive/ha_archive.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/storage/archive/ha_archive.cc b/storage/archive/ha_archive.cc index 164c59f2426..aafbedf6a07 100644 --- a/storage/archive/ha_archive.cc +++ b/storage/archive/ha_archive.cc @@ -1,5 +1,6 @@ /* - Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights + reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -1078,6 +1079,7 @@ int ha_archive::index_next(uchar * buf) } rc= found ? 0 : HA_ERR_END_OF_FILE; + table->status= rc ? STATUS_NOT_FOUND : 0; MYSQL_INDEX_READ_ROW_DONE(rc); DBUG_RETURN(rc); }