Skip to content

KAFKA-20603 : Replace MemoryLRUCache restoring flag with restore lifecycle hooks#22366

Open
muralibasani wants to merge 2 commits into
apache:trunkfrom
muralibasani:KAFKA-20603
Open

KAFKA-20603 : Replace MemoryLRUCache restoring flag with restore lifecycle hooks#22366
muralibasani wants to merge 2 commits into
apache:trunkfrom
muralibasani:KAFKA-20603

Conversation

@muralibasani
Copy link
Copy Markdown
Contributor

@muralibasani muralibasani commented May 24, 2026

Ref : https://issues.apache.org/jira/browse/KAFKA-20603

Only refactoring.

Replace MemoryLRUCache restoring flag with onRestoreStart/onRestoreEnd lifecycle hooks on internal RecordBatchingStateRestoreCallback

@muralibasani muralibasani marked this pull request as draft May 24, 2026 20:03
@muralibasani muralibasani marked this pull request as ready for review May 24, 2026 20:09
@UladzislauBlok
Copy link
Copy Markdown
Contributor

Thanks for the PR.
While code looks okay, I want to check on the proposal overall. It looks like we just introduced more complicated solution to just reset flag. Isn't that overkill?

Comment on lines +251 to +254
// visible for testing
RecordBatchingStateRestoreCallback restoreCallback() {
return restoreCallback;
}
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.

imo this is anti pattern, and we shouldn't test so low level functions. "Test behavior, not implementation"

@muralibasani
Copy link
Copy Markdown
Contributor Author

Thanks for the PR. While code looks okay, I want to check on the proposal overall. It looks like we just introduced more complicated solution to just reset flag. Isn't that overkill?

@UladzislauBlok thanks for the review.
Indeed looks like an overkill. The original TODO comment

// TODO: this is a sub-optimal solution to avoid logging during restoration. 
// in the future we should augment the StateRestoreCallback with onComplete etc to better resolve this.

is actually addressed by a simple try finally inside MemoryLRUCache, then the flag becomes exception safe and it is not sub-optimal anymore imo.

But currently only MemoryLRUCache reads this flag, so the new design proposed does not justify it. If we have another consumer/store needs this flag, design gets justified.

For now, if we want to keep it simple, we can revert this design choice and introduce a try/finally here


Let me know.

@github-actions github-actions Bot removed the triage PRs from the community label May 26, 2026
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