Skip to content

MOD-12489: FT.HYBRID - Coordinator Deadlock - Avoid Taking Index Read Lock #7404

Merged
kei-nan merged 2 commits intomasterfrom
master_jk_hybrid_avoid_taking_read_lock_in_coordindator
Nov 19, 2025
Merged

MOD-12489: FT.HYBRID - Coordinator Deadlock - Avoid Taking Index Read Lock #7404
kei-nan merged 2 commits intomasterfrom
master_jk_hybrid_avoid_taking_read_lock_in_coordindator

Conversation

@kei-nan
Copy link
Collaborator

@kei-nan kei-nan commented Nov 18, 2025

A deadlock was found since the read locks for the index were held by the depleters.

Describe the changes in the pull request

A clear and concise description of what the PR is solving, including:

  1. Current: Depleters in coordinator always take index lock
  2. Change: Depleters in coordinator won't take index lock
  3. Outcome: Avoid Deadlocks in coordinator that are related to hybrid.

Main objects this PR modified

  1. Depleter Index Lock Flow

Mark if applicable

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

Note

Stop taking index read locks in distributed hybrid depleters to prevent deadlocks; remove the synchronize_read_locks parameter and set locking explicitly where needed.

  • Coordinator/Distributed Depletion:
    • In src/coord/hybrid/dist_hybrid_plan.cpp, create depleter sync with false to avoid index read locks during distributed depletion.
  • Standalone/Background Depletion:
    • In src/hybrid/hybrid_request.c, when depleteInBackground is true, create depleter sync with true (explicitly enabling coordination), decoupled from params.
  • API Cleanup:
    • Remove HybridPipelineParams.synchronize_read_locks from src/pipeline/pipeline.h and its usage.
    • Drop initialization of hybridParams->synchronize_read_locks in src/hybrid/parse_hybrid.c.

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

@kei-nan kei-nan self-assigned this Nov 18, 2025
JoanFM
JoanFM previously approved these changes Nov 18, 2025
int rc = REDISMODULE_OK;
if (depleteInBackground) {
sync_ref = DepleterSync_New(req->nrequests, params->synchronize_read_locks);
sync_ref = DepleterSync_New(req->nrequests, true);
Copy link
Collaborator

Choose a reason for hiding this comment

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

So now the decision wether to take the read lock is dependent on which function we use to build the pipeline?
HybridRequest_BuildDepletionPipeline \ HybridRequest_BuildDepletionPipeline ?
Honestly I dont like it, I prefer the parameter approach
Anyway, its not crucial and leaving it to you to decide

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

when we operate at the shard level we need to take the index lock
when we operate at the coord level we don't
we have the internal boolean in the parse code but it doesn't tell us if we are in coordinator or shard.
because in standalone we also need to take the lock and internal would be false in such a case.
for now will leave as is

Copy link
Collaborator

@Itzikvaknin Itzikvaknin left a comment

Choose a reason for hiding this comment

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

Only typos, spellcheck was lazy this time

code review comment

Co-authored-by: Itzikvaknin <[email protected]>
@codecov
Copy link

codecov bot commented Nov 18, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.11%. Comparing base (f81354f) to head (fe37ea5).
⚠️ Report is 13 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7404      +/-   ##
==========================================
- Coverage   85.17%   85.11%   -0.06%     
==========================================
  Files         346      346              
  Lines       53049    53048       -1     
  Branches    13773    13773              
==========================================
- Hits        45184    45154      -30     
- Misses       7671     7700      +29     
  Partials      194      194              
Flag Coverage Δ
flow 84.52% <100.00%> (-0.09%) ⬇️
unit 52.34% <100.00%> (-0.01%) ⬇️

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.

@kei-nan kei-nan added this pull request to the merge queue Nov 18, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 18, 2025
@JoanFM JoanFM added this pull request to the merge queue Nov 18, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 19, 2025
@kei-nan kei-nan added this pull request to the merge queue Nov 19, 2025
Merged via the queue into master with commit 9589f1d Nov 19, 2025
22 checks passed
@kei-nan kei-nan deleted the master_jk_hybrid_avoid_taking_read_lock_in_coordindator branch November 19, 2025 17:03
redisearch-backport-pull-request bot pushed a commit that referenced this pull request Nov 19, 2025
… Lock (#7404)

* always lock in shard sepletion flow, never lock in coordinator depletion flow

* Apply suggestions from code review

code review comment

Co-authored-by: Itzikvaknin <[email protected]>

---------

Co-authored-by: Itzikvaknin <[email protected]>
(cherry picked from commit 9589f1d)
@redisearch-backport-pull-request
Copy link
Contributor

github-merge-queue bot pushed a commit that referenced this pull request Nov 19, 2025
…x Read Lock (#7430)

MOD-12489: FT.HYBRID - Coordinator Deadlock - Avoid Taking Index Read Lock  (#7404)

* always lock in shard sepletion flow, never lock in coordinator depletion flow

* Apply suggestions from code review

code review comment



---------


(cherry picked from commit 9589f1d)

Co-authored-by: kei-nan <[email protected]>
Co-authored-by: Itzikvaknin <[email protected]>
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