Commit e5c29da
committed
main: cap per-group chunk reads per poll cycle (round-robin fairness)
The lagging-first sort (#46) fixed one starvation and created another.
Sorted-but-uncapped iteration let the most-lagging group's chunk loop
run all the way to head before the next group got a read — and when
that group's flushes kept failing (portola OCC conflicts), its position
kept resetting and the loop relitigated the same range indefinitely.
Observed in prod: team-2's cursor frozen at 16967279 for 1.5h across
three pod restarts, applied_inserts=0, while team-50689 monopolized
every poll cycle.
Cap each group at _MAX_CHUNKS_PER_GROUP_PER_CYCLE (4) chunks per poll
cycle. Sorted order still gives the laggiest group the first turn each
cycle; the cap guarantees every other group also gets a turn in the
same cycle. 4 chunks x cdc_chunk_snapshots gives each group a per-cycle
read budget of ~7x the source arrival rate at current prod settings, so
lag still drains while fairness holds.
New test seeds one group 10k snapshots behind and one 100 behind, and
asserts the healthy group reads within the SAME cycle while the lagging
group reads exactly the cap. Verified to fail against the uncapped
loop.1 parent 8160c30 commit e5c29da
2 files changed
Lines changed: 84 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1030 | 1030 | | |
1031 | 1031 | | |
1032 | 1032 | | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
1033 | 1089 | | |
1034 | 1090 | | |
1035 | 1091 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
72 | 81 | | |
73 | 82 | | |
74 | 83 | | |
| |||
806 | 815 | | |
807 | 816 | | |
808 | 817 | | |
809 | | - | |
810 | | - | |
811 | | - | |
812 | | - | |
813 | | - | |
814 | | - | |
815 | | - | |
816 | | - | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
817 | 834 | | |
818 | 835 | | |
819 | 836 | | |
| |||
828 | 845 | | |
829 | 846 | | |
830 | 847 | | |
831 | | - | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
832 | 851 | | |
833 | 852 | | |
834 | 853 | | |
| |||
0 commit comments