Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/aof.c
Original file line number Diff line number Diff line change
Expand Up @@ -1208,8 +1208,11 @@ void flushAppendOnlyFile(int force) {
* This is needed to avoid a WAITAOF hang in case a module used RM_Call with the NO_AOF flag,
* in which case primary_repl_offset will increase but fsynced_reploff_pending won't be updated
* (because there's no reason, from the AOF POV, to call fsync) and then WAITAOF may wait on
* the higher offset (which contains data that was only propagated to replicas, and not to AOF) */
if (!sync_in_progress && server.aof_fsync != AOF_FSYNC_NO)
* the higher offset (which contains data that was only propagated to replicas, and not to AOF).
* aof_last_incr_fsync_offset advances when an fsync is requested, not when it completes, so
* also wait for the background fsync jobs, which publish the offset when the fsync succeeds. */
if (server.aof_fsync != AOF_FSYNC_NO && server.aof_last_incr_fsync_offset == server.aof_last_incr_size &&
!aofFsyncInProgress() && !bioPendingJobsOfType(BIO_CLOSE_AOF))
atomic_store_explicit(&server.fsynced_reploff_pending, server.primary_repl_offset,
memory_order_relaxed);
return;
Expand Down
24 changes: 24 additions & 0 deletions tests/unit/wait.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,30 @@ tags {"wait aof network external:skip"} {
assert_equal [$master waitaof 1 0 0] {1 0}
}

test {WAITAOF local copy everysec does not ack a write that was not fsynced} {
# Fsync now, so the next write lands inside the one second window of everysec.
test_config_set r appendfsync always
$master incr foo
$master config set appendfsync everysec

# With no-appendfsync-on-rewrite and a child process, the write reaches the
# AOF but no fsync happens until the child exits.
test_config_set r no-appendfsync-on-rewrite yes
test_config_set r rdb-key-save-delay 100000000
$master bgsave
test_defer {
catch {exec kill -9 [get_child_pid 0]}
waitForBgsave r
}
assert_equal [s rdb_bgsave_in_progress] 1
$master incr foo
assert_equal [$master waitaof 1 0 100] {0 0} ;# exits on timeout

catch {exec kill -9 [get_child_pid 0]}
waitForBgsave r
assert_equal [$master waitaof 1 0 10000] {1 0}
}

test {WAITAOF local copy with appendfsync always} {
r config set appendfsync always
$master incr foo
Expand Down
Loading