From: Alexander Nozdrin Date: May 6 2011 11:40am Subject: bzr commit into mysql-5.5 branch (alexander.nozdrin:3497) List-Archive: http://lists.mysql.com/commits/136821 Message-Id: <201105061140.p46BeRej012986@acsmt356.oracle.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============6409311805717208554==" --===============6409311805717208554== MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline #At file:///home/alik/MySQL/bzr/00/bug60025/mysql-5.5-bug60025/ based on revid:alexander.nozdrin@stripped 3497 Alexander Nozdrin 2011-05-06 The user-visible problem was that the server started to consume memory if a stored-routine of some sort is executed subsequently. The memory was freed only after the corresponding connection was closed. Technically, the problem was that the memory needed for temporary string conversions was allocated on the connection ("persistent") memory root, instead of statement one. The root cause of this problem was the incorrect patch for Bug 55744. That patch wrongly fixed a crash in prepared-statement-mode introduced by another patch. The patch for Bug 55744 used wrong condition to check if prepared statement mode is active (or whether the connection-scoped or statement-scoped memory root should be used). The thing is that for prepared statements such conversions should be done in the connection memory root, so that that the transformations of item-tree were correctly remembered in the PREPARE-phase. The fix is to use proper condition to detect prepared-statement-mode and use proper memory root. modified: sql/item.cc === modified file 'sql/item.cc' --- a/sql/item.cc 2011-05-06 11:39:40 +0000 +++ b/sql/item.cc 2011-05-06 11:40:22 +0000 @@ -1781,14 +1781,17 @@ bool agg_item_set_converter(DTCollation } THD *thd= current_thd; - Query_arena *arena, backup; bool res= FALSE; uint i; + /* In case we're in statement prepare, create conversion item in its memory: it will be reused on each execute. */ - arena= thd->activate_stmt_arena_if_needed(&backup); + Query_arena backup; + Query_arena *arena= thd->stmt_arena->is_stmt_prepare() ? + thd->activate_stmt_arena_if_needed(&backup) : + NULL; for (i= 0, arg= args; i < nargs; i++, arg+= item_sep) { --===============6409311805717208554== MIME-Version: 1.0 Content-Type: text/bzr-bundle; charset="us-ascii"; name="bzr/alexander.nozdrin@stripped" Content-Transfer-Encoding: 7bit Content-Disposition: inline # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: alexander.nozdrin@stripped\ # gym9tfv4lqzam6t1 # target_branch: file:///home/alik/MySQL/bzr/00/bug60025/mysql-5.5-\ # bug60025/ # testament_sha1: 60b7078dd7d4be8af2f7b80860d7f0624f2a20c7 # timestamp: 2011-05-06 15:40:25 +0400 # source_branch: file:///home/alik/MySQL/bzr/00/bug60025/mysql-5.5/ # base_revision_id: alexander.nozdrin@stripped\ # vi12q2mulw2cr768 # # Begin bundle IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWStXA6EAAfP/gAAQEABRd/// 8gV2AL/v//BQBaZqsVt7lbJIinTICUSYhoAmU9MQUDamTDU8TUM0T1AlIp6ND1JtU/VPRPJP0UDQ DRoAyGgCU0mgk2poZT0IMqeo2o/VDQMBD1AHMAmAEwAAmAAJgACSIRoE2plHpoqb8ip6n6mo9Rpi HqGjIaUTJTk3Szm853XZa5GvFwtmoU6qQVOChqryihni9tm/h60WM3uxAkCR/F+fGtVUH+idGyLa pasV90bryN7o8ILm27gcm17vXiqaw2nSfDGo6j5uWk9EYWoYfSKO8oVAph/t4J7tsq9+y8VSmqUi CS4SKImKoKU/LZFsJJ7HuoGwYU6lScc5WCrPUyd1NzTI6v5Ry0R1Pxw0SlG0kg7IXlfJzz9Z86Tw NMjQY9SnVezeNph4COPvrKd8iLccAXuznC9cXwgqUIhlVELbFm0XzANsBus0ucshG0YXCBpRA/oO MS3jHNQULMKjUVjZvENUuWJMauLzvUlEMyG1ohQIRNrtdbXPZAJ5wzKGCakqepsqoqml0Im7dn5l JTZbSvSzTQ4ypzJMESgQioboRFwypwdDIk0KD+oMvPgGBqrqKmzjcVcMHa3hFNLweRYl01lnRYbM RAoYLy25kePdBLeeJMkQvYNH6Ngp1En2WziEtXW0fgOkNcjOwlvdaeOIYSiD2LluqUzBZMnKqo80 iSiO7cLBZBSNRKnpbhAuKlbtxmasroobKmNTVN5osWutwPKg9igWNTDbwFpSlxl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