|
1 | | -\# Notes on ProduceResponse → ProducerBatch matching |
| 1 | +# Notes on ProduceResponse → ProducerBatch matching |
2 | 2 |
|
| 3 | +While reading `Sender.handleProduceResponse`, I wanted to write down a few questions |
| 4 | +before making any code changes. |
3 | 5 |
|
| 6 | +The response-to-batch lookup currently relies on: |
| 7 | +- topicId when present (newer protocol versions) |
| 8 | +- falling back to topic name + partition otherwise |
| 9 | +- a snapshot of topicId → name mapping taken before send |
4 | 10 |
|
5 | | -While reading `Sender.handleProduceResponse`, I wanted to document and sanity-check |
6 | | - |
7 | | -one aspect of the response-to-batch matching logic. |
8 | | - |
9 | | - |
10 | | - |
11 | | -Currently, matching relies on: |
12 | | - |
13 | | -\- topicId when present (protocol v13+), but only if it can be resolved via a |
14 | | - |
15 | | - topic-name snapshot captured before the request is sent |
16 | | - |
17 | | -\- otherwise falling back to topic name + partition |
18 | | - |
19 | | - |
20 | | - |
21 | | -Since metadata can change while a produce request is in flight |
22 | | - |
23 | | -(e.g. topic recreation, leader changes, protocol differences), |
24 | | - |
25 | | -I wanted to understand the guarantees around this mapping. |
26 | | - |
27 | | - |
| 11 | +Given that metadata can change while a produce request is in flight (topic recreation, |
| 12 | +leader changes, protocol differences), I wanted to confirm the guarantees here. |
28 | 13 |
|
29 | 14 | In particular: |
| 15 | +- Are we assuming that a response with a non-zero topicId can always be resolved |
| 16 | + using the topic-name snapshot taken before sending? |
| 17 | +- In what cases (if any) can `batch == null` occur, and is that considered an |
| 18 | + impossible state or a deliberate hard failure? |
30 | 19 |
|
31 | | -\- Are we assuming that a non-zero topicId in the response will always be |
32 | | - |
33 | | - resolvable using the pre-send topic name snapshot? |
34 | | - |
35 | | -\- In what scenarios (if any) can `batch == null` occur here, and is that treated |
36 | | - |
37 | | - as an impossible state or a deliberate hard failure to preserve correctness? |
38 | | - |
39 | | - |
40 | | - |
41 | | -No behavior change proposed yet , this note exists to clarify assumptions |
42 | | - |
43 | | -before exploring tests or hardening changes. |
44 | | - |
45 | | - |
46 | | - |
| 20 | +This is just a note for now — no behavior change proposed yet. |
0 commit comments