Commit 917d695
authored
KAFKA-17019 Producer TimeoutException should include root cause (#20159)
### Changes
- Add new Exception class `PotentialCauseException`.
- All `org.apache.kafka.common.errors.TimeoutException` in
`KafkaProducer` has `PotentialCauseException` as root cause if it
cannot catch any exception.
### Describe
`TimeoutException` can be thrown for various reasons.
However, it is often difficult to identify the root cause,
Because there are so many potential factors that can lead to a
`TimeoutException`.
For example:
1. The `ProducerClient` might be busy, so it may not be able to send the
request in time. As a result, some batches may expire, leading to a
`TimeoutException`.
2. The `broker` might be unavailable due to network issues or internal
failures.
3. A request may be in flight, and although the broker successfully
handles and responds to it, the response might arrive slightly late.
As shown above, there are many possible causes. In some cases, no
`exception` is caught in the `catch` block, and a `TimeoutException` is
thrown simply by comparing the `elapsed time`. However, the developer
using `TimeoutException` in `KafkaProducer` likely already knows which
specific reasons could cause it in that context. Therefore, I think it
would be helpful to include a `PotentialCauseException` that reflects
the likely reason, based on the developer’s knowledge.
Reviewers: TengYao Chi <kitingiao@gmail.com>, Yung
<yungyung7654321@gmail.com>, Andrew Schofield
<aschofield@confluent.io>, Chia-Ping Tsai <chia7712@gmail.com>1 parent fd5d923 commit 917d695
File tree
8 files changed
+123
-64
lines changed- clients/src
- main/java/org/apache/kafka/clients/producer
- internals
- test/java/org/apache/kafka
- clients/producer
- internals
- test
8 files changed
+123
-64
lines changedLines changed: 16 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
248 | 248 | | |
249 | 249 | | |
250 | 250 | | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
251 | 263 | | |
252 | 264 | | |
253 | 265 | | |
| |||
672 | 684 | | |
673 | 685 | | |
674 | 686 | | |
675 | | - | |
| 687 | + | |
676 | 688 | | |
677 | 689 | | |
678 | 690 | | |
| |||
761 | 773 | | |
762 | 774 | | |
763 | 775 | | |
764 | | - | |
| 776 | + | |
765 | 777 | | |
766 | 778 | | |
767 | 779 | | |
| |||
847 | 859 | | |
848 | 860 | | |
849 | 861 | | |
850 | | - | |
| 862 | + | |
851 | 863 | | |
852 | 864 | | |
853 | 865 | | |
| |||
882 | 894 | | |
883 | 895 | | |
884 | 896 | | |
885 | | - | |
| 897 | + | |
886 | 898 | | |
887 | 899 | | |
888 | 900 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
424 | 424 | | |
425 | 425 | | |
426 | 426 | | |
427 | | - | |
| 427 | + | |
428 | 428 | | |
429 | 429 | | |
430 | 430 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
414 | 414 | | |
415 | 415 | | |
416 | 416 | | |
417 | | - | |
| 417 | + | |
| 418 | + | |
418 | 419 | | |
419 | 420 | | |
420 | 421 | | |
| |||
Lines changed: 2 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
| 50 | + | |
55 | 51 | | |
56 | 52 | | |
57 | 53 | | |
58 | 54 | | |
59 | | - | |
| 55 | + | |
60 | 56 | | |
61 | 57 | | |
62 | 58 | | |
| |||
Lines changed: 11 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
174 | 174 | | |
175 | 175 | | |
176 | 176 | | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
177 | 183 | | |
178 | 184 | | |
179 | 185 | | |
| |||
1322 | 1328 | | |
1323 | 1329 | | |
1324 | 1330 | | |
1325 | | - | |
| 1331 | + | |
1326 | 1332 | | |
1327 | 1333 | | |
1328 | 1334 | | |
| |||
1352 | 1358 | | |
1353 | 1359 | | |
1354 | 1360 | | |
1355 | | - | |
| 1361 | + | |
| 1362 | + | |
1356 | 1363 | | |
1357 | 1364 | | |
1358 | 1365 | | |
| |||
2364 | 2371 | | |
2365 | 2372 | | |
2366 | 2373 | | |
2367 | | - | |
| 2374 | + | |
| 2375 | + | |
2368 | 2376 | | |
2369 | 2377 | | |
2370 | 2378 | | |
| |||
Lines changed: 12 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
163 | 163 | | |
164 | 164 | | |
165 | 165 | | |
| 166 | + | |
166 | 167 | | |
167 | 168 | | |
168 | 169 | | |
| |||
425 | 426 | | |
426 | 427 | | |
427 | 428 | | |
| 429 | + | |
428 | 430 | | |
429 | 431 | | |
430 | 432 | | |
| |||
2792 | 2794 | | |
2793 | 2795 | | |
2794 | 2796 | | |
2795 | | - | |
| 2797 | + | |
2796 | 2798 | | |
2797 | 2799 | | |
2798 | 2800 | | |
| |||
2942 | 2944 | | |
2943 | 2945 | | |
2944 | 2946 | | |
2945 | | - | |
2946 | | - | |
| 2947 | + | |
| 2948 | + | |
| 2949 | + | |
2947 | 2950 | | |
2948 | 2951 | | |
2949 | 2952 | | |
| |||
3154 | 3157 | | |
3155 | 3158 | | |
3156 | 3159 | | |
3157 | | - | |
| 3160 | + | |
3158 | 3161 | | |
3159 | 3162 | | |
3160 | 3163 | | |
| |||
3193 | 3196 | | |
3194 | 3197 | | |
3195 | 3198 | | |
3196 | | - | |
| 3199 | + | |
3197 | 3200 | | |
3198 | 3201 | | |
3199 | 3202 | | |
| |||
3232 | 3235 | | |
3233 | 3236 | | |
3234 | 3237 | | |
3235 | | - | |
| 3238 | + | |
3236 | 3239 | | |
3237 | 3240 | | |
3238 | 3241 | | |
| |||
3264 | 3267 | | |
3265 | 3268 | | |
3266 | 3269 | | |
3267 | | - | |
| 3270 | + | |
3268 | 3271 | | |
3269 | 3272 | | |
3270 | 3273 | | |
| |||
3281 | 3284 | | |
3282 | 3285 | | |
3283 | 3286 | | |
3284 | | - | |
| 3287 | + | |
3285 | 3288 | | |
3286 | 3289 | | |
3287 | 3290 | | |
| |||
3884 | 3887 | | |
3885 | 3888 | | |
3886 | 3889 | | |
3887 | | - | |
| 3890 | + | |
3888 | 3891 | | |
3889 | 3892 | | |
3890 | 3893 | | |
| |||
0 commit comments