You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2021/05/27 09:57:56 UTC

[GitHub] [druid] clintropolis commented on a change in pull request #11311: Fix bug: 502 bad gateway thrown when we edit/delete any auto compaction config created 0.21.0 or before

clintropolis commented on a change in pull request #11311:
URL: https://github.com/apache/druid/pull/11311#discussion_r640466988



##########
File path: core/src/main/java/org/apache/druid/common/config/JacksonConfigManager.java
##########
@@ -90,14 +100,15 @@ public JacksonConfigManager(
    *
    * @param key of the config to set
    * @param oldValue old config value. If not null, then the update will only succeed if the insert
-   *                 happens when current database entry is the same as this value. If null, then the insert
-   *                 will not consider the current database entry.
+   *                 happens when current database entry is the same as this value. Note that the current database
+   *                 entry (in array of bytes) have to be exactly the same as the array of bytes of this value for
+   *                 update to succeed. If null, then the insert will not consider the current database entry.

Review comment:
       nit: it might be worth calling out why it uses bytes to be resilient across serde instead of the old object

##########
File path: server/src/main/java/org/apache/druid/server/coordinator/duty/KillCompactionConfig.java
##########
@@ -88,7 +96,8 @@ public DruidCoordinatorRuntimeParams run(DruidCoordinatorRuntimeParams params)
       try {
         RetryUtils.retry(
             () -> {
-              CoordinatorCompactionConfig current = CoordinatorCompactionConfig.current(jacksonConfigManager);
+              final byte[] currenInByte = CoordinatorCompactionConfig.getConfigInByteFromDb(connector, connectorConfig);

Review comment:
       nit: `currentBytes` maybe?

##########
File path: server/src/main/java/org/apache/druid/server/http/CoordinatorCompactionConfigsResource.java
##########
@@ -204,8 +213,9 @@ Response updateConfigHelper(Callable<SetResult> updateMethod)
       }
     }
     catch (Exception e) {
+      String errorMessage = e.getMessage();
       return Response.status(Response.Status.INTERNAL_SERVER_ERROR)
-                     .entity(ImmutableMap.of("error", e))
+                     .entity(ImmutableMap.of("error", errorMessage == null ? "Unknown Error" : errorMessage))

Review comment:
       nit: worth making a method to make an error response perhaps

##########
File path: server/src/main/java/org/apache/druid/server/http/CoordinatorCompactionConfigsResource.java
##########
@@ -87,8 +97,8 @@ public Response setCompactionTaskLimit(
   )
   {
     Callable<SetResult> callable = () -> {
-      final CoordinatorCompactionConfig current = CoordinatorCompactionConfig.current(manager);
-
+      final byte[] currenInByte = getCurrentConfigInByteFromDb();

Review comment:
       nit: same typo (and a few other places)

##########
File path: core/src/test/java/org/apache/druid/common/config/ConfigManagerTest.java
##########
@@ -49,7 +49,7 @@
 {
   private static final String CONFIG_KEY = "configX";
   private static final String TABLE_NAME = "config_table";
-  private static final TestConfig OLD_CONFIG = new TestConfig("1", "x", 1);
+  private static final byte[] OLD_CONFIG = {1, 2, 3};

Review comment:
       nit: maybe test should serialize test config to bytes to be more realistic?

##########
File path: integration-tests/src/test/java/org/apache/druid/tests/coordinator/duty/ITAutoCompactionUpgradeTest.java
##########
@@ -0,0 +1,121 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.tests.coordinator.duty;
+
+import com.google.inject.Inject;
+import org.apache.druid.data.input.MaxSizeSplitHintSpec;
+import org.apache.druid.indexer.partitions.DynamicPartitionsSpec;
+import org.apache.druid.indexer.partitions.PartitionsSpec;
+import org.apache.druid.java.util.common.granularity.Granularities;
+import org.apache.druid.java.util.common.logger.Logger;
+import org.apache.druid.server.coordinator.CoordinatorCompactionConfig;
+import org.apache.druid.server.coordinator.DataSourceCompactionConfig;
+import org.apache.druid.server.coordinator.UserCompactionTaskGranularityConfig;
+import org.apache.druid.server.coordinator.UserCompactionTaskIOConfig;
+import org.apache.druid.server.coordinator.UserCompactionTaskQueryTuningConfig;
+import org.apache.druid.testing.IntegrationTestingConfig;
+import org.apache.druid.testing.clients.CompactionResourceTestClient;
+import org.apache.druid.testing.guice.DruidTestModuleFactory;
+import org.apache.druid.tests.TestNGGroup;
+import org.apache.druid.tests.indexer.AbstractIndexerTest;
+import org.joda.time.Period;
+import org.testng.Assert;
+import org.testng.annotations.Guice;
+import org.testng.annotations.Test;
+
+@Test(groups = {TestNGGroup.UPGRADE})
+@Guice(moduleFactory = DruidTestModuleFactory.class)
+public class ITAutoCompactionUpgradeTest extends AbstractIndexerTest
+{
+  private static final Logger LOG = new Logger(ITAutoCompactionUpgradeTest.class);
+  private static final String UPGRADE_DATASOURCE_NAME = "upgradeTest";
+
+  @Inject
+  protected CompactionResourceTestClient compactionResource;
+
+  @Inject
+  private IntegrationTestingConfig config;
+
+  @Test
+  public void testUpgradeAutoCompactionConfigurationWhenConfigurationFromOlderVersionAlreadyExist() throws Exception
+  {
+    // Verify that compaction config already exist. This config was inserted manually into the database using SQL script.
+    // This auto compaction configuration payload is from Druid 0.21.0

Review comment:
       hmm, i dig the idea of some form of upgrade tests, but this seems a bit specific to add as an integration test. Perhaps it is fine to add, but we should not run it as part of everyday travis?




-- 
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:
users@infra.apache.org



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