这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@sundb
Copy link
Collaborator

@sundb sundb commented Sep 1, 2025

This PR fixes three defrag issues.

  1. Fix the issue that forget to update cgroup_ref_node when the consume group was reallocated.
    This crash was introduced by Add XDELEX and XACKDEL commands for stream #14130
    In this PR, when performing defragmentation on s->cgroups using defragRadixTree(), we no longer rely on the automatic data defragmentation of defragRadixTree(). Instead, we manually defragment the consumer group and then update its reference in s->cgroups.

  2. Fix a use-after-free issue caused by updating dictionary keys after HFE key is reallocated.
    This issue was introduced by Add support to defrag ebuckets incrementally #13842

  3. Fix the issue that forgot to be updated NextSegHdr->firstSeg when the first segment was reallocated.
    This issue was introduced by Add support to defrag ebuckets incrementally #13842

Note that both of these issues were introduced since 8.2, so we can fix them together.

@snyk-io
Copy link

snyk-io bot commented Sep 1, 2025

🎉 Snyk checks have passed. No issues have been found so far.

security/snyk check is complete. No issues have been found. (View Details)

license/snyk check is complete. No issues have been found. (View Details)

@sundb sundb requested a review from Copilot September 1, 2025 10:49

This comment was marked as outdated.

@github-project-automation github-project-automation bot moved this to Todo in Redis 8.4 Sep 1, 2025
@sundb sundb added the release-notes indication that this issue needs to be mentioned in the release notes label Sep 1, 2025
@sundb sundb changed the title Fix crash during stream defrag Fix crash during stream defrag and HFE defrag Sep 4, 2025
@sundb sundb requested a review from Copilot September 4, 2025 06:21
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a crash during stream defragmentation and HFE defragmentation that was introduced by a previous issue. The crash occurs due to a mismatch between consumer group references after defragmentation operations.

  • Fixed consumer group reference updates during stream defragmentation
  • Added manual defragmentation for consumer groups with proper reference tracking
  • Corrected the order of operations in HFE defragmentation to prevent race conditions

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@sundb sundb requested a review from moticless September 4, 2025 06:58
@sundb sundb changed the title Fix crash during stream defrag and HFE defrag Fix defrag issues for stream defrag and HFE Sep 4, 2025
src/ebuckets.c Outdated
if (newSegHdr) {
/* Update next segment's prev to point to the defragmented segment. */
nextSegHdr->prevSeg = newSegHdr;
nextSegHdr->firstSeg = (FirstSegHdr *)firstSegHdr;
Copy link
Member

Choose a reason for hiding this comment

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

don't we need to update that on all segments? (not just when newSegHdr is non NULL)
i.e. don't depend on newSegHdr, but rather add a var newFirstSegHdr? or just update unconditionally?

@oranagra
Copy link
Member

oranagra commented Sep 8, 2025

LGTM. looks like an unrelated threshold issue in the test, please confirm.

@sundb
Copy link
Collaborator Author

sundb commented Sep 8, 2025

@oranagra it's a known issue that doesn't relate to this PR.

@sundb sundb merged commit d649637 into redis:unstable Sep 8, 2025
18 of 19 checks passed
@github-project-automation github-project-automation bot moved this from Todo to Done in Redis 8.4 Sep 8, 2025
Polaris-911 added a commit to Polaris-911/redis that referenced this pull request Sep 9, 2025
YaacovHazan pushed a commit to YaacovHazan/redis that referenced this pull request Sep 28, 2025
This PR fixes three defrag issues.

1. Fix the issue that forget to update cgroup_ref_node when the consume
group was reallocated.
This crash was introduced by redis#14130
In this PR, when performing defragmentation on `s->cgroups` using
`defragRadixTree()`, we no longer rely on the automatic data
defragmentation of `defragRadixTree()`. Instead, we manually defragment
the consumer group and then update its reference in `s->cgroups`.

2. Fix a use-after-free issue caused by updating dictionary keys after
HFE key is reallocated.
This issue was introduced by redis#13842

3. Fix the issue that forgot to be updated NextSegHdr->firstSeg when the
first segment was reallocated.
This issue was introduced by redis#13842

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-notes indication that this issue needs to be mentioned in the release notes

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants