diff options
author | Neha Kumari <neha.n.kumari@oracle.com> | 2016-08-05 12:17:11 +0530 |
---|---|---|
committer | Neha Kumari <neha.n.kumari@oracle.com> | 2016-08-05 12:17:11 +0530 |
commit | 22eec68941f3acbd9033e7fb33d10c63e6b388da (patch) | |
tree | f4cfbdbc4adb27f787bc883893b801a39a182527 | |
parent | 194776ce00f6fea37551ea25584798f78b0ad24b (diff) | |
download | mariadb-git-22eec68941f3acbd9033e7fb33d10c63e6b388da.tar.gz |
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.
-rw-r--r-- | client/mysqlbinlog.cc | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index 73a801c4b21..955d9e3fb3c 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -1,5 +1,5 @@ /* - 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 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) */ 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); if (!mysql) |