-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Concurrent Streaming and Replace improvements #15813
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
AmatyaAvadhanula
wants to merge
1
commit into
apache:master
from
AmatyaAvadhanula:segment_transactional_append_streaming
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -62,6 +62,7 @@ | |||||
| import org.apache.druid.timeline.partition.PartitionIds; | ||||||
| import org.apache.druid.timeline.partition.ShardSpec; | ||||||
| import org.apache.druid.timeline.partition.SingleDimensionShardSpec; | ||||||
| import org.apache.druid.utils.CollectionUtils; | ||||||
| import org.joda.time.DateTime; | ||||||
| import org.joda.time.Interval; | ||||||
| import org.joda.time.chrono.ISOChronology; | ||||||
|
|
@@ -536,6 +537,7 @@ public SegmentPublishResult commitAppendSegments( | |||||
| appendSegments, | ||||||
| appendSegmentToReplaceLock, | ||||||
| null, | ||||||
| null, | ||||||
| null | ||||||
| ); | ||||||
| } | ||||||
|
|
@@ -545,14 +547,16 @@ public SegmentPublishResult commitAppendSegmentsAndMetadata( | |||||
| Set<DataSegment> appendSegments, | ||||||
| Map<DataSegment, ReplaceTaskLock> appendSegmentToReplaceLock, | ||||||
| DataSourceMetadata startMetadata, | ||||||
| DataSourceMetadata endMetadata | ||||||
| DataSourceMetadata endMetadata, | ||||||
| Map<String, Set<SegmentIdWithShardSpec>> segmentIdToUpgradedVersions | ||||||
| ) | ||||||
| { | ||||||
| return commitAppendSegmentsAndMetadataInTransaction( | ||||||
| appendSegments, | ||||||
| appendSegmentToReplaceLock, | ||||||
| startMetadata, | ||||||
| endMetadata | ||||||
| endMetadata, | ||||||
| segmentIdToUpgradedVersions | ||||||
| ); | ||||||
| } | ||||||
|
|
||||||
|
|
@@ -1291,7 +1295,8 @@ private SegmentPublishResult commitAppendSegmentsAndMetadataInTransaction( | |||||
| Set<DataSegment> appendSegments, | ||||||
| Map<DataSegment, ReplaceTaskLock> appendSegmentToReplaceLock, | ||||||
| @Nullable DataSourceMetadata startMetadata, | ||||||
| @Nullable DataSourceMetadata endMetadata | ||||||
| @Nullable DataSourceMetadata endMetadata, | ||||||
| @Nullable Map<String, Set<SegmentIdWithShardSpec>> segmentIdToUpgradedVersions | ||||||
| ) | ||||||
| { | ||||||
| verifySegmentsToCommit(appendSegments); | ||||||
|
|
@@ -1303,7 +1308,7 @@ private SegmentPublishResult commitAppendSegmentsAndMetadataInTransaction( | |||||
| final String dataSource = appendSegments.iterator().next().getDataSource(); | ||||||
| final Set<DataSegment> segmentIdsForNewVersions = connector.retryTransaction( | ||||||
| (handle, transactionStatus) | ||||||
| -> createNewIdsForAppendSegments(handle, dataSource, appendSegments), | ||||||
| -> createNewIdsForAppendSegments(handle, dataSource, appendSegments, segmentIdToUpgradedVersions), | ||||||
| 0, | ||||||
| SQLMetadataConnector.DEFAULT_MAX_TRIES | ||||||
| ); | ||||||
|
|
@@ -1436,13 +1441,18 @@ private void insertPendingSegmentIntoMetastore( | |||||
| private Set<DataSegment> createNewIdsForAppendSegments( | ||||||
| Handle handle, | ||||||
| String dataSource, | ||||||
| Set<DataSegment> segmentsToAppend | ||||||
| Set<DataSegment> segmentsToAppend, | ||||||
| @Nullable Map<String, Set<SegmentIdWithShardSpec>> segmentIdToUpgradeVersions | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| ) throws IOException | ||||||
| { | ||||||
| if (segmentsToAppend.isEmpty()) { | ||||||
| return Collections.emptySet(); | ||||||
| } | ||||||
|
|
||||||
| if (segmentIdToUpgradeVersions == null) { | ||||||
| segmentIdToUpgradeVersions = Collections.emptyMap(); | ||||||
| } | ||||||
|
|
||||||
| final Set<Interval> appendIntervals = new HashSet<>(); | ||||||
| final TreeMap<String, Set<DataSegment>> appendVersionToSegments = new TreeMap<>(); | ||||||
| for (DataSegment segment : segmentsToAppend) { | ||||||
|
|
@@ -1475,7 +1485,37 @@ private Set<DataSegment> createNewIdsForAppendSegments( | |||||
| entry.getValue(), | ||||||
| appendVersionToSegments | ||||||
| ); | ||||||
| for (Map.Entry<Interval, Set<DataSegment>> upgradeEntry : segmentsToUpgrade.entrySet()) { | ||||||
| Map<Interval, Set<DataSegment>> filteredSegmentsToUpgrade = new HashMap<>(); | ||||||
| for (Interval interval : segmentsToUpgrade.keySet()) { | ||||||
| filteredSegmentsToUpgrade.put(interval, new HashSet<>()); | ||||||
| for (DataSegment segment : segmentsToUpgrade.get(interval)) { | ||||||
| boolean include = true; | ||||||
| if (segmentIdToUpgradeVersions.containsKey(segment.getId().toString())) { | ||||||
| for (SegmentIdWithShardSpec upgradedSegment : segmentIdToUpgradeVersions.get(segment.getId().toString())) { | ||||||
| if (upgradedSegment.getVersion().equals(upgradeVersion)) { | ||||||
| upgradedSegments.add( | ||||||
| new DataSegment( | ||||||
| upgradedSegment.asSegmentId(), | ||||||
| segment.getLoadSpec(), | ||||||
| segment.getDimensions(), | ||||||
| segment.getMetrics(), | ||||||
| upgradedSegment.getShardSpec(), | ||||||
| null, | ||||||
| segment.getBinaryVersion(), | ||||||
| segment.getSize() | ||||||
| ) | ||||||
| ); | ||||||
| include = false; | ||||||
| break; | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
| if (include) { | ||||||
| filteredSegmentsToUpgrade.get(interval).add(segment); | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
|
Comment on lines
+1489
to
+1517
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you please some comments to describe what are you trying to do here? I don't follow. |
||||||
| for (Map.Entry<Interval, Set<DataSegment>> upgradeEntry : filteredSegmentsToUpgrade.entrySet()) { | ||||||
| final Interval upgradeInterval = upgradeEntry.getKey(); | ||||||
| final Set<DataSegment> segmentsAlreadyOnVersion | ||||||
| = overlappingIntervalToSegments.getOrDefault(upgradeInterval, Collections.emptySet()) | ||||||
|
|
@@ -1548,6 +1588,10 @@ private Set<DataSegment> createNewIdsForAppendSegmentsWithVersion( | |||||
| Set<DataSegment> committedSegments | ||||||
| ) throws IOException | ||||||
| { | ||||||
| if (CollectionUtils.isNullOrEmpty(segmentsToUpgrade)) { | ||||||
| return Collections.emptySet(); | ||||||
| } | ||||||
|
|
||||||
| // Find the committed segments with the higest partition number | ||||||
| SegmentIdWithShardSpec committedMaxId = null; | ||||||
| for (DataSegment committedSegment : committedSegments) { | ||||||
|
|
||||||
This file contains hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated docs improvement