Skip to content

KAFKA-14491: [17/N] Refactor segments cleanup logic#13365

Merged
mjsax merged 1 commit into
apache:trunkfrom
vcrfxia:kip-889-logical-segments-cleanup
Mar 21, 2023
Merged

KAFKA-14491: [17/N] Refactor segments cleanup logic#13365
mjsax merged 1 commit into
apache:trunkfrom
vcrfxia:kip-889-logical-segments-cleanup

Conversation

@vcrfxia

@vcrfxia vcrfxia commented Mar 8, 2023

Copy link
Copy Markdown
Contributor

Prior to this PR, AbstractSegments automatically called the helper method to clean up expired segments as part of getOrCreateSegmentIfLive(). This works fine for windowed store implementations which call getOrCreateSegmentIfLive() exactly once per put() call, but is inefficient and difficult to reason about for the new RocksDBVersionedStore implementation (cf. #13188) which makes potentially multiple calls to getOrCreateSegmentIfLive() for different segments for a single put() call. This PR addresses this by refactoring the call to clean up expired segments out of getOrCreateSegmentIfLive(), opting to have the different segments implementations specify when cleanup should occur instead. After this PR, RocksDBVersionedStore only cleans up expired segments once per call to put().

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

@mjsax mjsax added streams kip Requires or implements a KIP labels Mar 11, 2023

@mjsax mjsax left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Overall LGTM. One nit question.


@Override
public void cleanupExpiredSegments(final long streamTime) {
super.cleanupExpiredSegments(streamTime);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If we only call super... why do we need to overwrite the method to begin with?

@vcrfxia vcrfxia Mar 14, 2023

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.

The method from AbstractSegments is protected, but LogicalKeyValueSegments needs to expose it publicly so that it can be called from the versioned store implementation.

Admittedly looks odd at first glance. I can add a comment into the code if you think it'd be useful?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ah. I see. Guess it would get clear quickly in an IDE -- just hard to see on GitHub. Seems fine w/o a comment.

@mjsax
mjsax merged commit 361095a into apache:trunk Mar 21, 2023
@vcrfxia
vcrfxia deleted the kip-889-logical-segments-cleanup branch March 21, 2023 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kip Requires or implements a KIP streams

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants