You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by "AmatyaAvadhanula (via GitHub)" <gi...@apache.org> on 2024/02/28 10:45:09 UTC

[PR] Concurrent replace should work with supervisors using concurrent locks (druid)

AmatyaAvadhanula opened a new pull request, #15995:
URL: https://github.com/apache/druid/pull/15995

   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
   
   This PR has:
   
   - [ ] been self-reviewed.
      - [ ] using the [concurrency checklist](https://github.com/apache/druid/blob/master/dev/code-review/concurrency.md) (Remove this item if the PR doesn't have any relation to concurrency.)
   - [ ] 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](https://github.com/apache/druid/blob/master/dev/license.md)
   - [ ] 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](https://github.com/apache/druid/blob/master/dev/code-review/code-coverage.md) is met.
   - [ ] added integration tests.
   - [ ] been tested in a test Druid cluster.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Concurrent replace should work with supervisors using concurrent locks (druid)

Posted by "AmatyaAvadhanula (via GitHub)" <gi...@apache.org>.
AmatyaAvadhanula commented on PR #15995:
URL: https://github.com/apache/druid/pull/15995#issuecomment-1970499583

   Thank you for the review @kfaraz 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Concurrent replace should work with supervisors using concurrent locks (druid)

Posted by "AmatyaAvadhanula (via GitHub)" <gi...@apache.org>.
AmatyaAvadhanula merged PR #15995:
URL: https://github.com/apache/druid/pull/15995


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Concurrent replace should work with supervisors using concurrent locks (druid)

Posted by "kfaraz (via GitHub)" <gi...@apache.org>.
kfaraz commented on code in PR #15995:
URL: https://github.com/apache/druid/pull/15995#discussion_r1505820170


##########
indexing-service/src/main/java/org/apache/druid/indexing/overlord/supervisor/SupervisorManager.java:
##########
@@ -87,23 +87,32 @@ public Optional<String> getActiveSupervisorIdForDatasourceWithAppendLock(String
       final Supervisor supervisor = entry.getValue().lhs;
       final SupervisorSpec supervisorSpec = entry.getValue().rhs;
 
-      TaskLockType taskLockType = null;
+      Boolean useConcurrentLocks = Tasks.DEFAULT_USE_CONCURRENT_LOCKS;
+      TaskLockType taskLockType = Tasks.DEFAULT_TASK_LOCK_TYPE;

Review Comment:
   ```suggestion
         boolean hasAppendLock = Tasks.DEFAULT_USE_CONCURRENT_LOCKS;
   ```



##########
indexing-service/src/main/java/org/apache/druid/indexing/overlord/supervisor/SupervisorManager.java:
##########
@@ -87,23 +87,32 @@ public Optional<String> getActiveSupervisorIdForDatasourceWithAppendLock(String
       final Supervisor supervisor = entry.getValue().lhs;
       final SupervisorSpec supervisorSpec = entry.getValue().rhs;
 
-      TaskLockType taskLockType = null;
+      Boolean useConcurrentLocks = Tasks.DEFAULT_USE_CONCURRENT_LOCKS;
+      TaskLockType taskLockType = Tasks.DEFAULT_TASK_LOCK_TYPE;
       if (supervisorSpec instanceof SeekableStreamSupervisorSpec) {
         SeekableStreamSupervisorSpec seekableStreamSupervisorSpec = (SeekableStreamSupervisorSpec) supervisorSpec;
         Map<String, Object> context = seekableStreamSupervisorSpec.getContext();
         if (context != null) {
-          taskLockType = QueryContexts.getAsEnum(
-              Tasks.TASK_LOCK_TYPE,
-              context.get(Tasks.TASK_LOCK_TYPE),
-              TaskLockType.class
+          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
+            );
+          }

Review Comment:
   ```suggestion
             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;
             }
   ```



##########
indexing-service/src/main/java/org/apache/druid/indexing/overlord/supervisor/SupervisorManager.java:
##########
@@ -87,23 +87,32 @@ public Optional<String> getActiveSupervisorIdForDatasourceWithAppendLock(String
       final Supervisor supervisor = entry.getValue().lhs;
       final SupervisorSpec supervisorSpec = entry.getValue().rhs;
 
-      TaskLockType taskLockType = null;
+      Boolean useConcurrentLocks = Tasks.DEFAULT_USE_CONCURRENT_LOCKS;
+      TaskLockType taskLockType = Tasks.DEFAULT_TASK_LOCK_TYPE;
       if (supervisorSpec instanceof SeekableStreamSupervisorSpec) {
         SeekableStreamSupervisorSpec seekableStreamSupervisorSpec = (SeekableStreamSupervisorSpec) supervisorSpec;
         Map<String, Object> context = seekableStreamSupervisorSpec.getContext();
         if (context != null) {
-          taskLockType = QueryContexts.getAsEnum(
-              Tasks.TASK_LOCK_TYPE,
-              context.get(Tasks.TASK_LOCK_TYPE),
-              TaskLockType.class
+          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
+            );
+          }
         }
       }
 
       if (supervisor instanceof SeekableStreamSupervisor
           && !supervisorSpec.isSuspended()
           && supervisorSpec.getDataSources().contains(datasource)
-          && TaskLockType.APPEND.equals(taskLockType)) {
+          && (useConcurrentLocks || TaskLockType.APPEND.equals(taskLockType))) {

Review Comment:
   ```suggestion
             && hasAppendLock) {
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org