Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Maintain TaskLockbox at datasource level for higher concurrency #17390

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

kfaraz
Copy link
Contributor

@kfaraz kfaraz commented Oct 22, 2024

Description

In clusters with a large number of datasources, task operations block each other owing to the giant lock in the TaskLockbox. This can become particularly problematic in cases of streaming ingestion being done into multiple datasources, where segment allocations become very slow since all of them must pass through a single queue.

None of the task operations share a critical section across datasources and it should suffice to perform the locking at the datasource level.

This patch is an attempt to remediate this problem.

Changes

  • Dedicate TaskLockbox to a single datasource. We can rename this to DataSourceTaskLockbox or something more appropriate later. For now, the name has been left unchanged to simplify the diff and review process.
  • Add a GlobalTaskLockbox which delegates to the respective datasource for any operation.
  • The GlobalTaskLockbox.sync() must still be mutually exclusive from any operation being performed on any of the datasources. This is performed by using a ReentrantReadWriteLock.

Pending

  • Maintain SegmentAllocationQueue at datasource level.
  • Fix up tests
  • Clean up the TaskLockbox for a datasource when it is not needed anymore
  • Try out changes in a cluster

This PR has:

  • been self-reviewed.
  • added documentation for new or modified features or behaviors.
  • a release note entry in the PR description.
  • added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
  • added or updated version, license, or notice information in licenses.yaml
  • added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
  • added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage is met.
  • added integration tests.
  • been tested in a test Druid cluster.

@kfaraz kfaraz changed the title Maintain TaskLockbox at datasource level for higher concurrency [WIP] Maintain TaskLockbox at datasource level for higher concurrency Oct 22, 2024
);
}

private class DatasourceLock extends ReentrantLock

Check warning

Code scanning / CodeQL

Serializable inner class of non-serializable class

Serializable inner class of non-serializable class [GlobalTaskLockbox](1). Consider making the class static or implementing readObject() and writeObject().
Copy link

This pull request has been marked as stale due to 60 days of inactivity.
It will be closed in 4 weeks if no further activity occurs. If you think
that's incorrect or this pull request should instead be reviewed, please simply
write any comment. Even if closed, you can still revive the PR at any time or
discuss it on the dev@druid.apache.org list.
Thank you for your contributions.

Copy link

github-actions bot commented Mar 8, 2025

This pull request has been marked as stale due to 60 days of inactivity.
It will be closed in 4 weeks if no further activity occurs. If you think
that's incorrect or this pull request should instead be reviewed, please simply
write any comment. Even if closed, you can still revive the PR at any time or
discuss it on the dev@druid.apache.org list.
Thank you for your contributions.

@github-actions github-actions bot added the stale label Mar 8, 2025
@kfaraz kfaraz removed the stale label Mar 11, 2025
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.

1 participant