Skip to content

KAFKA-18893: Add KIP-877 support to ReplicaSelector #19064

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

Merged
merged 10 commits into from
Mar 21, 2025

Conversation

TaiJuWu
Copy link
Collaborator

@TaiJuWu TaiJuWu commented Mar 1, 2025

ReplicaSelector implementations can implement Monitorable to register their own metrics.

Reviewers: Mickael Maison [email protected], Ken Huang [email protected]

@github-actions github-actions bot added triage PRs from the community core Kafka Broker clients small Small PRs labels Mar 1, 2025
@TaiJuWu TaiJuWu closed this Mar 1, 2025
@TaiJuWu TaiJuWu reopened this Mar 1, 2025
@TaiJuWu TaiJuWu marked this pull request as ready for review March 1, 2025 09:23
Copy link
Collaborator

@m1a2st m1a2st left a comment

Choose a reason for hiding this comment

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

Thank @TaiJuWu this PR, left a comment

@@ -27,6 +27,9 @@
/**
* Plug-able interface for selecting a preferred read replica given the current set of replicas for a partition
* and metadata from the client.
* Implement {@link org.apache.kafka.common.metrics.Monitorable} to enable the interceptor to register metrics.
Copy link
Collaborator

Choose a reason for hiding this comment

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

to enable the interceptor to register metrics. should be to enable the selector to register metrics.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for catching it, fixed.

@github-actions github-actions bot removed the triage PRs from the community label Mar 3, 2025
@mimaison mimaison marked this pull request as draft March 10, 2025 21:36
@mimaison
Copy link
Member

Converted to draft as per https://lists.apache.org/thread/hwrrztts7j8jwwkk740848hd6y8p2c0x

Giving the community a few days to review the proposed changes. If no objections are raised, I'll mark it back as ready.

@mimaison
Copy link
Member

Since no objections were raised and none of the proposed changes to KIP-877 impact ReplicaSelector, I'm putting it back into "Ready for review" state.

@mimaison mimaison marked this pull request as ready for review March 18, 2025 18:02
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, I left a few comments

@@ -1723,7 +1723,7 @@ class ReplicaManager(val config: KafkaConfig,
metadata => findPreferredReadReplica(partition, metadata, params.replicaId, fetchInfo.fetchOffset, fetchTimeMs))

if (preferredReadReplica.isDefined) {
replicaSelectorOpt.foreach { selector =>
replicaSelectorPlugin.foreach { selector =>
debug(s"Replica selector ${selector.getClass.getSimpleName} returned preferred replica " +
Copy link
Member

Choose a reason for hiding this comment

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

This needs updating, now selector is of type Plugin here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not sure I understand is correct or not.
I changed the debug message to debug(s"Replica selector plugin ${selector.getClass.getSimpleName} returned preferred replica " + s"${preferredReadReplica.get} for ${params.clientMetadata}")

If I am misunderstanding , please correct me.

Copy link
Member

Choose a reason for hiding this comment

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

Isn't it going to print Replica selector Plugin returned preferred replica now?
Instead we want Replica selector RackAwareReplicaSelector returned preferred replica so I think we need to call ${selector.get.getClass.getSimpleName}

Copy link
Collaborator Author

@TaiJuWu TaiJuWu Mar 20, 2025

Choose a reason for hiding this comment

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

Oh, you are correct. Thanks for catching it.
f1d62cb is the fix.

All comments are addressed. Thanks for your review!

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, thanks for the PR!

@mimaison mimaison changed the title KAFKA-18893: KIP-877 Add support for ReplicaSelector KAFKA-18893: Add KIP-877 support to ReplicaSelector Mar 21, 2025
@mimaison mimaison merged commit 79fe130 into apache:trunk Mar 21, 2025
26 checks passed
@TaiJuWu TaiJuWu deleted the 877_replicaSelector branch March 21, 2025 14:44
ShivsundarR pushed a commit to ShivsundarR/kafka that referenced this pull request Mar 26, 2025
ReplicaSelector implementations can implement Monitorable to register their own metrics.

Reviewers: Mickael Maison <[email protected]>, Ken Huang <[email protected]>
config.replicaSelectorClassName.map { className =>
val tmpReplicaSelector: ReplicaSelector = Utils.newInstance(className, classOf[ReplicaSelector])
tmpReplicaSelector.configure(config.originals())
tmpReplicaSelector
Plugin.wrapInstance(tmpReplicaSelector, metrics, className)
Copy link
Member

Choose a reason for hiding this comment

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

I just noticed that this is not correct. Instead of className, the second argument should be the name of the configuration: REPLICA_SELECTOR_CLASS_CONFIG.

I fixed that in my PR adding KIP-877 support to the authorizer: #19050

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants