Skip to content

Fix SkipTo edge case - [MOD-8561 MOD-8673]#5591

Merged
GuyAv46 merged 9 commits intomasterfrom
guyav-fix_skipto_bug
Feb 3, 2025
Merged

Fix SkipTo edge case - [MOD-8561 MOD-8673]#5591
GuyAv46 merged 9 commits intomasterfrom
guyav-fix_skipto_bug

Conversation

@GuyAv46
Copy link
Collaborator

@GuyAv46 GuyAv46 commented Feb 2, 2025

Describe the changes in the pull request

Fix a bug in the GC, which should update the last ID of an inverted index when cleaning it, in case it was modified.

This last ID in the index is used in the inverted-index reader iterator to test if we can expect more results from this iterator quickly.

An edge case where the last id(s) were deleted and this value was not up-to-date could cause the index reader iterator to assume it has a block to skip to, while that's not the case, causing unsafe access to the end of the block array.

Which additional issues this PR fixes

  1. MOD-8673
  2. [CRASH] RediSearch Crash after working for several hours, with Redis 7.2.0 crashed by signal: 11, si_code: 128 and Accessing address: (nil) #5517
  3. [BUG] Redis 7.4.2 crashed by signal: 11, si_code: 128 - intermittently when running FT.SEARCH #5532
  4. [BUG] #5594
  5. [BUG] Segmentation fault Redis 6.2.17 crashed by signal: 11, si_code: 128 #5601
  6. [BUG] One more Redis 7.4.2 crashed by signal: 11, si_code: 128 #5604

Main objects this PR modified

  1. Add assertions to verify block index ranges
  2. Fix the GC apply function

Mark if applicable

  • This PR introduces API changes
  • This PR introduces serialization changes


idx->numDocs -= info->ndocsCollected;
idx->gcMarker++;
idx->lastId = idx->blocks[idx->size - 1].lastId; // Update lastId
Copy link
Collaborator

Choose a reason for hiding this comment

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

isn't it possible idx->size is zero?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nope. If we delete all the blocks, we add an empty one.
Yet, I can add a validation here

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think let's have an assertion, max

@codecov
Copy link

codecov bot commented Feb 2, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.27%. Comparing base (8fe6870) to head (961f62e).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #5591   +/-   ##
=======================================
  Coverage   87.27%   87.27%           
=======================================
  Files         196      196           
  Lines       35285    35288    +3     
=======================================
+ Hits        30795    30798    +3     
  Misses       4490     4490           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@GuyAv46 GuyAv46 requested a review from kei-nan February 2, 2025 17:18
raz-mon
raz-mon previously approved these changes Feb 2, 2025
Copy link
Collaborator

@raz-mon raz-mon left a comment

Choose a reason for hiding this comment

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

AMAZING


idx->numDocs -= info->ndocsCollected;
idx->gcMarker++;
idx->lastId = idx->blocks[idx->size - 1].lastId; // Update lastId
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think let's have an assertion, max

@GuyAv46 GuyAv46 changed the title Fix SkipTo edge case - [MOD-] Fix SkipTo edge case - [MOD-8561] Feb 2, 2025
@raz-mon raz-mon changed the title Fix SkipTo edge case - [MOD-8561] Fix SkipTo edge case - [MOD-8561 MOD-8673] Feb 3, 2025
@GuyAv46 GuyAv46 added this pull request to the merge queue Feb 3, 2025
Merged via the queue into master with commit c29e9bc Feb 3, 2025
10 checks passed
@GuyAv46 GuyAv46 deleted the guyav-fix_skipto_bug branch February 3, 2025 10:48
@redisearch-backport-pull-request
Copy link
Contributor

Backport failed for 2.8, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin 2.8
git worktree add -d .worktree/backport-5591-to-2.8 origin/2.8
cd .worktree/backport-5591-to-2.8
git switch --create backport-5591-to-2.8
git cherry-pick -x c29e9bccd5136fec493245810e316fb9b8da4cdf

@redisearch-backport-pull-request
Copy link
Contributor

Backport failed for 2.6, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin 2.6
git worktree add -d .worktree/backport-5591-to-2.6 origin/2.6
cd .worktree/backport-5591-to-2.6
git switch --create backport-5591-to-2.6
git cherry-pick -x c29e9bccd5136fec493245810e316fb9b8da4cdf

@redisearch-backport-pull-request
Copy link
Contributor

Backport failed for 2.10, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin 2.10
git worktree add -d .worktree/backport-5591-to-2.10 origin/2.10
cd .worktree/backport-5591-to-2.10
git switch --create backport-5591-to-2.10
git cherry-pick -x c29e9bccd5136fec493245810e316fb9b8da4cdf

redisearch-backport-pull-request bot pushed a commit that referenced this pull request Feb 3, 2025
* add a failing test

* add an assertion

* fix the bug

* add another assertion

* add another scenario

* add an assertion to the gc

* rename test

* simplified test

* simplified simplification

(cherry picked from commit c29e9bc)
@redisearch-backport-pull-request
Copy link
Contributor

Successfully created backport PR for 8.0:

github-merge-queue bot pushed a commit that referenced this pull request Feb 3, 2025
Fix SkipTo edge case - [MOD-8561 MOD-8673] (#5591)

* add a failing test

* add an assertion

* fix the bug

* add another assertion

* add another scenario

* add an assertion to the gc

* rename test

* simplified test

* simplified simplification

(cherry picked from commit c29e9bc)

Co-authored-by: GuyAv46 <[email protected]>
GuyAv46 added a commit that referenced this pull request Feb 4, 2025
* add a failing test

* add an assertion

* fix the bug

* add another assertion

* add another scenario

* add an assertion to the gc

* rename test

* simplified test

* simplified simplification

(cherry picked from commit c29e9bc)
GuyAv46 added a commit that referenced this pull request Feb 4, 2025
* add a failing test

* add an assertion

* fix the bug

* add another assertion

* add another scenario

* add an assertion to the gc

* rename test

* simplified test

* simplified simplification

(cherry picked from commit c29e9bc)
GuyAv46 added a commit that referenced this pull request Feb 4, 2025
* add a failing test

* add an assertion

* fix the bug

* add another assertion

* add another scenario

* add an assertion to the gc

* rename test

* simplified test

* simplified simplification

(cherry picked from commit c29e9bc)
github-merge-queue bot pushed a commit that referenced this pull request Feb 5, 2025
Fix SkipTo edge case - [MOD-8561 MOD-8673] (#5591)

* add a failing test

* add an assertion

* fix the bug

* add another assertion

* add another scenario

* add an assertion to the gc

* rename test

* simplified test

* simplified simplification

(cherry picked from commit c29e9bc)
github-merge-queue bot pushed a commit that referenced this pull request Feb 5, 2025
Fix SkipTo edge case - [MOD-8561 MOD-8673] (#5591)

* add a failing test

* add an assertion

* fix the bug

* add another assertion

* add another scenario

* add an assertion to the gc

* rename test

* simplified test

* simplified simplification

(cherry picked from commit c29e9bc)
github-merge-queue bot pushed a commit that referenced this pull request Feb 5, 2025
Fix SkipTo edge case - [MOD-8561 MOD-8673] (#5591)

* add a failing test

* add an assertion

* fix the bug

* add another assertion

* add another scenario

* add an assertion to the gc

* rename test

* simplified test

* simplified simplification

(cherry picked from commit c29e9bc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants