Skip to content

Upgrade pending segments when a concurrent replace happens#15097

Closed
kfaraz wants to merge 8 commits intoapache:masterfrom
kfaraz:upgrade_pending_segments
Closed

Upgrade pending segments when a concurrent replace happens#15097
kfaraz wants to merge 8 commits intoapache:masterfrom
kfaraz:upgrade_pending_segments

Conversation

@kfaraz
Copy link
Copy Markdown
Contributor

@kfaraz kfaraz commented Oct 5, 2023

[WIP]

Description

Changes

  • Add new task action to commit realtime segments when using APPEND locks
  • Include TaskLockType in SequenceMetadata. The lock type is used to determine the right action type for committing realtime segments.
  • Add utility method IndexTaskUtils.emitSegmentPublishMetrics
  • Remove unused method IndexTaskUtils.getMessagesFromSavedParseExceptions

Pending changes

  • Add method in IndexerMetadataStorageCoordinator to commit segments, commit metadata and upgrade segments in the same transaction
  • Fix commitReplaceSegments method to identify pending segments to upgrade and create upgraded entries

This PR has:

  • been self-reviewed.
  • added documentation for new or modified features or behaviors.
  • a release note entry in the PR description.
  • added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
  • added or updated version, license, or notice information in licenses.yaml
  • added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
  • added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage is met.
  • added integration tests.
  • been tested in a test Druid cluster.

* This action differs from {@link SegmentTransactionalInsertAction} as it is used
* only with APPEND locks and also upgrades segments as needed.
*/
public class CommitRealtimeSegmentsAndMetadataAction implements TaskAction<SegmentPublishResult>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we not re-use SegmentTransactionAppendAction with the metadata being null for batch and the required values for streaming ingestion (similar to the original insert action)?

Is there anything besides the metadata commit that this action does that the transactional append action doesn't?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I was thinking the same. Let me see what we can do.

Comment on lines +122 to +123
"Cannot use action[%s] for task[%s] as it is holding a lock of type[%s] instead of [APPEND].",
"CommitRealtimeSegmentsAndMetadata", task.getId(), lock.getType()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this error will find its way to end user, we should avoid using names such as CommitRealtimeSegmentsAndMetadata

@JsonProperty("checkpointed") boolean checkpointed,
@JsonProperty("exclusiveStartPartitions") Set<PartitionIdType> exclusiveStartPartitions
@JsonProperty("exclusiveStartPartitions") Set<PartitionIdType> exclusiveStartPartitions,
@JsonProperty("taskLockType") TaskLockType taskLockType
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be nullable for backward compatibility reasons. should it not?

}

final String dataSource = appendSegments.iterator().next().getDataSource();
final Set<DataSegment> upgradedSegments = connector.retryTransaction(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
final Set<DataSegment> upgradedSegments = connector.retryTransaction(
final Set<DataSegment> segmentsToUpgrade = connector.retryTransaction(

@kfaraz
Copy link
Copy Markdown
Contributor Author

kfaraz commented Oct 16, 2023

Closing this PR as these changes have already been merged as a part of #15039

@kfaraz kfaraz closed this Oct 16, 2023
@kfaraz kfaraz deleted the upgrade_pending_segments branch October 16, 2023 05:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants