Commit 22eec689 authored by Neha Kumari's avatar Neha Kumari

Bug#23540182:MYSQLBINLOG DOES NOT FREE THE EXISTING CONNECTION BEFORE OPENING NEW REMOTE ONE

It happens when you are trying to read two or more log files from a
remote server using mysqlbinlog utility.

The reason for this is no matching mysql_close() that concludes the
life time of 'mysql' struct describing connection to the server.
This happens when mysqlbinlog is invoked with connecting to the server
and requesting more than one binlog file. In such case
dump_remote_log_entries() keeps calling safe_connect() per eachfile,
never caring to invoke mysql_close(). Only the final safe_connect()'s
allocation effect are cleaned by the base code.
That is with 2 files there's one 'mysql' connection descriptor struct
uncleaned/deallocated.

We are backporting the bug 21255763 (pushed in mysql-trunk)
in the earlier version of MySQL starting from 5.5 to 5.7.
which was pushed in mysql-trunk.

Fix:
Invoke mysql_close() just before mysql_init() in safe_connect()
defined in mysqlbinlog.cc. That makes possibly previously used 'mysql' be
reclaimed prior a new one is allocated.
parent 194776ce
/* /*
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -1444,6 +1444,12 @@ static int parse_args(int *argc, char*** argv) ...@@ -1444,6 +1444,12 @@ static int parse_args(int *argc, char*** argv)
*/ */
static Exit_status safe_connect() static Exit_status safe_connect()
{ {
/*
A possible old connection's resources are reclaimed now
at new connect attempt. The final safe_connect resources
are mysql_closed at the end of program, explicitly.
*/
mysql_close(mysql);
mysql= mysql_init(NULL); mysql= mysql_init(NULL);
if (!mysql) if (!mysql)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment