maytasm commented on a change in pull request #11144:
URL: https://github.com/apache/druid/pull/11144#discussion_r629635984



##########
File path: core/src/main/java/org/apache/druid/common/config/ConfigManager.java
##########
@@ -168,64 +171,99 @@ private void poll()
     return holder.getReference();
   }
 
-
   public <T> SetResult set(final String key, final ConfigSerde<T> serde, final 
T obj)
   {
-    if (obj == null || !started) {
-      if (obj == null) {
-        return SetResult.fail(new IllegalAccessException("input obj is null"));
+    return set(key, serde, null, obj);
+  }
+
+  public <T> SetResult set(final String key, final ConfigSerde<T> serde, 
@Nullable final T oldObject, final T newObject)
+  {
+    if (newObject == null || !started) {
+      if (newObject == null) {
+        return SetResult.fail(new IllegalAccessException("input obj is null"), 
false);

Review comment:
       Fixed

##########
File path: 
server/src/main/java/org/apache/druid/server/http/CoordinatorCompactionConfigsResource.java
##########
@@ -162,27 +165,68 @@ public Response deleteCompactionConfig(
       @Context HttpServletRequest req
   )
   {
-    final CoordinatorCompactionConfig current = 
CoordinatorCompactionConfig.current(manager);
-    final Map<String, DataSourceCompactionConfig> configs = current
-        .getCompactionConfigs()
-        .stream()
-        .collect(Collectors.toMap(DataSourceCompactionConfig::getDataSource, 
Function.identity()));
+    Callable<SetResult> callable = () -> {
+      final CoordinatorCompactionConfig current = 
CoordinatorCompactionConfig.current(manager);
+      final Map<String, DataSourceCompactionConfig> configs = current
+          .getCompactionConfigs()
+          .stream()
+          .collect(Collectors.toMap(DataSourceCompactionConfig::getDataSource, 
Function.identity()));
+
+      final DataSourceCompactionConfig config = configs.remove(dataSource);
+      if (config == null) {
+        return SetResult.fail(new NoSuchElementException("datasource not 
found"), false);
+      }
+
+      return manager.set(
+          CoordinatorCompactionConfig.CONFIG_KEY,
+          // Do database insert without swap if the current config is empty as 
this means the config may be null in the database
+          CoordinatorCompactionConfig.empty().equals(current) ? null : current,
+          CoordinatorCompactionConfig.from(current, 
ImmutableList.copyOf(configs.values())),
+          new AuditInfo(author, comment, req.getRemoteAddr())
+      );
+    };
+    return updateConfigHelper(callable);
+  }
 
-    final DataSourceCompactionConfig config = configs.remove(dataSource);
-    if (config == null) {
-      return Response.status(Response.Status.NOT_FOUND).build();
+  @VisibleForTesting
+  Response updateConfigHelper(Callable<SetResult> updateMethod)
+  {
+    int attemps = 0;
+    SetResult setResult = null;
+    try {
+      while (attemps < UPDATE_NUM_RETRY) {
+        setResult = updateMethod.call();
+        if (setResult.isOk() || !setResult.isRetryable()) {
+          break;
+        }
+        attemps++;
+        updateRetryDelay();
+      }
+    }

Review comment:
       I forgot about RetryUtils. Fixed




-- 
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.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to