Skip to content

KAFKA-14491: [13/N] Add versioned store builder and materializer#13274

Merged
mjsax merged 2 commits into
apache:trunkfrom
vcrfxia:kip-889-versioned-builder
Mar 7, 2023
Merged

KAFKA-14491: [13/N] Add versioned store builder and materializer#13274
mjsax merged 2 commits into
apache:trunkfrom
vcrfxia:kip-889-versioned-builder

Conversation

@vcrfxia

@vcrfxia vcrfxia commented Feb 17, 2023

Copy link
Copy Markdown
Contributor

This PR introduces VersionedKeyValueStoreBuilder for building the new versioned stores introduced in KIP-889, analogous to the existing TimestampedKeyValueStoreBuilder for building timestamped stores. This PR also updates the existing KTable store materializer class to materialize versioned stores in addition to timestamped stores. As part of this change, the materializer is renamed from TimestampedKeyValueStoreMaterializer to simply KeyValueStoreMaterializer.

Committer Checklist (excluded from commit message)

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

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.

Regardless of whether the Materialized instance passed for a versioned store has caching enabled or not, the resulting store will not have caching enabled as versioned stores don't support caching. This could be confusing to users but I don't think we have a good way around it since Materialized instances default to having caching enabled. If Materialized defaulted to caching disabled, then we could throw an error if withCachingEnabled() is called for Materialized instances with versioned suppliers, but given that the default is already to have caching enabled, it seems harsh/inconvenient to require users to explicitly call withCachingDisabled() in order to use versioned stores.

I think the most we should do is log a warning. Curious to hear other opinions.

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.

Don't have a strong opinion. Pinging @guozhangwang and @vvcephei for input.

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.

I guess it can't hurt to log at INFO/WARN level about it?

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.

OK, I've added an INFO log statement for now, while we wait for additional opinions.

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.

+1 on an INFO log (or no log at all).

Caching is non-functional behavior, so it makes sense for a store that doesn't support it (yet) just to treat it as a request and ignore it.

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.

This addition, and the analogous one in AbstractReadWriteDecorator, is necessary so that ProcessorContextImpl#getStateStore() can properly return versioned stores.

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.

These test changes are not directly related to this PR. While I was in here looking for inspiration for the new VersionedKeyValueStoreBuilderTest.java tests, I noticed that these tests were broken. The only reason they were throwing NullPointerExceptions is because the supplier was not being mocked to return name and metrics scope. Once added, then passing null key or value serdes no longer throws an exception.

I also added the same required mocking into shouldThrowNullPointerIfTimeIsNull() below so that the test actually throws an NPE on time being null, and not supplier return null for name or metrics scope.

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.

This is renamed from the existing TimestampedKeyValueStoreMaterializerTest.java, but I added enough new tests (and refactored the existing ones) that Github does not identify it as a rename.

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.

While renaming this class in IntelliJ, I got a warning that a class with this name existed in a previous version of Kafka Streams. I think this is fine since it's an internal class, but wanted to call it out in case there are compatibility concerns I'm not aware of.

@vcrfxia
vcrfxia force-pushed the kip-889-versioned-builder branch from 00d4b66 to b566fd4 Compare March 2, 2023 22:28

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

LGTM. Let's see if Guozhang or John have thoughts on the caching questions.

@mjsax
mjsax merged commit 84351ef into apache:trunk Mar 7, 2023
@vcrfxia
vcrfxia deleted the kip-889-versioned-builder branch March 7, 2023 02:06
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.

3 participants