You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2021/02/18 20:04:07 UTC
[GitHub] [kafka] rondagostino opened a new pull request #10155: Fix Raft broker restart issue when offset partitions are deferred
rondagostino opened a new pull request #10155:
URL: https://github.com/apache/kafka/pull/10155
A Raft-based broker is unable to restart if the broker defers partition metadata changes for a `__consumer_offsets` topic-partition. The issue is that `GroupMetadataManager` is asked to `removeGroupsForPartition()` upon the broker becoming a follower, but in order for that code to function it requires that the manager's scheduler be started. There are multiple possible solutions here since `removeGroupsForPartition()` is a no-op at this point in the broker startup cycle (nothing has been loaded, so there is nothing to unload). We could just not invoke the callback. But it seems more reasonable to not special-case this and instead start `ReplicaManager` and the coordinators just before applying the deferred partitions states.
### Committer Checklist (excluded from commit message)
- [ ] Verify design and implementation
- [ ] Verify test coverage and CI build status
- [ ] Verify documentation (including upgrade notes)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kafka] rondagostino commented on pull request #10155: Fix Raft broker restart issue when offset partitions are deferred
Posted by GitBox <gi...@apache.org>.
rondagostino commented on pull request #10155:
URL: https://github.com/apache/kafka/pull/10155#issuecomment-781610292
@cmccabe When we defer partition changes we batch everything up and only apply the latest changes at the end. I'm pretty sure you weren't asking about that, but I wanted to make it explicit just to be certain. So there is no chance of becoming a leader for a deferred partition after becoming a follower for it -- we only apply the end state, and that is either leader or follower.
What I think you were asking about is what happens if sometime later we transition to leader. That would be taken care of by the normal partition metadata processing logic. The partition remains "Online" during this entire transition. A partition transitions to Offline online only when there is a log dir failure (as an aside, that is not yet implemented for Raft-based clusters). In the absence of a log dir failure a partition can only transition between Online, Deferred, and None (meaning we are not a leader or a follower). Deferred only occurs at startup and if the broker becomes fenced after startup (this latter case is also not yet implemented). So we transition only between Online and None, and again the normal partition metadata processing logic handles these. That logic will also handle other transitions as we implement them. So I believe there is no problem here.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kafka] rondagostino commented on pull request #10155: Fix Raft broker restart issue when offset partitions are deferred
Posted by GitBox <gi...@apache.org>.
rondagostino commented on pull request #10155:
URL: https://github.com/apache/kafka/pull/10155#issuecomment-781650728
I successfully compiled locally. Compiling with `-PscalaVersion=2.12` failed locally but then succeeded after applying the one-liner fix from https://github.com/apache/kafka/pull/10146.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kafka] rondagostino edited a comment on pull request #10155: Fix Raft broker restart issue when offset partitions are deferred
Posted by GitBox <gi...@apache.org>.
rondagostino edited a comment on pull request #10155:
URL: https://github.com/apache/kafka/pull/10155#issuecomment-781610292
@cmccabe When we defer partition changes we batch everything up and only apply the latest changes at the end. I'm pretty sure you weren't asking about that, but I wanted to make it explicit just to be certain. So there is no chance of becoming a leader for a deferred partition after becoming a follower for it -- we only apply the end state, and that is either leader or follower.
What I think you were asking about is what happens if sometime later we transition to leader. That would be taken care of by the normal partition metadata processing logic. The partition remains "Online" during this entire transition. A partition transitions to Offline only when there is a log dir failure (as an aside, that is not yet implemented for Raft-based clusters). In the absence of a log dir failure a partition can only transition between Online, Deferred, and None (with None signifying we are not a leader or a follower). Deferred only occurs at startup and if the broker becomes fenced after startup (this latter case is also not yet implemented). So we transition only between Online and None, and again the normal partition metadata processing logic handles these. That logic will also handle other transitions to/from Deferred and into Offline once we implement those. So I believe there is no problem here.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kafka] cmccabe commented on pull request #10155: Fix Raft broker restart issue when offset partitions are deferred
Posted by GitBox <gi...@apache.org>.
cmccabe commented on pull request #10155:
URL: https://github.com/apache/kafka/pull/10155#issuecomment-782280589
committed to trunk and 2.8 after running tests locally
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kafka] cmccabe closed pull request #10155: Fix Raft broker restart issue when offset partitions are deferred
Posted by GitBox <gi...@apache.org>.
cmccabe closed pull request #10155:
URL: https://github.com/apache/kafka/pull/10155
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kafka] rondagostino commented on a change in pull request #10155: Fix Raft broker restart issue when offset partitions are deferred
Posted by GitBox <gi...@apache.org>.
rondagostino commented on a change in pull request #10155:
URL: https://github.com/apache/kafka/pull/10155#discussion_r579240227
##########
File path: core/src/main/scala/kafka/server/BrokerServer.scala
##########
@@ -326,14 +326,16 @@ class BrokerServer(
// Start log manager, which will perform (potentially lengthy) recovery-from-unclean-shutdown if required.
logManager.startup(metadataCache.getAllTopics())
// Start other services that we've delayed starting, in the appropriate order.
- replicaManager.endMetadataChangeDeferral(
- RequestHandlerHelper.onLeadershipChange(groupCoordinator, transactionCoordinator, _, _))
replicaManager.startup()
replicaManager.startHighWatermarkCheckPointThread()
groupCoordinator.startup(() => metadataCache.numPartitions(Topic.GROUP_METADATA_TOPIC_NAME).
getOrElse(config.offsetsTopicPartitions))
transactionCoordinator.startup(() => metadataCache.numPartitions(Topic.TRANSACTION_STATE_TOPIC_NAME).
getOrElse(config.transactionTopicPartitions))
+ // Apply deferred changes after starting coordinators to avoid GroupMetadataManager IllegalStateException
+ // due to Kafka scheduler not yet running (this manifests if we have deferred any coordinator offsets partitions).
Review comment:
> comments should explain the intended behavior vs what errors we are trying to avoid
Yeah, makes sense. New comment is as follows:
```
// Apply deferred partition metadata changes after starting replica manager and coordinators
// so that those services are ready and able to process the changes.
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kafka] rondagostino commented on pull request #10155: Fix Raft broker restart issue when offset partitions are deferred
Posted by GitBox <gi...@apache.org>.
rondagostino commented on pull request #10155:
URL: https://github.com/apache/kafka/pull/10155#issuecomment-781694442
Successfully ran `./gradlew build` after commenting out these two flaky tests, **both of which passed locally when run individually afterwards**:
`ConnectionQuotasTest.testListenerConnectionRateLimitWhenActualRateAboveLimit()`
`ConsumerBounceTest.testClose()`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kafka] cmccabe commented on pull request #10155: Fix Raft broker restart issue when offset partitions are deferred
Posted by GitBox <gi...@apache.org>.
cmccabe commented on pull request #10155:
URL: https://github.com/apache/kafka/pull/10155#issuecomment-781606147
> We also mark deferred partitions for which we are a follower as being online a bit earlier to avoid NotLeaderOrFollowerException that was being thrown upon restart
What happens the broker transitions from follower to being a leader for such a partition? Will we remember to mark the partition as offline again?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kafka] ijuma commented on a change in pull request #10155: Fix Raft broker restart issue when offset partitions are deferred
Posted by GitBox <gi...@apache.org>.
ijuma commented on a change in pull request #10155:
URL: https://github.com/apache/kafka/pull/10155#discussion_r579228539
##########
File path: core/src/main/scala/kafka/server/BrokerServer.scala
##########
@@ -326,14 +326,16 @@ class BrokerServer(
// Start log manager, which will perform (potentially lengthy) recovery-from-unclean-shutdown if required.
logManager.startup(metadataCache.getAllTopics())
// Start other services that we've delayed starting, in the appropriate order.
- replicaManager.endMetadataChangeDeferral(
- RequestHandlerHelper.onLeadershipChange(groupCoordinator, transactionCoordinator, _, _))
replicaManager.startup()
replicaManager.startHighWatermarkCheckPointThread()
groupCoordinator.startup(() => metadataCache.numPartitions(Topic.GROUP_METADATA_TOPIC_NAME).
getOrElse(config.offsetsTopicPartitions))
transactionCoordinator.startup(() => metadataCache.numPartitions(Topic.TRANSACTION_STATE_TOPIC_NAME).
getOrElse(config.transactionTopicPartitions))
+ // Apply deferred changes after starting coordinators to avoid GroupMetadataManager IllegalStateException
+ // due to Kafka scheduler not yet running (this manifests if we have deferred any coordinator offsets partitions).
Review comment:
These types of comments should explain the intended behavior vs what errors we are trying to avoid. Does that make sense?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org