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

Concurrent replace should work with supervisors using concurrent locks #15995

Merged

Conversation

AmatyaAvadhanula
Copy link
Contributor

@AmatyaAvadhanula AmatyaAvadhanula commented Feb 28, 2024

A concurrent replace should allow the existing pending segments of a peon to be upgraded via the supervisor.
Currently, we check if there is such an active supervisor for streaming ingestion when the context value of taskLockType: APPEND.
This PR ensures that useConcurrentLocks:true works as well.

Please note that if useConcurrentLocks is set to false, it would supersede taskLockType:APPEND

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.

@cryptoe cryptoe added this to the 29.0.1 milestone Feb 28, 2024
Copy link
Contributor

@kfaraz kfaraz left a comment

Choose a reason for hiding this comment

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

Left some comments to make the flow easy to understand.

Comment on lines 90 to 91
Boolean useConcurrentLocks = Tasks.DEFAULT_USE_CONCURRENT_LOCKS;
TaskLockType taskLockType = Tasks.DEFAULT_TASK_LOCK_TYPE;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Boolean useConcurrentLocks = Tasks.DEFAULT_USE_CONCURRENT_LOCKS;
TaskLockType taskLockType = Tasks.DEFAULT_TASK_LOCK_TYPE;
boolean hasAppendLock = Tasks.DEFAULT_USE_CONCURRENT_LOCKS;

}
}

if (supervisor instanceof SeekableStreamSupervisor
&& !supervisorSpec.isSuspended()
&& supervisorSpec.getDataSources().contains(datasource)
&& TaskLockType.APPEND.equals(taskLockType)) {
&& (useConcurrentLocks || TaskLockType.APPEND.equals(taskLockType))) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
&& (useConcurrentLocks || TaskLockType.APPEND.equals(taskLockType))) {
&& hasAppendLock) {

Comment on lines 96 to 108
useConcurrentLocks = QueryContexts.getAsBoolean(
Tasks.USE_CONCURRENT_LOCKS,
context.get(Tasks.USE_CONCURRENT_LOCKS)
);

if (useConcurrentLocks == null) {
useConcurrentLocks = false;
taskLockType = QueryContexts.getAsEnum(
Tasks.TASK_LOCK_TYPE,
context.get(Tasks.TASK_LOCK_TYPE),
TaskLockType.class
);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
useConcurrentLocks = QueryContexts.getAsBoolean(
Tasks.USE_CONCURRENT_LOCKS,
context.get(Tasks.USE_CONCURRENT_LOCKS)
);
if (useConcurrentLocks == null) {
useConcurrentLocks = false;
taskLockType = QueryContexts.getAsEnum(
Tasks.TASK_LOCK_TYPE,
context.get(Tasks.TASK_LOCK_TYPE),
TaskLockType.class
);
}
Boolean useConcurrentLocks = QueryContexts.getAsBoolean(
Tasks.USE_CONCURRENT_LOCKS,
context.get(Tasks.USE_CONCURRENT_LOCKS)
);
if (useConcurrentLocks == null) {
TaskLockType taskLockType = QueryContexts.getAsEnum(
Tasks.TASK_LOCK_TYPE,
context.get(Tasks.TASK_LOCK_TYPE),
TaskLockType.class
);
if (taskLockType == null) {
hasAppendLock = Tasks.DEFAULT_USE_CONCURRENT_LOCKS;
} else if (taskLockType == TaskLockType.APPEND) {
hasAppendLock = true;
} else {
hasAppendLock = false;
}
} else {
hasAppendLock = useConcurrentLocks;
}

Copy link
Contributor

@kfaraz kfaraz left a comment

Choose a reason for hiding this comment

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

Thanks for the fix, @AmatyaAvadhanula !

@AmatyaAvadhanula AmatyaAvadhanula merged commit 7c42e87 into apache:master Feb 29, 2024
83 checks passed
@AmatyaAvadhanula
Copy link
Contributor Author

Thank you for the review @kfaraz

317brian pushed a commit to 317brian/druid that referenced this pull request Feb 29, 2024
apache#15995)

* Concurrent replace should work with supervisors using concurrent locks

* Ignore supervisors with useConcurrentLocks set to false

* Apply feedback
AmatyaAvadhanula added a commit to AmatyaAvadhanula/druid that referenced this pull request Mar 1, 2024
apache#15995)

* Concurrent replace should work with supervisors using concurrent locks

* Ignore supervisors with useConcurrentLocks set to false

* Apply feedback
kfaraz pushed a commit that referenced this pull request Mar 1, 2024
…urrent locks (#15995) (#16019)

* Concurrent replace should work with supervisors using concurrent locks

* Ignore supervisors with useConcurrentLocks set to false

* Apply feedback
asdf2014 added a commit that referenced this pull request Mar 4, 2024
* docs: add mermaid diagram support

* fix crash when parsing data in data loader that can not be parsed (#15983)

* update jetty to address CVE (#16000)

* Concurrent replace should work with supervisors using concurrent locks (#15995)

* Concurrent replace should work with supervisors using concurrent locks

* Ignore supervisors with useConcurrentLocks set to false

* Apply feedback

* Add pre-check for heavy debug logs (#15706)

Co-authored-by: Kashif Faraz <[email protected]>
Co-authored-by: Benedict Jin <[email protected]>

* Remove helm paths from CodeQL config (#16006)

* docs: mention acid-compliance for metadb

---------

Co-authored-by: Vadim Ogievetsky <[email protected]>
Co-authored-by: Jan Werner <[email protected]>
Co-authored-by: AmatyaAvadhanula <[email protected]>
Co-authored-by: Sensor <[email protected]>
Co-authored-by: Kashif Faraz <[email protected]>
Co-authored-by: Benedict Jin <[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