Skip to content

fix(set): propagate storage errors in Set instead of treating as NotFound#3428

Merged
jihuayu merged 4 commits into
apache:unstablefrom
songqing:fix/set-add-error-handling
Apr 9, 2026
Merged

fix(set): propagate storage errors in Set instead of treating as NotFound#3428
jihuayu merged 4 commits into
apache:unstablefrom
songqing:fix/set-add-error-handling

Conversation

@songqing

@songqing songqing commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

Previously, when storage_->Get() returned a non-NotFound error (e.g., I/O error or corruption) during SADD, the code fell through to the batch->Put path, incorrectly treating the error as "member not found" and adding the member. This could silently inflate metadata.size and insert duplicate members on storage failures.

Add an explicit !s.IsNotFound() check to propagate real errors, which is consistent with how Set::Remove already handles the same pattern.

@jihuayu jihuayu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Great!
It seems SREM has the same issue. Could you fix it as well and add the corresponding test cases?

@songqing songqing force-pushed the fix/set-add-error-handling branch from 61465b4 to d52e83d Compare April 8, 2026 08:35
@songqing songqing changed the title fix(set): propagate storage errors in Set::Add instead of treating as NotFound fix(set): propagate storage errors in Set instead of treating as NotFound Apr 8, 2026
@songqing

songqing commented Apr 8, 2026

Copy link
Copy Markdown
Contributor Author

Great! It seems SREM has the same issue. Could you fix it as well and add the corresponding test cases?
done

@jihuayu jihuayu enabled auto-merge (squash) April 8, 2026 13:24
@jihuayu jihuayu merged commit b272b5c into apache:unstable Apr 9, 2026
70 of 73 checks passed
@sonarqubecloud

sonarqubecloud Bot commented Apr 9, 2026

Copy link
Copy Markdown

nagisa-kunhah pushed a commit to nagisa-kunhah/kvrocks that referenced this pull request Apr 29, 2026
…ound (apache#3428)

Previously, when `storage_->Get()` returned a non-NotFound error (e.g.,
I/O error or corruption) during SADD, the code fell through to the
`batch->Put` path, incorrectly treating the error as "member not found"
and adding the member. This could silently inflate `metadata.size` and
insert duplicate members on storage failures.

Add an explicit `!s.IsNotFound()` check to propagate real errors, which
is consistent with how `Set::Remove` already handles the same pattern.

---------

Co-authored-by: 纪华裕 <jihuayu123@gmail.com>
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.

3 participants