replication memory leaks

Former-commit-id: 73020b6a939f241ade7512d58a4ddf17f5a803c5
This commit is contained in:
John Sully 2020-01-30 17:56:24 -05:00
parent 4352a26a5b
commit a7b7040577

View File

@ -2628,7 +2628,6 @@ void syncWithMaster(connection *conn) {
serverLog(LL_WARNING,"Opening the temp file needed for MASTER <-> REPLICA synchronization: %s",strerror(errno)); serverLog(LL_WARNING,"Opening the temp file needed for MASTER <-> REPLICA synchronization: %s",strerror(errno));
goto error; goto error;
} }
mi->repl_transfer_tmpfile = zstrdup(tmpfile);
mi->repl_transfer_fd = dfd; mi->repl_transfer_fd = dfd;
} }
@ -2648,6 +2647,8 @@ void syncWithMaster(connection *conn) {
mi->repl_transfer_read = 0; mi->repl_transfer_read = 0;
mi->repl_transfer_last_fsync_off = 0; mi->repl_transfer_last_fsync_off = 0;
mi->repl_transfer_lastio = g_pserver->unixtime; mi->repl_transfer_lastio = g_pserver->unixtime;
if (mi->repl_transfer_tmpfile)
zfree(mi->repl_transfer_tmpfile);
mi->repl_transfer_tmpfile = zstrdup(tmpfile); mi->repl_transfer_tmpfile = zstrdup(tmpfile);
return; return;
@ -2805,7 +2806,13 @@ void freeMasterInfo(redisMaster *mi)
{ {
zfree(mi->masterauth); zfree(mi->masterauth);
zfree(mi->masteruser); zfree(mi->masteruser);
if (mi->repl_transfer_tmpfile)
zfree(mi->repl_transfer_tmpfile);
delete mi->staleKeyMap; delete mi->staleKeyMap;
if (mi->cached_master != nullptr)
freeClientAsync(mi->cached_master);
if (mi->master != nullptr)
freeClientAsync(mi->master);
zfree(mi); zfree(mi);
} }
@ -3098,6 +3105,12 @@ void replicationCacheMaster(redisMaster *mi, client *c) {
* current offset if no data was lost during the failover. So we use our * current offset if no data was lost during the failover. So we use our
* current replication ID and offset in order to synthesize a cached master. */ * current replication ID and offset in order to synthesize a cached master. */
void replicationCacheMasterUsingMyself(redisMaster *mi) { void replicationCacheMasterUsingMyself(redisMaster *mi) {
if (mi->cached_master != nullptr)
{
// This can happen on first load of the RDB, the master we created in config load is stale
freeClient(mi->cached_master);
}
/* The master client we create can be set to any DBID, because /* The master client we create can be set to any DBID, because
* the new master will start its replication stream with SELECT. */ * the new master will start its replication stream with SELECT. */
mi->master_initial_offset = g_pserver->master_repl_offset; mi->master_initial_offset = g_pserver->master_repl_offset;