AmatyaAvadhanula commented on code in PR #16380:
URL: https://github.com/apache/druid/pull/16380#discussion_r1588805459
##########
server/src/main/java/org/apache/druid/metadata/IndexerSQLMetadataStorageCoordinator.java:
##########
@@ -1886,7 +1856,67 @@ private SegmentIdWithShardSpec createNewSegment(
committedMaxId == null ? 0 :
committedMaxId.getShardSpec().getNumCorePartitions()
)
);
+ return getTrueAllocatedId(allocatedId);
+ }
+ }
+
+ private SegmentIdWithShardSpec getTrueAllocatedId(
+ SegmentIdWithShardSpec allocatedId
+ )
+ {
+ // Check if there is a conflict with an existing entry in the segments
table
+ if (retrieveSegmentForId(allocatedId.asSegmentId().toString(), true) ==
null) {
+ return allocatedId;
+ }
+
+ // If yes, try to compute allocated partition num using the max unused
segment shard spec
+ SegmentIdWithShardSpec unusedMaxId = getUnusedMaxId(
+ allocatedId.getDataSource(),
+ allocatedId.getInterval(),
+ allocatedId.getVersion()
+ );
+ // No unused segment. Just return the allocated id
+ if (unusedMaxId == null) {
+ return allocatedId;
+ }
+
+ int maxPartitionNum = Math.max(
+ allocatedId.getShardSpec().getPartitionNum(),
+ unusedMaxId.getShardSpec().getPartitionNum() + 1
Review Comment:
Similar to the description, it's possible that the user chose to drop only
segments 6-10 instead of all the segments.
The conflict would have arisen in that case as well, and we could not have
ignored the version.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]