From 7997874f4d2be9da1e26c77804569b0057c1e0a2 Mon Sep 17 00:00:00 2001 From: Binbin Date: Mon, 13 Mar 2023 22:12:29 +0800 Subject: Fix tail->repl_offset update in feedReplicationBuffer (#11905) In #11666, we added a while loop and will split a big reply node to multiple nodes. The update of tail->repl_offset may be wrong. Like before #11666, we would have created at most one new reply node, and now we will create multiple nodes if it is a big reply node. Now we are creating more than one node, and the tail->repl_offset of all the nodes except the last one are incorrect. Because we update master_repl_offset at the beginning, and then use it to update the tail->repl_offset. This would have lead to an assertion during PSYNC, a test was added to validate that case. Besides that, the calculation of size was adjusted to fix tests that failed due to a combination of a very low backlog size, and some thresholds of that get violated because of the relatively high overhead of replBufBlock. So now if the backlog size / 16 is too small, we'll take PROTO_REPLY_CHUNK_BYTES instead. Co-authored-by: Oran Agra --- tests/integration/replication-buffer.tcl | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/integration/replication-buffer.tcl b/tests/integration/replication-buffer.tcl index fe85632ae..2e402480d 100644 --- a/tests/integration/replication-buffer.tcl +++ b/tests/integration/replication-buffer.tcl @@ -267,7 +267,7 @@ test {Replica client-output-buffer size is limited to backlog_limit/16 when no r wait_for_ofs_sync $master $replica # Write another key to force the test to wait for another event loop iteration - # to give the serverCron a chance to disconnect replicas with COB size exeeeding the limits + # to give the serverCron a chance to disconnect replicas with COB size exceeding the limits $master set key1 "1" wait_for_ofs_sync $master $replica @@ -280,6 +280,16 @@ test {Replica client-output-buffer size is limited to backlog_limit/16 when no r } assert {[status $master sync_partial_ok] == 0} + + # Before this fix (#11905), the test would trigger an assertion in 'o->used >= c->ref_block_pos' + test {The update of replBufBlock's repl_offset is ok - Regression test for #11666} { + set rd [redis_deferring_client] + set replid [status $master master_replid] + set offset [status $master repl_backlog_first_byte_offset] + $rd psync $replid $offset + assert_equal {PONG} [$master ping] ;# Make sure the master doesn't crash. + $rd close + } } } } -- cgit v1.2.1