Skip to content

fix: remove draining from Flush callback#7420

Merged
JoanFM merged 4 commits intomasterfrom
joan-remove-flush-drain
Nov 22, 2025
Merged

fix: remove draining from Flush callback#7420
JoanFM merged 4 commits intomasterfrom
joan-remove-flush-drain

Conversation

@JoanFM
Copy link
Collaborator

@JoanFM JoanFM commented Nov 19, 2025

Describe the changes in the pull request

Remove Draining from onFlush callback


Note

Stop draining the workers thread pool in onFlush and add a test that exercises querying during FLUSHALL and after creating a new index.

  • Flush handling:
    • Remove call to workersThreadPool_Drain(ctx, 0) from onFlush in src/spec.c.
  • Tests:
    • Add tests/pytests/test_query_while_flush.py to continuously query an index before/after FLUSHALL, verify expected errors post-flush, and validate new index queries succeed.

Written by Cursor Bugbot for commit 3b10983. This will update automatically on new commits. Configure here.

@codecov
Copy link

codecov bot commented Nov 19, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.87%. Comparing base (47e2c4f) to head (3b10983).
⚠️ Report is 27 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7420      +/-   ##
==========================================
+ Coverage   84.85%   84.87%   +0.02%     
==========================================
  Files         346      347       +1     
  Lines       53208    53716     +508     
  Branches    13935    14292     +357     
==========================================
+ Hits        45148    45592     +444     
- Misses       7866     7928      +62     
- Partials      194      196       +2     
Flag Coverage Δ
flow 84.72% <ø> (+0.27%) ⬆️
unit 52.36% <ø> (+0.13%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Collaborator

@alonre24 alonre24 left a comment

Choose a reason for hiding this comment

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

What would happen if we call flushall while jobs are pending (due to not draining), and then we immediately create a new index and push new jobs? Should we test such a scenario?

@JoanFM
Copy link
Collaborator Author

JoanFM commented Nov 20, 2025

What would happen if we call flushall while jobs are pending (due to not draining), and then we immediately create a new index and push new jobs? Should we test such a scenario?

Okey, but I guess the expected behavior is that the queries that were queued before and during FLUSHALL will fail and the subsequent ones should succeed right?

@JoanFM
Copy link
Collaborator Author

JoanFM commented Nov 20, 2025

What would happen if we call flushall while jobs are pending (due to not draining), and then we immediately create a new index and push new jobs? Should we test such a scenario?

What seems weird to me is that we are draining but after we have freed spectdict_g, so isn't there a chance that one of the workers could try to access an invalid struct?

@JoanFM JoanFM force-pushed the joan-remove-flush-drain branch from 244ee7f to 22c2d75 Compare November 20, 2025 12:49
@alonre24
Copy link
Collaborator

What would happen if we call flushall while jobs are pending (due to not draining), and then we immediately create a new index and push new jobs? Should we test such a scenario?

Okey, but I guess the expected behavior is that the queries that were queued before and during FLUSHALL will fail and the subsequent ones should succeed right?

yes.

@alonre24
Copy link
Collaborator

What would happen if we call flushall while jobs are pending (due to not draining), and then we immediately create a new index and push new jobs? Should we test such a scenario?

What seems weird to me is that we are draining but after we have freed spectdict_g, so isn't there a chance that one of the workers could try to access an invalid struct?

Only the main thread is allowed to access the specdict_g struct AFAIK

from common import *

@skip(cluster=True)
def test_query_while_flush(env):
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should create an env with workers, no?
Also consider using getWorkersThpoolStats for validation

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

oh sure, will create with WORKERS

@JoanFM JoanFM requested review from GuyAv46 and alonre24 November 20, 2025 15:35
@JoanFM JoanFM added this pull request to the merge queue Nov 22, 2025
Merged via the queue into master with commit e56bf5b Nov 22, 2025
25 checks passed
@JoanFM JoanFM deleted the joan-remove-flush-drain branch November 22, 2025 02:42
@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-7420-to-2.8 origin/2.8
cd .worktree/backport-7420-to-2.8
git switch --create backport-7420-to-2.8
git cherry-pick -x e56bf5bd7abca36aad32d6cae4c1d433c288ae3a

@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-7420-to-2.10 origin/2.10
cd .worktree/backport-7420-to-2.10
git switch --create backport-7420-to-2.10
git cherry-pick -x e56bf5bd7abca36aad32d6cae4c1d433c288ae3a

redisearch-backport-pull-request bot pushed a commit that referenced this pull request Nov 22, 2025
* fix: remove draining from Flush callback

* test: add test for query while flushall

* improve testing with workers

* improve test

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

Successfully created backport PR for 8.2:

redisearch-backport-pull-request bot pushed a commit that referenced this pull request Nov 22, 2025
* fix: remove draining from Flush callback

* test: add test for query while flushall

* improve testing with workers

* improve test

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

Successfully created backport PR for 8.4:

JoanFM added a commit that referenced this pull request Nov 26, 2025
* fix: remove draining from Flush callback

* test: add test for query while flushall

* improve testing with workers

* improve test

(cherry picked from commit e56bf5b)
JoanFM added a commit that referenced this pull request Nov 26, 2025
* fix: remove draining from Flush callback

* test: add test for query while flushall

* improve testing with workers

* improve test

(cherry picked from commit e56bf5b)
JoanFM added a commit that referenced this pull request Nov 26, 2025
* fix: remove draining from Flush callback

* test: add test for query while flushall

* improve testing with workers

* improve test

(cherry picked from commit e56bf5b)
github-merge-queue bot pushed a commit that referenced this pull request Nov 26, 2025
* fix: remove draining from Flush callback (#7420)

* fix: remove draining from Flush callback

* test: add test for query while flushall

* improve testing with workers

* improve test

(cherry picked from commit e56bf5b)

* skip test on sanitizer

---------

Co-authored-by: Joan Fontanals <[email protected]>
github-merge-queue bot pushed a commit that referenced this pull request Nov 26, 2025
fix: remove draining from Flush callback (#7420)

* fix: remove draining from Flush callback

* test: add test for query while flushall

* improve testing with workers

* improve test

(cherry picked from commit e56bf5b)
github-merge-queue bot pushed a commit that referenced this pull request Nov 26, 2025
* fix: remove draining from Flush callback (#7420)

* fix: remove draining from Flush callback

* test: add test for query while flushall

* improve testing with workers

* improve test

(cherry picked from commit e56bf5b)

* skip test on sanitizer

---------

Co-authored-by: Joan Fontanals <[email protected]>
github-merge-queue bot pushed a commit that referenced this pull request Nov 26, 2025
* fix: remove draining from Flush callback (#7420)

* fix: remove draining from Flush callback

* test: add test for query while flushall

* improve testing with workers

* improve test

(cherry picked from commit e56bf5b)

* fix: fix test
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