maytasm commented on a change in pull request #11144:
URL: https://github.com/apache/druid/pull/11144#discussion_r629678850
##########
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 made the issue at https://github.com/apache/druid/issues/11230
--
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]