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

KAFKA-18373: Remove ZkMetadataCache #18553

Merged
merged 4 commits into from
Jan 17, 2025
Merged

Conversation

FrankYang0529
Copy link
Member

Committer Checklist (excluded from commit message)

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

@github-actions github-actions bot added the core Kafka Broker label Jan 15, 2025
@FrankYang0529 FrankYang0529 marked this pull request as draft January 15, 2025 14:17
@ijuma
Copy link
Member

ijuma commented Jan 15, 2025

We should also remove casts to the KRaft metadata cache as part of this JIRA or a file a separate issue for that.

@FrankYang0529
Copy link
Member Author

We should also remove casts to the KRaft metadata cache as part of this JIRA or a file a separate issue for that.

Yes, I will do it in this PR. Thanks for the reminder.

@chia7712
Copy link
Member

@FrankYang0529 please fix the conflicts

@FrankYang0529 FrankYang0529 marked this pull request as ready for review January 15, 2025 15:45
@chia7712
Copy link
Member

We should also remove casts to the KRaft metadata cache as part of this JIRA or a file a separate issue for that.

If MetadataCache is extensively used throughout the codebase, replacing all instances with KRaftMetadataCache within this single PR could result in a significant and potentially disruptive change. Maybe we should focus on modifying only the directly related paths and files, minimizing the scope of this PR.

@FrankYang0529
Copy link
Member Author

FrankYang0529 commented Jan 15, 2025

We should also remove casts to the KRaft metadata cache as part of this JIRA or a file a separate issue for that.

Yes, I will do it in this PR. Thanks for the reminder.

Sorry, I did some quick survey. I would like to make sure we're on the same page first. Do we want to remove MetadataCache interface? I create anothre Jira for followup, so this discussion doesn't block this PR. Thanks.

https://issues.apache.org/jira/browse/KAFKA-18555

// TODO: support raft code?
private var metadataCache = new ZkMetadataCache(0, MetadataVersion.latestTesting(), BrokerFeatures.createEmpty())
metadataCache.updateMetadata(0, updateMetadataRequest)
private val metadataDelta = new MetadataDelta(MetadataImage.EMPTY)
Copy link
Collaborator

@TaiJuWu TaiJuWu Jan 15, 2025

Choose a reason for hiding this comment

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

Should we need this? it more like zk logic.
I have a similar fix https://github.com/apache/kafka/pull/18354/files

Copy link
Member

Choose a reason for hiding this comment

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

I don't understand the question - what do you mean it's zk logic?

Copy link
Member

Choose a reason for hiding this comment

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

I believe @TaiJuWu is suggesting that this data was previously used by zk-related tests. Since these zk-related tests have already been removed, there is no longer a need to set this data.

Copy link
Member

@ijuma ijuma Jan 16, 2025

Choose a reason for hiding this comment

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

That seems a bit odd. This class is testing functionality that is independent of zk. In such cases, we have to be very careful that we're deleting tests that are actually zk specific versus testing functionality that is general but were never converted to the kraft way.

Copy link
Collaborator

@TaiJuWu TaiJuWu Jan 16, 2025

Choose a reason for hiding this comment

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

My bad. previous what I think was this setting is test for IBP2.6 but it was deleted by #18468
After checking (checkout to 3.9 and deleted metadataCache.updateMetadata), I found all tests are passed so I am not sure what it is for.

Copy link
Member

Choose a reason for hiding this comment

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

OK, so this is perhaps just dead code (zk or otherwise). That's a nice catch. :)

@ijuma
Copy link
Member

ijuma commented Jan 15, 2025

No, we should not change all the codebase to use the Kraft metadata cache. Instead, we should move the relevant methods from the Kraft implementation to the interface so we don't need to cast - that should not be a large change (but someone needs to check).

@ijuma ijuma closed this Jan 15, 2025
@ijuma ijuma reopened this Jan 15, 2025
@ijuma
Copy link
Member

ijuma commented Jan 15, 2025

Apologies for closing accidentally - I reopened.

@FrankYang0529 FrankYang0529 force-pushed the KAFKA-18373 branch 2 times, most recently from 5cf16eb to f3d7a74 Compare January 16, 2025 11:05

import scala.jdk.CollectionConverters._

class FinalizedFeatureCacheTest {
Copy link
Member

Choose a reason for hiding this comment

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

Don't we need this with kraft?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, in this test, most of cases test ZkMetadataCache#updateFeaturesOrThrow. IIUC, in KRaft, it receives update via setImage, so it doesn't have similar cases as ZkMetadataCache.

Copy link
Member

Choose a reason for hiding this comment

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

OK, thanks.

Copy link
Member

@mimaison mimaison left a comment

Choose a reason for hiding this comment

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

Thanks for the PR. It looks good overall, I just left a couple of minor suggestions.

@@ -42,7 +42,7 @@ import org.mockito.ArgumentMatchers.{any, anyBoolean}
import org.mockito.Mockito.{doNothing, mock, never, times, verify, verifyNoInteractions, verifyNoMoreInteractions, when}
import org.mockito.{ArgumentCaptor, ArgumentMatchers, Mockito}

import java.util.{Collections, Optional, OptionalInt, OptionalLong}
import java.util.{Optional, OptionalInt, OptionalLong}
Copy link
Member

Choose a reason for hiding this comment

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

It looks like Map imported just below is unused, so we can delete it.

import org.apache.kafka.server.config.ReplicationConfigs
import org.apache.kafka.server.common.{MetadataVersion, OffsetAndEpoch}
Copy link
Member

Choose a reason for hiding this comment

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

scala.collection.Map imported below seems unused, can we delete it too?

Copy link
Member

@mimaison mimaison left a comment

Choose a reason for hiding this comment

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

LGTM

@mimaison mimaison merged commit 5a1fb15 into apache:trunk Jan 17, 2025
8 of 9 checks passed
mimaison pushed a commit that referenced this pull request Jan 17, 2025
@mimaison
Copy link
Member

Applied to 4.0 too: be5b5f3

pranavt84 pushed a commit to pranavt84/kafka that referenced this pull request Jan 27, 2025
airlock-confluentinc bot pushed a commit to confluentinc/kafka that referenced this pull request Jan 27, 2025
manoj-mathivanan pushed a commit to manoj-mathivanan/kafka that referenced this pull request Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Kafka Broker
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants