Merge branch 'unstable' into keydbpro

Former-commit-id: aca1a6605685811833729d746df85781177d5a78
This commit is contained in:
John Sully 2020-01-30 21:15:42 -05:00
commit 6be6785b31
2 changed files with 34 additions and 5 deletions

View File

@ -1704,9 +1704,17 @@ robj *rdbLoadObject(int rdbtype, rio *rdb, robj *key, uint64_t mvcc_tstamp) {
len--;
/* Load raw strings */
if ((field = (sds)rdbGenericLoadStringObject(rdb,RDB_LOAD_SDS,NULL))
== NULL) return NULL;
== NULL)
{
decrRefCount(o);
return NULL;
}
if ((value = (sds)rdbGenericLoadStringObject(rdb,RDB_LOAD_SDS,NULL))
== NULL) return NULL;
== NULL)
{
decrRefCount(o);
return NULL;
}
/* Add pair to ziplist */
o->m_ptr = ziplistPush((unsigned char*)ptrFromObj(o), (unsigned char*)field,
@ -1735,9 +1743,17 @@ robj *rdbLoadObject(int rdbtype, rio *rdb, robj *key, uint64_t mvcc_tstamp) {
len--;
/* Load encoded strings */
if ((field = (sds)rdbGenericLoadStringObject(rdb,RDB_LOAD_SDS,NULL))
== NULL) return NULL;
== NULL)
{
decrRefCount(o);
return NULL;
}
if ((value = (sds)rdbGenericLoadStringObject(rdb,RDB_LOAD_SDS,NULL))
== NULL) return NULL;
== NULL)
{
decrRefCount(o);
return NULL;
}
/* Add pair to hash table */
ret = dictAdd((dict*)ptrFromObj(o), field, value);

View File

@ -2691,7 +2691,6 @@ void syncWithMaster(connection *conn) {
serverLog(LL_WARNING,"Opening the temp file needed for MASTER <-> REPLICA synchronization: %s",strerror(errno));
goto error;
}
mi->repl_transfer_tmpfile = zstrdup(tmpfile);
mi->repl_transfer_fd = dfd;
}
@ -2711,6 +2710,8 @@ void syncWithMaster(connection *conn) {
mi->repl_transfer_read = 0;
mi->repl_transfer_last_fsync_off = 0;
mi->repl_transfer_lastio = g_pserver->unixtime;
if (mi->repl_transfer_tmpfile)
zfree(mi->repl_transfer_tmpfile);
mi->repl_transfer_tmpfile = zstrdup(tmpfile);
return;
@ -2868,7 +2869,13 @@ void freeMasterInfo(redisMaster *mi)
{
zfree(mi->masterauth);
zfree(mi->masteruser);
if (mi->repl_transfer_tmpfile)
zfree(mi->repl_transfer_tmpfile);
delete mi->staleKeyMap;
if (mi->cached_master != nullptr)
freeClientAsync(mi->cached_master);
if (mi->master != nullptr)
freeClientAsync(mi->master);
zfree(mi);
}
@ -3161,6 +3168,12 @@ void replicationCacheMaster(redisMaster *mi, client *c) {
* 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. */
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 new master will start its replication stream with SELECT. */
mi->master_initial_offset = g_pserver->master_repl_offset;