Skip to content

Commit

Permalink
replication test wip
Browse files Browse the repository at this point in the history
  • Loading branch information
enjoy-binbin committed Mar 13, 2023
1 parent 7be7834 commit 2cbbf63
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/replication.c
Expand Up @@ -332,8 +332,6 @@ void feedReplicationBuffer(char *s, size_t len) {
static long long repl_block_id = 0;

if (server.repl_backlog == NULL) return;
server.master_repl_offset += len;
server.repl_backlog->histlen += len;

while(len > 0) {
size_t start_pos = 0; /* The position of referenced block to start sending. */
Expand All @@ -354,6 +352,8 @@ void feedReplicationBuffer(char *s, size_t len) {
tail->used += copy;
s += copy;
len -= copy;
server.master_repl_offset += copy;
server.repl_backlog->histlen += copy;
}
if (len) {
/* Create a new node, make sure it is allocated to at
Expand All @@ -369,7 +369,6 @@ void feedReplicationBuffer(char *s, size_t len) {
size_t copy = (tail->size >= len) ? len : tail->size;
tail->used = copy;
tail->refcount = 0;
tail->repl_offset = server.master_repl_offset - tail->used + 1;
tail->id = repl_block_id++;
memcpy(tail->buf, s, copy);
listAddNodeTail(server.repl_buffer_blocks, tail);
Expand All @@ -382,6 +381,9 @@ void feedReplicationBuffer(char *s, size_t len) {
}
s += copy;
len -= copy;
server.master_repl_offset += copy;
server.repl_backlog->histlen += copy;
tail->repl_offset = server.master_repl_offset - tail->used + 1;

This comment has been minimized.

Copy link
@sundb

sundb Mar 13, 2023

It can be changed to tail->repl_offset = server.master_repl_offset + 1; and moved to after tail->refcount = 0;.

This comment has been minimized.

Copy link
@enjoy-binbin

enjoy-binbin Mar 13, 2023

Author Owner

yean, good catch.

I actually realized later, the current fix is just a test/tmp version.

}

/* For output buffer of replicas. */
Expand Down

0 comments on commit 2cbbf63

Please sign in to comment.