Commit 7cd5ea6
authored
kgo: fix mark <=> epoch interaction, make epoch handling more resilient (#1203)
MarkCommit{Records,Offsets} compared the epoch/offset you were marking
against the existing head epoch/offset. If the there was no internally
existing epoch/offset, or only `dirty` was set (via being consumed)
while `head` / `committed` were both the default struct value {0,0},
then trying to mark a record with a negative epoch would be ignored.
Note that returning -1 via the broker epoch requires a broker to both
(a) SUPPORT epochs, i.e. implement all the Kafka APIs with leader epoch
support, and then (b) NOT SUPPORT epochs, i.e. return / use -1
everywhere. This has only been seen against Azure Event hubs.
Anyway, now, when initializing an EpochOffset internally (for an
uncommit {dirty,head,committed}, the epoch is explicitly initialized
with -1. Further, for added robustness, MarkCommit{Records,Offsets}
only compares against existing values -- if a value does not exist,
we auto-accept the mark.
This commit also:
* Improves EpochOffset.Less to assume all negative epochs are -1
* Simplifies the logic in CommitRecords to use EpochOffset.Less
* Adds debug lines in metadata when new partitions are added
* Adds the epoch to an existing debug log line when updating uncommitted
* Sets the LeaderEpoch to -1 for records when producing, and clarifies
in docs that -1 should have always been the case.1 parent 8906743 commit 7cd5ea6
File tree
4 files changed
+38
-15
lines changed- pkg/kgo
4 files changed
+38
-15
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1878 | 1878 | | |
1879 | 1879 | | |
1880 | 1880 | | |
1881 | | - | |
| 1881 | + | |
| 1882 | + | |
1882 | 1883 | | |
1883 | 1884 | | |
1884 | 1885 | | |
| |||
1925 | 1926 | | |
1926 | 1927 | | |
1927 | 1928 | | |
1928 | | - | |
| 1929 | + | |
| 1930 | + | |
| 1931 | + | |
| 1932 | + | |
| 1933 | + | |
| 1934 | + | |
1929 | 1935 | | |
1930 | 1936 | | |
1931 | 1937 | | |
1932 | | - | |
| 1938 | + | |
1933 | 1939 | | |
1934 | | - | |
| 1940 | + | |
1935 | 1941 | | |
1936 | 1942 | | |
1937 | 1943 | | |
| |||
2400 | 2406 | | |
2401 | 2407 | | |
2402 | 2408 | | |
| 2409 | + | |
| 2410 | + | |
| 2411 | + | |
| 2412 | + | |
| 2413 | + | |
2403 | 2414 | | |
2404 | | - | |
| 2415 | + | |
2405 | 2416 | | |
2406 | 2417 | | |
2407 | 2418 | | |
2408 | | - | |
2409 | | - | |
2410 | | - | |
2411 | | - | |
| 2419 | + | |
| 2420 | + | |
2412 | 2421 | | |
2413 | 2422 | | |
2414 | 2423 | | |
| |||
2469 | 2478 | | |
2470 | 2479 | | |
2471 | 2480 | | |
2472 | | - | |
| 2481 | + | |
2473 | 2482 | | |
2474 | 2483 | | |
2475 | 2484 | | |
2476 | | - | |
| 2485 | + | |
2477 | 2486 | | |
2478 | 2487 | | |
2479 | 2488 | | |
| |||
2509 | 2518 | | |
2510 | 2519 | | |
2511 | 2520 | | |
2512 | | - | |
2513 | | - | |
| 2521 | + | |
| 2522 | + | |
2514 | 2523 | | |
2515 | 2524 | | |
2516 | 2525 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
926 | 926 | | |
927 | 927 | | |
928 | 928 | | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
929 | 935 | | |
930 | 936 | | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
931 | 943 | | |
932 | 944 | | |
933 | 945 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
624 | 624 | | |
625 | 625 | | |
626 | 626 | | |
627 | | - | |
| 627 | + | |
628 | 628 | | |
629 | 629 | | |
630 | 630 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
133 | | - | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
134 | 136 | | |
135 | 137 | | |
136 | 138 | | |
| |||
0 commit comments