Skip to content

KAFKA-16254: Allow MM2 to fully disable offset sync feature#15999

Merged
mimaison merged 39 commits intoapache:trunkfrom
OmniaGM:KAFKA-16254-mm2-disallow-offset-sync
Jul 9, 2024
Merged

KAFKA-16254: Allow MM2 to fully disable offset sync feature#15999
mimaison merged 39 commits intoapache:trunkfrom
OmniaGM:KAFKA-16254-mm2-disallow-offset-sync

Conversation

@OmniaGM
Copy link
Copy Markdown
Contributor

@OmniaGM OmniaGM commented May 20, 2024

Implementation of KIP-1031 https://cwiki.apache.org/confluence/display/KAFKA/KIP-1031%3A+Control+offset+translation+in+MirrorSourceConnector

Committer Checklist (excluded from commit message)

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

@gharris1727 gharris1727 added mirror-maker-2 kip Requires or implements a KIP labels May 20, 2024
Copy link
Copy Markdown
Member

@chia7712 chia7712 left a comment

Choose a reason for hiding this comment

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

@OmniaGM I have left some comments in the discussion thread (https://lists.apache.org/thread/2scgvn66vs8c04ldxsj4sw2vlo6wd98o). It would be great if you have free time to take a look.

For another code style idea: Could we have a new static class including all "emit"-related code? That will have following benefits.

  1. more readable. The static class can be null (or empty) to "prove" that this function is "disabled"
  2. no unused objects are created. For example, offsetProducer, delayedOffsetSyncs, pendingOffsetSyncs are unused if the emit is disable
  3. easy to test emit behavior as all they in single static class now.

WDYT?

@OmniaGM OmniaGM force-pushed the KAFKA-16254-mm2-disallow-offset-sync branch from 5ae6390 to 3038580 Compare May 21, 2024 15:26
@OmniaGM
Copy link
Copy Markdown
Contributor Author

OmniaGM commented May 21, 2024

@OmniaGM I have left some comments in the discussion thread (https://lists.apache.org/thread/2scgvn66vs8c04ldxsj4sw2vlo6wd98o). It would be great if you have free time to take a look.

For another code style idea: Could we have a new static class including all "emit"-related code? That will have following benefits.

  1. more readable. The static class can be null (or empty) to "prove" that this function is "disabled"
  2. no unused objects are created. For example, offsetProducer, delayedOffsetSyncs, pendingOffsetSyncs are unused if the emit is disable
  3. easy to test emit behavior as all they in single static class now.

WDYT?

We kinda have OffsetSyncStore and based on the name it looks like the right place for this however, it is focused on read from the offsetSyncs topic. I added another one called OffsetSyncWriter and moved all emitting offsets code into there. let me know if this is okay!

@OmniaGM OmniaGM force-pushed the KAFKA-16254-mm2-disallow-offset-sync branch from 10eb256 to 557591b Compare May 21, 2024 17:06
Copy link
Copy Markdown
Member

@chia7712 chia7712 left a comment

Choose a reason for hiding this comment

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

@OmniaGM Nice patch!

@OmniaGM OmniaGM force-pushed the KAFKA-16254-mm2-disallow-offset-sync branch from 436ce41 to 4958ac1 Compare May 22, 2024 09:38
Copy link
Copy Markdown
Member

@soarez soarez 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 this PR @OmniaGM

@OmniaGM OmniaGM requested a review from soarez May 29, 2024 16:44
@chia7712
Copy link
Copy Markdown
Member

just remind that today is the deadline for feature freeze. If this PR is necessary for 3.8.0, we need to cherry-pick to branch-3.8

@OmniaGM
Copy link
Copy Markdown
Contributor Author

OmniaGM commented May 29, 2024

I was hoping for it to land in 3.8.0 I'll raise a PR against 3.8 once we merge it into trunk. however It shouldn't be a blocker for 3.8

Copy link
Copy Markdown
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.

@OmniaGM
Copy link
Copy Markdown
Contributor Author

OmniaGM commented Jun 28, 2024

@C0urante I believe I addressed all the comments now, can you please have a second look?

Copy link
Copy Markdown
Contributor

@C0urante C0urante left a comment

Choose a reason for hiding this comment

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

Thanks, this is looking really good! Had some more thoughts on the validation logic but apart from that I think we're basically there. The integration tests (minus the accidental failed creation for the MirrorCheckpointConnector) look especially nice 👍

Copy link
Copy Markdown
Contributor

@C0urante C0urante left a comment

Choose a reason for hiding this comment

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

Thanks @OmniaGM! Really close, made it all the way through the tests and the comments from this round should be all that need to be addressed before we can merge.

@OmniaGM OmniaGM force-pushed the KAFKA-16254-mm2-disallow-offset-sync branch from 66e0246 to fd6e0e0 Compare July 1, 2024 22:26
Copy link
Copy Markdown
Contributor

@C0urante C0urante 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 @OmniaGM!

@C0urante
Copy link
Copy Markdown
Contributor

C0urante commented Jul 2, 2024

@mimaison @chia7712 @soarez I plan on merging this by the end of the week; if any of you would like to do another round before I merge, please let me know.

Copy link
Copy Markdown
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 updates. I made another pass. It looks good, I just left a few small suggestions.

Copy link
Copy Markdown
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

Copy link
Copy Markdown
Member

@chia7712 chia7712 left a comment

Choose a reason for hiding this comment

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

@OmniaGM thanks for your patch and patient. a couple of comments left PTAL

List<ConfigValue> configValues = super.validate(connectorConfigs).configValues();
MirrorCheckpointConfig.validate(connectorConfigs).forEach((config, errorMsg) ->
configValues.stream()
.filter(conf -> conf.name().equals(config))
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.

EMIT_OFFSET_SYNCS_ENABLED is in MirrorSourceConfig, so it is not a part of config def of MirrorCheckpointConnector. Hence, the error related to EMIT_OFFSET_SYNCS_ENABLED can't be propagated.

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.

The following test shows my concern:

    @Test
    public void test() {
        Map<String, String> props = new HashMap<>();
        props.put(MirrorConnectorConfig.EMIT_OFFSET_SYNCS_ENABLED, "false");
        MirrorCheckpointConnector connector = new MirrorCheckpointConnector();
        Config config = connector.validate(props);
        assertEquals(1, config.configValues().stream().filter(c -> c.name().equals(MirrorConnectorConfig.EMIT_OFFSET_SYNCS_ENABLED)).count());
    }

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.

I moved this to MirrorConnectorConfig which all inherit. So this should be addressed now

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.

I still agree with @mimaison that we shouldn't have this property in the MirrorConnectorConfig class, since then it'll be included as a "common config" for all connectors in our generated docs here instead of in the MirrorSourceConnector-specific docs here.

Can we just add a new ConfigValue for the property in MirrorCheckpointConnector::validate if we find a validation error with 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.

I updated MirrorCheckpointConnector::validate to create configValue if the name of the config not defined

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.

Sorry for the confusion I just lost track of @mimaison point from before! this why I reverted config back to MirrorConnectorConfig

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.

No worries! Latest looks good to me 👍

@chia7712 thoughts?

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

boolean offsetSyncsConfigured = props.keySet().stream()
.anyMatch(conf -> conf.startsWith(OFFSET_SYNCS_CLIENT_ROLE_PREFIX) || conf.startsWith(OFFSET_SYNCS_TOPIC_CONFIG_PREFIX));

if ("false".equals(props.get(MirrorConnectorConfig.EMIT_OFFSET_SYNCS_ENABLED)) && offsetSyncsConfigured) {
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.

what if EMIT_OFFSET_SYNCS_ENABLED=true and offsetSyncsConfigured=false? Should we add error message for 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.

No, because offsetSyncsConfigured has default which is the global configs for topics and clients

@OmniaGM OmniaGM requested a review from chia7712 July 3, 2024 13:47
Copy link
Copy Markdown
Member

@chia7712 chia7712 left a comment

Choose a reason for hiding this comment

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

@OmniaGM thanks for updated PR. the last two comments are left. PTAL


if (emitCheckpointDisabled && syncGroupOffsetsDisabled) {
Arrays.asList(SYNC_GROUP_OFFSETS_ENABLED, EMIT_CHECKPOINTS_ENABLED).forEach(configName -> {
invalidConfigs.putIfAbsent(configName, "MirrorCheckpointConnector can't run with both " + SYNC_GROUP_OFFSETS_ENABLED + " and " +
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.

It seems to me EMIT_CHECKPOINTS_ENABLED does not obstruct MirrorCheckpointConnector from running since it is used to update consumer groups offsets of target cluster. By contrast, SYNC_GROUP_OFFSETS_ENABLED do impact the MirrorCheckpointConnector

https://github.com/apache/kafka/blob/trunk/connect/mirror/src/main/java/org/apache/kafka/connect/mirror/MirrorCheckpointConnector.java#L121

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.

My understanding that it will not start a task so the connector would be doing nothing without any feedback or indication for why. If this is problematic I would suggest remove this check as this was a suggestion out of the scope of the KIP to begin with. @C0urante and @chia7712 WDYT?

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.

I didn't realize that we disabled the connector from generating task configs if checkpoints were disabled. In that case, I think we should remove the check for sync.group.offsets.enabled altogether and just check emit.checkpoints.enabled. But generally I agree with @OmniaGM that if we don't generate task configs for the connector when it's configured that way, it's best to surface this as a validation error instead of silently degrading to a no-op.

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.

It seems to me EMIT_CHECKPOINTS_ENABLED does not obstruct MirrorCheckpointConnector from running since it is used to update consumer groups offsets of target cluster. By contrast, SYNC_GROUP_OFFSETS_ENABLED do impact the MirrorCheckpointConnector

I just notice that I use the incorrect config name :(

My understanding that it will not start a task so the connector would be doing nothing without any feedback or indication for why.

agree and my point was "we should return invalid config if EMIT_CHECKPOINTS_ENABLED=false", because SYNC_GROUP_OFFSETS_ENABLED=false is allowed to MirrorCheckpointConnector . For example: in this case: EMIT_CHECKPOINTS_ENABLED=false and SYNC_GROUP_OFFSETS_ENABLED=true we should return invalid configs, right?

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.

I removed the validation for sync.group.offsets.enabled and kept emit.checkpoints.enabled validation only

Copy link
Copy Markdown
Member

@chia7712 chia7712 left a comment

Choose a reason for hiding this comment

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

LGTM and thanks @OmniaGM patient to complete this great feature!

Copy link
Copy Markdown
Contributor

@C0urante C0urante left a comment

Choose a reason for hiding this comment

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

Ditto @chia7712's comments; thank you so much for your patience @OmniaGM!

@OmniaGM
Copy link
Copy Markdown
Contributor Author

OmniaGM commented Jul 9, 2024

Thanks All for reviewing this PR. I reviewed the failed tests and they are unrelated.

@mimaison mimaison merged commit 0781151 into apache:trunk Jul 9, 2024
abhi-ksolves pushed a commit to ksolves/kafka that referenced this pull request Jul 31, 2024
…5999)


Reviewers: Mickael Maison <mickael.maison@gmail.com>, Chris Egerton <fearthecellos@gmail.com>, Chia-Ping Tsai <chia7712@gmail.com>, Igor Soarez <soarez@apple.com>
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 mirror-maker-2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants