masterTryPartialResynchronization 函数中的相关代码如下:
/* We still have the data our slave is asking for? */
if (!server.repl_backlog ||
psync_offset < server.repl_backlog_off ||
psync_offset > (server.repl_backlog_off + server.repl_backlog_histlen)) {
serverLog(LL_NOTICE,
"Unable to partial resync with replica %s for lack of backlog (Replica request was: %lld).",
replicationGetSlaveName(c), psync_offset);
if (psync_offset > server.master_repl_offset) {
serverLog(LL_WARNING,
"Warning: replica %s tried to PSYNC with an offset that is greater than the master replication offset.",
replicationGetSlaveName(c));
}
goto need_full_resync;
}
上面的代码进行了前置判断,如果从节点的读位置对应的数据丢失了,就需要执行全量复制。这种情况不会执行到 addReplyReplicationBacklog 函数中。