-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix replica task failures with metadata inconsistency while running c…
…oncurrent append replace (#16614) Changes: - Add new task action `RetrieveSegmentsByIdAction` - Use new task action to retrieve segments irrespective of their visibility - During rolling upgrades, this task action would fail as Overlord would be on old version - If new action fails, fall back to just fetching used segments as before
- Loading branch information
Showing
12 changed files
with
300 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
110 changes: 110 additions & 0 deletions
110
...ce/src/main/java/org/apache/druid/indexing/common/actions/RetrieveSegmentsByIdAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
/* | ||
* 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.indexing.common.actions; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.core.type.TypeReference; | ||
import org.apache.druid.indexing.common.task.Task; | ||
import org.apache.druid.timeline.DataSegment; | ||
|
||
import java.util.Objects; | ||
import java.util.Set; | ||
|
||
/** | ||
* Task action to retrieve segments from the metadata store. Matching segments | ||
* are returned regardless of their visibility i.e. visible, overshadowed or unused. | ||
*/ | ||
public class RetrieveSegmentsByIdAction implements TaskAction<Set<DataSegment>> | ||
{ | ||
private final String dataSource; | ||
private final Set<String> segmentIds; | ||
|
||
@JsonCreator | ||
public RetrieveSegmentsByIdAction( | ||
@JsonProperty("dataSource") String dataSource, | ||
@JsonProperty("segmentIds") Set<String> segmentIds | ||
) | ||
{ | ||
this.dataSource = dataSource; | ||
this.segmentIds = segmentIds; | ||
} | ||
|
||
@JsonProperty | ||
public String getDataSource() | ||
{ | ||
return dataSource; | ||
} | ||
|
||
@JsonProperty | ||
public Set<String> getSegmentIds() | ||
{ | ||
return segmentIds; | ||
} | ||
|
||
@Override | ||
public TypeReference<Set<DataSegment>> getReturnTypeReference() | ||
{ | ||
return new TypeReference<Set<DataSegment>>() | ||
{ | ||
}; | ||
} | ||
|
||
@Override | ||
public Set<DataSegment> perform(Task task, TaskActionToolbox toolbox) | ||
{ | ||
return toolbox.getIndexerMetadataStorageCoordinator() | ||
.retrieveSegmentsById(dataSource, segmentIds); | ||
} | ||
|
||
@Override | ||
public boolean isAudited() | ||
{ | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) | ||
{ | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
RetrieveSegmentsByIdAction that = (RetrieveSegmentsByIdAction) o; | ||
return Objects.equals(dataSource, that.dataSource) && Objects.equals(segmentIds, that.segmentIds); | ||
} | ||
|
||
@Override | ||
public int hashCode() | ||
{ | ||
return Objects.hash(dataSource, segmentIds); | ||
} | ||
|
||
@Override | ||
public String toString() | ||
{ | ||
return getClass().getSimpleName() + "{" + | ||
"dataSource='" + dataSource + '\'' + | ||
", segmentIds=" + segmentIds + | ||
'}'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.