Skip to content
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

[improve][broker][PIP-286] Make the TopicCompactionService to support find entry based on publishTime or index #21208

Merged
merged 3 commits into from
Oct 18, 2023

Conversation

coderzc
Copy link
Member

@coderzc coderzc commented Sep 20, 2023

PIP: #20867

Motivation

#20867

Modifications

Add findEntryByPublishTime and findEntryByEntryIndex in the TopicCompactionService API.

Implement them in the PulsarTopicCompactionService using binary search.

Verifying this change

  • Make sure that the change passes the CI checks.

(Please pick either of the following options)

This change is a trivial rework / code cleanup without any test coverage.

(or)

This change is already covered by existing tests, such as (please describe tests).

(or)

This change added tests and can be verified as follows:

(example:)

  • Added integration tests for end-to-end deployment with large payloads (10MB)
  • Extended integration test for recovery after broker failure

Does this pull request potentially affect one of the following parts:

If the box was checked, please highlight the changes

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository:

@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Sep 20, 2023
@coderzc coderzc self-assigned this Sep 20, 2023
@coderzc coderzc added this to the 3.2.0 milestone Sep 20, 2023
@coderzc coderzc added type/feature The PR added a new feature or issue requested a new feature area/broker type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages and removed type/feature The PR added a new feature or issue requested a new feature labels Sep 20, 2023
Copy link
Contributor

@Technoboy- Technoboy- left a comment

Choose a reason for hiding this comment

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

LGTM


@Override
public CompletableFuture<Entry> findEntryByEntryIndex(long entryIndex) {
final Predicate<Entry> predicate = entry -> {
Copy link
Member

Choose a reason for hiding this comment

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

How do you handle if the entry index is minus value?

Copy link
Member Author

@coderzc coderzc Oct 16, 2023

Choose a reason for hiding this comment

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

It will return the first entry of compacted data, this is also consistent with the method definition, what do you think?

@@ -106,6 +111,78 @@ public CompletableFuture<Position> getLastCompactedPosition() {
return CompletableFuture.completedFuture(compactedTopic.getCompactionHorizon().orElse(null));
}

@Override
public CompletableFuture<Entry> findEntryByPublishTime(long publishTime) {
final Predicate<Entry> predicate = entry -> {
Copy link
Member

Choose a reason for hiding this comment

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

How do you handle if the publishTime is minus value?

Copy link
Member

@mattisonchao mattisonchao left a comment

Choose a reason for hiding this comment

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

LGTM :)

CompletableFuture<Entry> findEntryByPublishTime(long publishTime);

/**
* Find the first entry that greater or equal to target entryIndex.
Copy link
Contributor

Choose a reason for hiding this comment

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

It requires the broker entry metadata. So we'd better improve the Javadoc to explain the behavior of broker entry metadata missed.

And please also add a test for this case.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok. I changed the test to cover this case.

@coderzc coderzc requested a review from codelipenghui October 16, 2023 13:00
@codelipenghui
Copy link
Contributor

/pulsarbot run-failure-checks

@coderzc coderzc merged commit b1bca56 into apache:master Oct 18, 2023
44 of 45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/broker area/compaction doc-not-needed Your PR changes do not impact docs ready-to-test type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants