Merge pull request #96 from Snapchat/repl_asan_fixes

Repl asan fixes
This commit is contained in:
John Sully 2022-08-23 13:39:25 -04:00 committed by GitHub Enterprise
commit 3e83935994
2 changed files with 14 additions and 4 deletions

View File

@ -771,7 +771,7 @@ unsigned long getClusterConnectionsCount(void) {
/* We decrement the number of nodes by one, since there is the /* We decrement the number of nodes by one, since there is the
* "myself" node too in the list. Each node uses two file descriptors, * "myself" node too in the list. Each node uses two file descriptors,
* one incoming and one outgoing, thus the multiplication by 2. */ * one incoming and one outgoing, thus the multiplication by 2. */
return g_pserver->cluster_enabled ? return g_pserver->cluster_enabled && g_pserver->cluster != nullptr ?
((dictSize(g_pserver->cluster->nodes)-1)*2) : 0; ((dictSize(g_pserver->cluster->nodes)-1)*2) : 0;
} }

View File

@ -2977,6 +2977,7 @@ error:
} }
void readSyncBulkPayload(connection *conn) { void readSyncBulkPayload(connection *conn) {
serverAssert(GlobalLocksAcquired());
rdbSaveInfo rsi; rdbSaveInfo rsi;
redisMaster *mi = (redisMaster*)connGetPrivateData(conn); redisMaster *mi = (redisMaster*)connGetPrivateData(conn);
static int usemark = 0; static int usemark = 0;
@ -2993,6 +2994,9 @@ void readSyncBulkPayload(connection *conn) {
return; return;
} }
if (conn != mi->repl_transfer_s)
return;
/* Final setup of the connected slave <- master link */ /* Final setup of the connected slave <- master link */
replicationCreateMasterClient(mi,mi->repl_transfer_s,rsi.repl_stream_db); replicationCreateMasterClient(mi,mi->repl_transfer_s,rsi.repl_stream_db);
if (mi->isRocksdbSnapshotRepl) { if (mi->isRocksdbSnapshotRepl) {
@ -3801,12 +3805,14 @@ int connectWithMaster(redisMaster *mi) {
* Never call this function directly, use cancelReplicationHandshake() instead. * Never call this function directly, use cancelReplicationHandshake() instead.
*/ */
void undoConnectWithMaster(redisMaster *mi) { void undoConnectWithMaster(redisMaster *mi) {
serverAssert(GlobalLocksAcquired());
auto conn = mi->repl_transfer_s; auto conn = mi->repl_transfer_s;
connSetPrivateData(conn, nullptr); connSetPrivateData(conn, nullptr);
aePostFunction(g_pserver->rgthreadvar[mi->ielReplTransfer].el, [conn]{
connClose(conn);
});
mi->repl_transfer_s = NULL; mi->repl_transfer_s = NULL;
int result = aePostFunction(g_pserver->rgthreadvar[mi->ielReplTransfer].el, [conn]{
connClose(conn);
}, false);
serverAssert(result == AE_OK);
} }
/* Abort the async download of the bulk dataset while SYNC-ing with master. /* Abort the async download of the bulk dataset while SYNC-ing with master.
@ -3961,6 +3967,10 @@ void freeMasterInfo(redisMaster *mi)
{ {
sdsfree(mi->masterauth); sdsfree(mi->masterauth);
zfree(mi->masteruser); zfree(mi->masteruser);
if (g_pserver->rdb_filename != nullptr && g_pserver->rdb_filename == mi->repl_transfer_tmpfile) {
unlink(g_pserver->rdb_filename);
g_pserver->rdb_filename = nullptr;
}
if (mi->repl_transfer_tmpfile) if (mi->repl_transfer_tmpfile)
zfree(mi->repl_transfer_tmpfile); zfree(mi->repl_transfer_tmpfile);
delete mi->staleKeyMap; delete mi->staleKeyMap;