Skip to content

KAFKA-8179: Part 3, Add PartitionsLost API for resetGenerations and metadata/subscription change#6884

Merged
guozhangwang merged 91 commits intoapache:trunkfrom
guozhangwang:K8179-p3-emigrate-callback
Aug 8, 2019
Merged

KAFKA-8179: Part 3, Add PartitionsLost API for resetGenerations and metadata/subscription change#6884
guozhangwang merged 91 commits intoapache:trunkfrom
guozhangwang:K8179-p3-emigrate-callback

Conversation

@guozhangwang
Copy link
Copy Markdown
Contributor

@guozhangwang guozhangwang commented Jun 5, 2019

  1. Add onPartitionsLost into the RebalanceListener, which will be triggered when a) reset generations due to errors, and b) topic metadata changed and owned partitions no longer exist.

When resetting generations proactively and subscription changes, we will trigger onPartitionsRevoked instead.

  1. Semantical behavior change: with COOPERATIVE protocol, if the revoked / lost partitions are empty, do not trigger the corresponding callback at all. For added partitions though, even if it is empty we would still trigger the callback as a way to notify the rebalance event; with EAGER protocol, revoked / assigned callbacks are always triggered.

The ordering of the callback would be the following:

a. Callback onPartitionsRevoked / onPartitionsLost triggered.
b. Update the assignment (both revoked and added).
c. Callback onPartitionsAssigned triggered.

In this way we are assured that users can still access the partitions being revoked, whereas they can also access the partitions being added.

  1. Semantical behavior change (KAFKA-4600): if the rebalance listener throws an exception, pass it along all the way to the consumer.poll caller, but still completes the rest of the actions. Also, the newly assigned partitions list does not gets affected with exception thrown since it is just for notifying the users.

  2. Semantical behavior change: the ConsumerCoordinator would not try to modify assignor's returned assignments, instead it will validate that assignments and set the error code accordingly: if there are overlaps between added / revoked partitions, it is a fatal error and would be communicated to all members to stop; if revoked is not empty, it is an error indicate re-join; otherwise, it is normal.

  3. Minor: with the error code removed from the Assignment, ConsumerCoordinator will request re-join if the revoked partitions list is not empty.

  4. Updated ConsumerCoordinatorTest accordingly. Also found a minor bug in MetadataUpdate that removed topic would still be retained with null value of num.partitions.

  5. Updated a few other unit tests that are exposed due to this change.

Committer Checklist (excluded from commit message)

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

…pache#6511)

As described in KIP-443 (https://cwiki.apache.org/confluence/display/KAFKA/KIP-443%3A+Return+to+default+segment.ms+and+segment.index.bytes+in+Streams+repartition+topics). We want to remove the aggressive overrides of segment.ms and segment.index.bytes for repartition topics. The remaining segment.bytes should still be effective in bounding its footprint.

Reviewers: Bill Bejeck <bbejeck@gmail.com>
@guozhangwang
Copy link
Copy Markdown
Contributor Author

Copy link
Copy Markdown
Member

@ableegoldman ableegoldman 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 kicking off system tests -- everything LGTM

* Unsubscribe from topics currently subscribed with {@link #subscribe(Collection)} or {@link #subscribe(Pattern)}.
* This also clears any partitions directly assigned through {@link #assign(Collection)}.
*
* @throws org.apache.kafka.common.KafkaException for any other unrecoverable errors (e.g. rebalance callback errors)
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.

It might be worth mentioning in the upgrade notes the fact that we now invoke revocation logic in unsubscribe and close.

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.

Yes, that's in my plan -- I have another PR on web docs for the changes related, but wanted to keep this one from continue growing.

// heartbeat error handling is executed by heartbeat thread, in which case
// we would not drop partitions and trigger rebalance callback as it should
// only be triggered by the caller thread
if (api != ApiKeys.HEARTBEAT) {
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.

Hmm.. I am not sure this is sufficient. Any of the responses could return from the heartbeat thread.

@guozhangwang
Copy link
Copy Markdown
Contributor Author

@guozhangwang
Copy link
Copy Markdown
Contributor Author

Jenkins failures are irrelevant.

@guozhangwang
Copy link
Copy Markdown
Contributor Author

retest this please

.compose(new LeaveGroupResponseHandler());
}

// we need to reset generation first in order to trigger the rebalance callback if necessary, before sending
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.

This seems no longer relevant?

@guozhangwang
Copy link
Copy Markdown
Contributor Author

Addressed latest comment.

@guozhangwang
Copy link
Copy Markdown
Contributor Author

Jenkins failures are irrelevant and non-overlapping.

Copy link
Copy Markdown
Contributor

@hachikuji hachikuji left a comment

Choose a reason for hiding this comment

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

LGTM. I left a suggestion on an alternative name for onLeaveGroup.

/**
* Invoked prior to each leave group event. This is typically used to cleanup assigned partitions
*/
protected void onLeaveGroup() {}
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.

For consistency with onJoinPrepare and onJoinComplete, would it be reasonable to call this onLeavePrepare?

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.

Of course :)

@guozhangwang guozhangwang merged commit e867a58 into apache:trunk Aug 8, 2019
ijuma added a commit to confluentinc/kafka that referenced this pull request Aug 9, 2019
* apache-github/trunk:
  MINOR: Ignore dynamic log4j log level tests (apache#7183)
  KAFKA-8748: Fix flaky testDescribeLogDirsRequest (apache#7182)
  KAFKA-8598: Use automatic RPC generation in RenewDelegationToken
  KAFKA-8179: Part 3, Add PartitionsLost API for resetGenerations and metadata/subscription change (apache#6884)
bbejeck added a commit to bbejeck/kafka that referenced this pull request Aug 16, 2019
…setGenerations and metadata/subscription change (apache#6884)"

This reverts commit e867a58.
guozhangwang added a commit that referenced this pull request Dec 4, 2019
This is a cherry-pick of the bug-fix included in #6884 to 2.3 and older branch.

Reviewers: A. Sophie Blee-Goldman <sophie@confluent.io>, Matthias J. Sax <mjsax@apache.org>
@guozhangwang guozhangwang deleted the K8179-p3-emigrate-callback branch April 24, 2020 23:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants