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] Improve CompactedTopicImpl lock #20697

Merged
merged 1 commit into from
Jul 4, 2023

Conversation

coderzc
Copy link
Member

@coderzc coderzc commented Jun 30, 2023

Motivation

Currently, some synchronized is used in CompactedTopicImpl to avoid data contention, but it does not completely avoid data contention due to asynchronous operations and may lead to cursor skipping some data.

The cursor may skip some data due to compactionHorizon be updated:

Modifications

  • Remove unnecessary synchronized.
  • Make compactionHorizon unchanged when reading compacted data.
  • Add volatile for compactedTopicContext.

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

Documentation

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

Matching PR in forked repository

PR in forked repository:

@coderzc coderzc changed the title Improve CompactedTopicImpl lock [improve][broker] Improve CompactedTopicImpl lock Jun 30, 2023
@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Jun 30, 2023
callback.readEntriesComplete(Collections.emptyList(), readEntriesCtx);
return CompletableFuture.completedFuture(null);
}
if (startPoint == NEWER_THAN_COMPACTED && compactionHorizon.compareTo(cursorPosition) < 0) {
cursor.asyncReadEntriesOrWait(numberOfEntriesToRead, callback, readEntriesCtx,
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need keep this logic ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Condition is always false because it has been judged line-107.

@codelipenghui codelipenghui added this to the 3.1.0 milestone Jul 3, 2023
@codelipenghui codelipenghui added type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages area/broker labels Jul 3, 2023
@codelipenghui
Copy link
Contributor

/pulsarbot run-failure-checks

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 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.

4 participants