Skip to content

Do not record a cancelled forkless save as failed - #4524

Open
nitaicaro wants to merge 1 commit into
valkey-io:forklessfrom
nitaicaro:forkless-fix-cancel-not-error-v2
Open

Do not record a cancelled forkless save as failed#4524
nitaicaro wants to merge 1 commit into
valkey-io:forklessfrom
nitaicaro:forkless-fix-cancel-not-error-v2

Conversation

@nitaicaro

@nitaicaro nitaicaro commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

A cancelled forkless save (BGSAVE CANCEL, or a flush that aborts the iterator) was recorded as a failed save.

Existing fork behavior:

  • FLUSHDB during a fork save: the save is unaffected. The fork child holds a copy-on-write snapshot, so wiping the live DB does not touch it and the save completes.
  • FLUSHALL during a fork save: the save is aborted (via SIGUSR1, which is whitelisted as not a failure) and a fresh save runs.

For forkless we want to match that, but for FLUSHDB we can't: forkless has no copy-on-write protection, and expediting the write of the the entire db is too much. So we match it to the best of our abilities - forkless treats both FLUSHDB and FLUSHALL the way fork treats FLUSHALL - as an intentional abort.

Treat an intentional cancel like the fork child's SIGUSR1 whitelist: skip recording end metrics and the persistence event, leaving lastbgsave_status untouched. When a key write fails only because the save is being terminated, clear the error so it is classified as a cancel rather than a failure. A genuine write error is still recorded as a failure.

@coderabbitai

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 8e7bcfbf-5597-4b15-9921-5a316ed1a55a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nitaicaro nitaicaro changed the title Do not record a cancelled save as failed Do not record a cancelled forkless save as failed Aug 26, 2026

@valkey-review-bot valkey-review-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The cancellation classification needs to distinguish an abort-caused write failure from a real error, and forkless cancellation still needs to close the module persistence-event lifecycle.

Comment thread src/forkless.c
Comment thread src/forkless.c Outdated
@codecov

codecov Bot commented Aug 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.41%. Comparing base (ccd15a1) to head (50d9b1e).
⚠️ Report is 2 commits behind head on forkless.

Additional details and impacted files
@@             Coverage Diff              @@
##           forkless    #4524      +/-   ##
============================================
- Coverage     80.27%   79.41%   -0.87%     
============================================
  Files           176      175       -1     
  Lines         97654    93238    -4416     
============================================
- Hits          78396    74047    -4349     
+ Misses        19258    19191      -67     
Files with missing lines Coverage Δ
src/forkless.c 84.95% <100.00%> (+1.47%) ⬆️

... and 27 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

A cancelled forkless save (BGSAVE CANCEL, or a flush that aborts the
iterator) was recorded as a failed save. With a save point configured and
stop-writes-on-bgsave-error on, that denied every write with -MISCONF
until the next successful save.

Existing fork behavior:
- FLUSHDB during a fork save: the save is unaffected. The fork child holds
  a copy-on-write snapshot, so wiping the live DB does not touch it and the
  save completes.
- FLUSHALL during a fork save: the save is aborted (via SIGUSR1, which is
  whitelisted as not a failure) and a fresh save runs.

For forkless we want to match that, but for FLUSHDB we can't: forkless has
no copy-on-write protection and iterates the live data, so when the flushed
data is deleted we have to abort the save there too. So forkless treats
both FLUSHDB and FLUSHALL the way fork treats FLUSHALL: an intentional
abort, not a failure.

Treat an intentional cancel like the fork child's SIGUSR1 whitelist: skip
recording end metrics and the persistence event, leaving lastbgsave_status
untouched. When a key write fails only because the save is being
terminated, clear the error so it is classified as a cancel rather than a
failure. A genuine write error is still recorded as a failure.

Signed-off-by: Nitai Caro <caronita@amazon.com>
@nitaicaro
nitaicaro force-pushed the forkless-fix-cancel-not-error-v2 branch from 50d9b1e to 6355e7c Compare August 27, 2026 00:16
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.

1 participant