Skip to content

Conversation

@tezc
Copy link
Collaborator

@tezc tezc commented Jan 20, 2025

During fullsync, before loading RDB on the replica, we stop aof child to prevent copy-on-write disaster.
Once rdb is loaded, aof is started again and it will trigger aof rewrite. With #13732 , for rdbchannel replication, this behavior was changed. Currently, we start aof after replication buffer is streamed to db. This PR changes it back to start aof just after rdb is loaded (before repl buffer is streamed)

Both approaches may have pros and cons. If we start aof before streaming repl buffers, we may still face with copy-on-write issues as repl buffers potentially include large amount of changes. If we wait until replication buffer drained, it means we are delaying starting aof persistence.

Additional changes are introduced as part of this PR:

  • Interface change:
    Added mem_replica_full_sync_buffer field to the INFO MEMORY command reply. During full sync, it shows total memory consumed by accumulated replication stream buffer on replica. Added same metric to MEMORY STATS command reply as replica.fullsync.buffer field.

  • Fixes:

    • Count repl stream buffer size of replica as part of 'memory overhead' calculation for fields in "INFO MEMORY" and "MEMORY STATS" outputs. Before this PR, repl buffer was not counted as part of memory overhead calculation, causing misreports for fields like used_memory_overhead and used_memory_dataset in "INFO STATS" and for overhead.total field in "MEMORY STATS" command reply.
    • Dismiss replication stream buffers memory of replica in the fork to reduce COW impact during a fork.
    • Fixed a few time sensitive flaky tests, deleted a noop statement, fixed some comments and fail messages in rdbchannel tests.

@tezc tezc requested a review from oranagra January 20, 2025 08:18
Copy link
Member

@oranagra oranagra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.
please list the interface changes in the PR description.
@YaacovHazan please comment on how do we formally approve them?

@tezc tezc added release-notes indication that this issue needs to be mentioned in the release notes state:needs-doc-pr requires a PR to redis-doc repository labels Jan 28, 2025
@YaacovHazan
Copy link
Collaborator

@oranagra This is an internal mechanism in Redis, and we don't need to get approval for that... we do need to communicate the change, so we are good to merge it

@tezc tezc merged commit 09f8a2f into redis:unstable Feb 4, 2025
19 checks passed
@tezc tezc deleted the revert-aofrw branch February 4, 2025 18:40
funny-dog pushed a commit to funny-dog/redis that referenced this pull request Sep 17, 2025
During fullsync, before loading RDB on the replica, we stop aof child to
prevent copy-on-write disaster.
Once rdb is loaded, aof is started again and it will trigger aof
rewrite. With redis#13732 , for rdbchannel
replication, this behavior was changed. Currently, we start aof after
replication buffer is streamed to db. This PR changes it back to start
aof just after rdb is loaded (before repl buffer is streamed)

Both approaches may have pros and cons. If we start aof before streaming
repl buffers, we may still face with copy-on-write issues as repl
buffers potentially include large amount of changes. If we wait until
replication buffer drained, it means we are delaying starting aof
persistence.

Additional changes are introduced as part of this PR:

- Interface change:
Added `mem_replica_full_sync_buffer` field to the `INFO MEMORY` command
reply. During full sync, it shows total memory consumed by accumulated
replication stream buffer on replica. Added same metric to `MEMORY
STATS` command reply as `replica.fullsync.buffer` field.
  
  
- Fixes: 
- Count repl stream buffer size of replica as part of 'memory overhead'
calculation for fields in "INFO MEMORY" and "MEMORY STATS" outputs.
Before this PR, repl buffer was not counted as part of memory overhead
calculation, causing misreports for fields like `used_memory_overhead`
and `used_memory_dataset` in "INFO STATS" and for `overhead.total` field
in "MEMORY STATS" command reply.
- Dismiss replication stream buffers memory of replica in the fork to
reduce COW impact during a fork.
- Fixed a few time sensitive flaky tests, deleted a noop statement,
fixed some comments and fail messages in rdbchannel tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-notes indication that this issue needs to be mentioned in the release notes state:needs-doc-pr requires a PR to redis-doc repository

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants