Skip to content

refactor(query): mitigate exchange coordinator lock contention#20048

Draft
dqhl76 wants to merge 2 commits into
databendlabs:mainfrom
dqhl76:fix-queries-coordinator
Draft

refactor(query): mitigate exchange coordinator lock contention#20048
dqhl76 wants to merge 2 commits into
databendlabs:mainfrom
dqhl76:fix-queries-coordinator

Conversation

@dqhl76

@dqhl76 dqhl76 commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/

Summary

refactor(query): mitigate exchange coordinator lock contention

When query concurrency is high, we observe frequent warnings caused by waiting too long to acquire the queries_coordinator lock in on_finished_query.

Waited 2.104701739s to acquire queries_coordinator lock

We try to refactor queries coordinator:

  1. Split the single coarse-grained lock in the original queries coordinator into per-query independent locks to reduce lock contention.
  2. Shorten the lock holding time, eliminate reentrancy, and replace the reentrant lock with a regular mutex.

Tests

  • Unit Test
  • Logic Test
  • Benchmark Test
  • No Test - Explain why

Type of change

  • Bug Fix (non-breaking change which fixes an issue)
  • New Feature (non-breaking change which adds functionality)
  • Breaking Change (fix or feature that could cause existing functionality not to work as expected)
  • Documentation Update
  • Refactoring
  • Performance Improvement
  • Other (please describe):

This change is Reviewable

@github-actions github-actions Bot added the pr-refactor this PR changes the code base without new features or bugfix label Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-refactor this PR changes the code base without new features or bugfix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant