Commit d5d0bfd
authored
[receiver/kafka]Protect partition lost/revoke callback against unassigned groups (open-telemetry#40921)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
The `OnPartitionLost` function can be called without the group ever
being assigned
([ref](https://pkg.go.dev/github.com/twmb/franz-go/pkg/kgo#OnPartitionsLost)).
However, the kafka receiver code didn't protect against this. The PR
adds a check to protect against this case. Quoting from the linked docs
for `OnPartitionLost`:
```
OnPartitionsLost sets the function to be called on "fatal" group errors, such as IllegalGeneration, UnknownMemberID, and authentication failures. This function differs from [OnPartitionsRevoked](https://pkg.go.dev/github.com/twmb/franz-go/pkg/kgo#OnPartitionsRevoked) in that it is unlikely that commits will succeed when partitions are outright lost, whereas commits likely will succeed when revoking partitions.
Because this function is called on any fatal group error, it is possible for this function to be called without the group ever being joined.
```
<!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. -->
#### Link to tracking issue
Fixes
open-telemetry#40920
<!--Describe what testing was performed and which tests were added.-->
#### Testing
Since the test is a callback, I can't think of a good way to test it
other than coding the exact scenario which I think would be too brittle.
<!--Describe the documentation added.-->
#### Documentation
Added godoc comments for clarity.
<!--Please delete paragraphs that you did not use before submitting.-->1 parent ea75b50 commit d5d0bfd
File tree
3 files changed
+72
-11
lines changed- .chloggen
- receiver/kafkareceiver
3 files changed
+72
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
378 | 378 | | |
379 | 379 | | |
380 | 380 | | |
381 | | - | |
382 | | - | |
383 | | - | |
384 | | - | |
385 | | - | |
386 | | - | |
387 | | - | |
388 | | - | |
389 | | - | |
390 | | - | |
391 | | - | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
392 | 400 | | |
393 | 401 | | |
394 | 402 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
243 | 243 | | |
244 | 244 | | |
245 | 245 | | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
0 commit comments