提交 189a12af 编写于 作者: A antirez

PSYNC2: discard pending transactions from cached master.

During the review of the fix for #3899, @yangsiran identified an
implementation bug: given that the offset is now relative to the applied
part of the replication log, when we cache a master, the successive
PSYNC2 request will be made in order to *include* the transaction that
was not completely processed. This means that we need to discard any
pending transaction from our replication buffer: it will be re-executed.
上级 22be435e
......@@ -2120,10 +2120,12 @@ void replicationCacheMaster(client *c) {
unlinkClient(c);
/* Fix the master specific fields: we want to discard to non processed
* query buffers and non processed offsets. */
* query buffers and non processed offsets, including pending
* transactions. */
sdsclear(server.master->querybuf);
sdsclear(server.master->pending_querybuf);
server.master->read_reploff = server.master->reploff;
if (c->flags & CLIENT_MULTI) discardTransaction(c);
/* Save the master. Server.master will be set to null later by
* replicationHandleMasterDisconnection(). */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册