Skip to content

Commit 22eec68

Browse files
author
Neha Kumari
committed
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.
1 parent 194776c commit 22eec68

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

client/mysqlbinlog.cc

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
33
44
This program is free software; you can redistribute it and/or modify
55
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)
14441444
*/
14451445
static Exit_status safe_connect()
14461446
{
1447+
/*
1448+
A possible old connection's resources are reclaimed now
1449+
at new connect attempt. The final safe_connect resources
1450+
are mysql_closed at the end of program, explicitly.
1451+
*/
1452+
mysql_close(mysql);
14471453
mysql= mysql_init(NULL);
14481454

14491455
if (!mysql)

0 commit comments

Comments
 (0)