diff --git a/src/aof.cpp b/src/aof.cpp index 326c30ba2..f99a90b2e 100644 --- a/src/aof.cpp +++ b/src/aof.cpp @@ -870,6 +870,11 @@ int loadAppendOnlyFile(char *filename) { fakeClient = createAOFClient(); startLoadingFile(fp, filename, RDBFLAGS_AOF_PREAMBLE); + for (int idb = 0; idb < cserver.dbnum; ++idb) + { + g_pserver->db[idb]->trackChanges(true); + } + /* Check if this AOF file has an RDB preamble. In that case we need to * load the RDB file and later continue loading the AOF tail. */ char sig[5]; /* "REDIS" */ @@ -892,11 +897,6 @@ int loadAppendOnlyFile(char *filename) { } } - for (int idb = 0; idb < cserver.dbnum; ++idb) - { - g_pserver->db[idb]->trackChanges(true); - } - /* Read the actual AOF file, in REPL format, command by command. */ while(1) { int argc, j; diff --git a/src/replication.cpp b/src/replication.cpp index 2618a605f..d99346a57 100644 --- a/src/replication.cpp +++ b/src/replication.cpp @@ -975,14 +975,8 @@ public: aeAcquireLock(); } - if (ireplica == replicas.size()-1 && replica->replyAsync == nullptr) { - if (prepareClientToWrite(replica) == C_OK) { - replica->replyAsync = reply; - reply = nullptr; - } - } else { - addReplyProto(replica, reply->buf(), reply->size); - } + std::unique_lock lock(replica->lock); + addReplyProto(replica, reply->buf(), reply->used); } ProcessPendingAsyncWrites(); replicas.erase(std::remove_if(replicas.begin(), replicas.end(), [](const client *c)->bool{ return c->flags.load(std::memory_order_relaxed) & CLIENT_CLOSE_ASAP;}), replicas.end()); @@ -1089,7 +1083,7 @@ int rdbSaveSnapshotForReplication(struct rdbSaveInfo *rsi) { spreplBuf->addLong(rsi->repl_stream_db); spreplBuf->addArrayLen(2); spreplBuf->addString("repl-id", 7); - spreplBuf->addString(rsi->repl_id, CONFIG_RUN_ID_SIZE+1); + spreplBuf->addString(rsi->repl_id, CONFIG_RUN_ID_SIZE); spreplBuf->addArrayLen(2); spreplBuf->addString("repl-offset", 11); spreplBuf->addLong(rsi->master_repl_offset); @@ -1387,7 +1381,7 @@ void syncCommand(client *c) { /* CASE 0: Fast Sync */ if ((c->slave_capa & SLAVE_CAPA_ROCKSDB_SNAPSHOT) && g_pserver->m_pstorageFactory) { - startBgsaveForReplication(c->slave_capa); + serverLog(LL_NOTICE,"Fast SYNC on next replication cycle"); /* CASE 1: BGSAVE is in progress, with disk target. */ } else if (g_pserver->FRdbSaveInProgress() && g_pserver->rdb_child_type == RDB_CHILD_TYPE_DISK)