Preserve all save rules after include-based configuration rewrites
perfloop-oss/redis · Uncatalogued correctness
https://perfloop.ai/t/oss/case_fvw5bshmaa
Verdict
VERIFIED · settled 2026-11-06 · pull request opened as redis/redis#16183
What happened: The check fails before this change and passes with it.
Hypothesis
A successful configuration rewrite can write several snapshot rules, which specify when Redis saves data to disk, yet restart keeps only the last rule. Returning from an included file clears loading mode while its parent is still being parsed. A native check reproduced both lost runtime replacements and disagreement with rewrite's aggregate baseline. Deployment frequency and downstream snapshot activity remain unmeasured.
At revision 41888396080aab24ad5218f2e45e66158e24884b, loadServerConfigFromString sets reading_config_file to one on entry and zero on every successful return (src/config.c:561, 791). After a nested load returns, setConfigSaveOption therefore takes its runtime-replacement branch and resets prior rules for each later directive (3813-3866). In contrast, rewriteConfigNormalizeFileArgs accumulates save rules across includes (2632-2655). rewriteConfig dispatches rewriteConfigSaveOption, which writes a clear followed by one line per current rule when overriding includes (1630-1663). Those individually valid emitted lines are then loaded as replacements, not cumulative rules.
Property prop_70n190wnpx runs `bash tests/unit/config-rewrite-save-property/run.sh`. checkProperty run call_KiDoLBftIs6GHW2A7N0YZmoJ completed 44 successful-rewrite fixtures and printed `CONFIG_SAVE kind=exhaustive checked=44 startup_model_disagreements=4 persistence_violations=6`. Exit 1 is the final property assertion; build, startup, CONFIG SET and CONFIG REWRITE succeeded. The reduced replacement witness uses a plain include containing `save 100 1\n`, then CONFIG SET save to `300 3 400 4`. Rewrite emits `save ""`, `save 300 3`, and `save 400 4`; restart returns only `400 4`. It also fails through one wrapper. A distinct witness has an included `100 1` followed by main-file `save 200 2`; setting the combined rule list matches the read-only baseline and is skipped, then restart restores only `200 2`. All files are LF-terminated. Include bytes and the live post-rewrite value stayed unchanged as required. The run returned exact inputs for both witnesses.
This is independent of hyp_n01t503kt6: it needs neither wildcards nor an unterminated comment, and sharing wildcard stream construction would not restore the nested loading context. Combining emitted rules on one line could mask the replacement witness but would not repair the disk-equal baseline witness. Preserving the enclosing load state addresses the broader class rather than only its output-format symptom.
The accepted source-aware behavior comes from merged https://github.com/redis/redis/pull/16009. Its opt-in compatibility decision is confirmed at https://github.com/redis/redis/issues/14404#issuecomment-6620978891 and must remain intact. The inspected open https://github.com/redis/redis/pull/15712 changes save-number validation, not reading_config_file lifetime. The inspected https://github.com/redis/redis/pull/15299 proposes runtime-dirty rewrite gating and does not repair the loading context or cumulative rule emission. Open PR evidence was refreshed before publication. Older-page inspection and the private tracker linked by #16009 remain evidence gaps, not upstream clearance.
The smallest useful Case experiment is to preserve the parent's loading context across a child return and rerun the two returned witnesses, then the bounded history matrix. The proof target is persistence of the full runtime rule list and agreement between startup and rewrite's aggregate model, with explicit clears, ordinary runtime replacements and no-include histories retained as controls. The native Tcl checker and its file layout are provisional proof choices, not additional frozen placement requirements.
Change to test: Keep configuration-file loading active until the enclosing load finishes, so save directives emitted after includes accumulate rather than replace one another. Preserve explicit empty-save clears and runtime CONFIG SET replacement semantics, and keep the rewrite baseline aligned with startup's complete rule list.
Where it lives
perfloop-oss/redis · src/config.c
Evidence
The check fails before this change and passes with it: `For LF-terminated configuration histories using save pairs with canonical and startup-accepted number spellings, quoted pairs, explicit clears and zero-pair directives, Redis startup accumulates the full effective save list across completed includes. Successful file-controlled CONFIG REWRITE preserves the live list and include bytes and restores the full list across repeated rewrite/restart cycles in default, legacy, forced and source-aware modes. Source-aware comparison agrees with that aggregate. Runtime CONFIG SET replacement, the default-off source-aware option and CLI/stdin replay authority remain intact.`
The check fails before this change and passes with it: `For LF-terminated save histories with main-file includes, default and explicit legacy CONFIG REWRITE persist file and runtime rules without copying replayed CLI/stdin rules into the after-includes block. Rewrite leaves the live save list and include bytes unchanged. Repeated restarts with identical launch inputs apply the CLI/stdin rules once per start. Source-aware CLI skipping, forced serialization and default-mode behavior without includes remain unchanged.`
The check fails before this change and passes with it: `For LF-terminated histories with a narrowed save change count of 2147483648 or 4294967295 retained through direct or wrapping includes, with file-only, CLI or stdin replay, failed multi-option CONFIG SET preserves the complete pre-command save list after setter-validation or listener-apply failure. In default and source-aware rewrite modes, CONFIG REWRITE leaves the live list and included bytes unchanged and restores the complete list across two restarts with identical launch inputs. CONFIG GET retains signed stored-count output.`
Checks: 2 of 2 passed. Verification: no defect found.
Timeline
2026-11-05· Case opened2026-11-06· PR opened