Skip to content

Fix stream IDMP tests to recover via AOF instead of RDB - #15878

Open
kexyseeds wants to merge 2 commits into
redis:unstablefrom
kexyseeds:idmp-aof-test-coverage
Open

kexyseeds wants to merge 2 commits into
redis:unstablefrom
kexyseeds:idmp-aof-test-coverage

Conversation

@kexyseeds

@kexyseeds kexyseeds commented Sep 27, 2026 •

Copy link
Copy Markdown

While investigating #15836, I noticed three stream IDMP tests in tests/unit/type/stream.tcl that intend to verify recovery from AOF but actually recover from RDB:

  • XIDMPRECORD AOF rewrite restores IDMP
  • XIDMPRECORD AOF rewrite emits XIDMPRECORD for stream with IDMP from XIDMPRECORD only
  • XADD IDMP set in AOF

Two problems:

  1. After BGREWRITEAOF (or enabling AOF), they reload with DEBUG RELOAD, which saves the current dataset to RDB and loads it back (src/debug.c). The generated AOF is never read, so the tests pass even if the AOF recovery path drops the IDMP state.
  2. aof-use-rdb-preamble is left at its default (yes), so the rewritten base file is an RDB preamble rather than plain commands, and the XIDMPRECORD records emitted by rewriteStreamObject() are never exercised.

This PR:

  • Sets aof-use-rdb-preamble no before enabling AOF (with a comment explaining why), so the rewritten AOF is plain commands and recovery goes through XIDMPRECORD / command replay.
  • Replaces DEBUG RELOAD with DEBUG LOADAOF, which empties the dataset and loads the AOF files from disk — the same pattern already used in tests/unit/other.tcl.
  • For XADD IDMP set in AOF, recovery rides the enable-time rewrite plus the incrementally propagated XADD commands, so its comment describes that mechanism rather than the explicit-rewrite one.

Validation:

  • The three modified tests pass.
  • Sensitivity checks: with XIDMPRECORD emission temporarily disabled in rewriteStreamObject(), the two rewrite tests fail (the retry appends a new entry and returns a different ID). With the incr AOF emptied after the buffer is flushed to disk, DEBUG LOADAOF loses the stream and the dedup state — confirming the assertions are carried by the AOF file contents.
  • Full unit/type/stream passes.

One point for discussion: aof-use-rdb-preamble no is not restored afterwards and leaks to later tests on the same server. This mirrors the pre-existing appendonly yes leak in this file (the tests keep AOF enabled). If maintainers prefer, I can move these tests to a dedicated start_server {overrides {appendonly yes aof-use-rdb-preamble no}} block or restore the config explicitly.

Commits carry Signed-off-by (DCO).


Note

Low Risk
Test-only changes to stream IDMP persistence coverage; no production code paths modified.

Overview
Fixes stream IDMP AOF tests so they exercise real AOF recovery instead of accidentally passing via RDB.

Three tests in stream.tcl (XADD IDMP set in AOF, and two XIDMPRECORD rewrite cases) now set aof-use-rdb-preamble no before enabling AOF, forcing plain command AOF and rewrite paths that emit XIDMPRECORD / replay XADD rather than loading IDMP state from an RDB preamble. Recovery uses DEBUG LOADAOF instead of DEBUG RELOAD, which previously round-tripped through RDB and never read the on-disk AOF.

The rewrite tests also tighten checks after reload (e.g. dedup for a second idempotent ID, and moving duplicate assertions to post-LOADAOF in the XIDMPRECORD-only scenario).

Reviewed by Cursor Bugbot for commit a251abc. Bugbot is set up for automated code reviews on this repo. Configure here.

The two XIDMPRECORD AOF rewrite tests enabled AOF but left
aof-use-rdb-preamble at its default (yes), and reloaded the dataset
with DEBUG RELOAD, which round-trips an RDB snapshot. They therefore
passed without ever exercising the XIDMPRECORD lines emitted by a
plain command AOF rewrite.

Force a plain command AOF (aof-use-rdb-preamble no), reload with
DEBUG LOADAOF, and verify after recovery that re-sending the same
(pid, iid) returns the original stream ID without appending entries.
The XIDMPRECORD-only test now performs its first XADD IDMP validation
after recovery, so its dedup state is established solely by
XIDMPRECORD before the rewrite.

Sensitivity-checked: with XIDMPRECORD emission disabled in
rewriteStreamObject, both tests fail as intended.
Signed-off-by: kexy <77062309+kexyseeds@users.noreply.github.com>
Same defect pattern as the XIDMPRECORD AOF rewrite tests: the test used
DEBUG RELOAD, which saves and reloads an RDB snapshot, so it never
exercised AOF recovery.

Keep the AOF in plain command format (set aof-use-rdb-preamble no
before enabling AOF, so the enable-time rewrite produces a command
base) and reload with DEBUG LOADAOF, which flushes the pending buffer,
empties the dataset and loads the base and incr files from disk. The
post-reload assertions are now carried by the AOF file contents.

Signed-off-by: kexy <77062309+kexyseeds@users.noreply.github.com>
@CLAassistant

CLAassistant commented Sep 27, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@kexyseeds kexyseeds changed the title Fix stream IDMP tests to recover via AOF instead of RDBIdmp aof test coverage Fix stream IDMP tests to recover via AOF instead of RDBIdmp aof Sep 27, 2026
@kexyseeds kexyseeds changed the title Fix stream IDMP tests to recover via AOF instead of RDBIdmp aof Fix stream IDMP tests to recover via AOF instead of RDB Sep 27, 2026
@sundb
sundb requested a review from sggeorgiev September 28, 2026 02:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants