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/09/30 17:50:42 UTC
[GitHub] [kafka] guozhangwang opened a new pull request #11372: [DO NOT MERGE] MINOR: Do not send data on abortable error too
guozhangwang opened a new pull request #11372:
URL: https://github.com/apache/kafka/pull/11372
We forbid sending produce request before adding partitions in the txn in the following way:
* In `Sender#runOnce`, we would not continue to `sendProducerData` as long as `maybeSendAndPollTransactionalRequest()` returns true.
* Inside `maybeSendAndPollTransactionalRequest` as long as `!newPartitionsInTransaction.isEmpty()` we would enqueue an `AddPartitionsToTxn` request to the queue, so in normal cases `maybeSendAndPollTransactionalRequest` would return `true` which would forbid us to send produce request in that iteration.
* One thing that caught my eyes however, is that inside `transactionManager.nextRequest(accumulator.hasIncomplete())` where we call `maybeTerminateRequestWithError(nextRequestHandler)`, if the state is already `hasAbortableError()` we would fail the request immediately and hence the caller would return `null`, in which case `maybeSendAndPollTransactionalRequest` would return false.
* At the `Sender#runOnce()`, we only check `if (transactionManager.hasFatalError())` and if yes we would not proceed to send produce requests.
So I think there's a possible trace where we would send produce request before sending addPartitionsToTxn requests:
1) First of all, the state of the transaction is already in `abortable error`.
2) In `Sender#runOnce`, we would first pass `transactionManager.hasFatalError()` since we are not in `fatal error`
3) And then in `maybeSendAndPollTransactionalRequest`, although we would generate an `addPartitionsToTxn` request, that request would fail immediately due to the `abortable error` state.
4) And then we would pass `maybeSendAndPollTransactionalRequest` and continue to `sendProducerData` assuming the metadata for the destination brokers are available.
In this case, a producer request could be sent out while the addPartitionsToTxn request is failed.
### 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.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kafka] guozhangwang commented on pull request #11372: [DO NOT MERGE] MINOR: Do not send data on abortable error too
Posted by GitBox <gi...@apache.org>.
guozhangwang commented on pull request #11372:
URL: https://github.com/apache/kafka/pull/11372#issuecomment-938240965
@hachikuji yeah I think you're right that https://github.com/apache/kafka/blob/trunk/clients/src/main/java/org/apache/kafka/clients/producer/internals/RecordAccumulator.java#L508 have this case covered.
--
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.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kafka] guozhangwang commented on pull request #11372: [DO NOT MERGE] MINOR: Do not send data on abortable error too
Posted by GitBox <gi...@apache.org>.
guozhangwang commented on pull request #11372:
URL: https://github.com/apache/kafka/pull/11372#issuecomment-931541497
cc @hachikuji @dajac WDYT.
--
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.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kafka] guozhangwang commented on pull request #11372: [DO NOT MERGE] MINOR: Do not send data on abortable error too
Posted by GitBox <gi...@apache.org>.
guozhangwang commented on pull request #11372:
URL: https://github.com/apache/kafka/pull/11372#issuecomment-931536992
If this is indeed an issue, then I think the simple fix should be changing the `hasFatalError` to `hasError`.
--
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.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kafka] hachikuji commented on pull request #11372: [DO NOT MERGE] MINOR: Do not send data on abortable error too
Posted by GitBox <gi...@apache.org>.
hachikuji commented on pull request #11372:
URL: https://github.com/apache/kafka/pull/11372#issuecomment-934656281
@guozhangwang I've been trying to write a test case for this scenario, but so far I've been unsuccessful. I think in order to hit this case, we have to send to a new partition after already being in the abortable error state. But this fails because of the following check: https://github.com/apache/kafka/blob/trunk/clients/src/main/java/org/apache/kafka/clients/producer/internals/Sender.java#L422. After we have hit the abortable state, we fail new appends categorically without sending them. I tried to think of other related scenarios, but I couldn't create a problem. The code is complex enough though that it's tough to feel confident that all cases have been covered.
Another thing is that we seem to already have some protection in `RecordAccumulator` even if we slip past the call to `maybeSendAndPollTransactionalRequest` and hit `sendProducerData`: https://github.com/apache/kafka/blob/trunk/clients/src/main/java/org/apache/kafka/clients/producer/internals/RecordAccumulator.java#L508.
--
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.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org