abhishekagarwal87 commented on code in PR #15097:
URL: https://github.com/apache/druid/pull/15097#discussion_r1349639738
##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/SequenceMetadata.java:
##########
@@ -73,7 +78,8 @@ public SequenceMetadata(
@JsonProperty("startOffsets") Map<PartitionIdType, SequenceOffsetType>
startOffsets,
@JsonProperty("endOffsets") Map<PartitionIdType, SequenceOffsetType>
endOffsets,
@JsonProperty("checkpointed") boolean checkpointed,
- @JsonProperty("exclusiveStartPartitions") Set<PartitionIdType>
exclusiveStartPartitions
+ @JsonProperty("exclusiveStartPartitions") Set<PartitionIdType>
exclusiveStartPartitions,
+ @JsonProperty("taskLockType") TaskLockType taskLockType
Review Comment:
This should be nullable for backward compatibility reasons. should it not?
##########
server/src/main/java/org/apache/druid/metadata/IndexerSQLMetadataStorageCoordinator.java:
##########
@@ -971,6 +966,70 @@ private static class CheckExistingSegmentIdResult
}
}
+ private SegmentPublishResult commitAppendSegmentsAndMetadataInTransaction(
+ Set<DataSegment> appendSegments,
+ Map<DataSegment, ReplaceTaskLock> appendSegmentToReplaceLock,
+ @Nullable DataSourceMetadata startMetadata,
+ @Nullable DataSourceMetadata endMetadata
+ )
+ {
+ verifySegmentsToCommit(appendSegments);
+ if ((startMetadata == null && endMetadata != null)
+ || (startMetadata != null && endMetadata == null)) {
+ throw new IllegalArgumentException("start/end metadata pair must be
either null or non-null");
+ }
+
+ final String dataSource = appendSegments.iterator().next().getDataSource();
+ final Set<DataSegment> upgradedSegments = connector.retryTransaction(
Review Comment:
```suggestion
final Set<DataSegment> segmentsToUpgrade = connector.retryTransaction(
```
##########
indexing-service/src/main/java/org/apache/druid/indexing/common/actions/SegmentTransactionalAppendAction.java:
##########
@@ -70,30 +111,48 @@ public TypeReference<SegmentPublishResult>
getReturnTypeReference()
};
}
- /**
- * Performs some sanity checks and publishes the given segments.
- */
@Override
public SegmentPublishResult perform(Task task, TaskActionToolbox toolbox)
{
+ // Verify that all the locks are of expected type
+ final List<TaskLock> locks =
toolbox.getTaskLockbox().findLocksForTask(task);
+ for (TaskLock lock : locks) {
+ if (lock.getType() != TaskLockType.APPEND) {
+ throw InvalidInput.exception(
+ "Cannot use action[%s] for task[%s] as it is holding a lock of
type[%s] instead of [APPEND].",
+ "CommitRealtimeSegmentsAndMetadata", task.getId(), lock.getType()
Review Comment:
Since this error will find its way to end user, we should avoid using names
such as `CommitRealtimeSegmentsAndMetadata`
--
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]