Commit f3dca49
committed
fix(load): measure poll-error tolerance in time, and name the job when giving up
Two review points, both on paths where the caller is left not knowing whether the
load landed.
TOLERANCE WAS A COUNT, WHICH MEANS NOTHING ON ITS OWN. Five consecutive failures
at the load's 2s interval is about eight seconds, and the thing being survived is a
gateway blip: a rolling restart or a load balancer reconverging serves 502s for
longer than that. Past it the poll aborted, the caller's retry re-submitted the
load, and the first job was still holding the table -- the door this tolerance
exists to close, just narrower than before.
A count is also the wrong unit, because what it means in wall-clock depends on
whichever `interval_s` the caller passed, and callers differ. Now a time bound:
give up after 120s of CONTINUOUS failure, reset on any success, still bounded by
the poll's own deadline. Failed checks also back off to 15s rather than retrying
every 2s -- whatever is serving 502s does not need the extra traffic.
THE GIVE-UP PATHS DROPPED THE JOB ID. `api_error_message(e)` is the gateway's
message ("502: Bad Gateway"), and the failed-job raise preferred the server's
message, which need not mention the id. Those are exactly the two paths where the
answer is unknown and the id is the only handle for asking. Both name the job now,
matching what `_poll_job`'s own TimeoutError already did.
The test for the tolerance drives a FAKE CLOCK advanced by the sleeps. With
`sleep` patched to a no-op and a real clock, it waited out the whole grace period
in wall time -- 120 seconds of a spinning loop to assert one message, and it
slowed the suite from 0.5s to 121s before I noticed. A test measuring a time bound
has to own the clock.
152 passed in 0.53s. `ruff check` clean on the touched files.1 parent 127aae1 commit f3dca49
2 files changed
Lines changed: 121 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
98 | | - | |
99 | | - | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
100 | 115 | | |
101 | 116 | | |
102 | 117 | | |
| |||
921 | 936 | | |
922 | 937 | | |
923 | 938 | | |
924 | | - | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
925 | 942 | | |
926 | 943 | | |
927 | 944 | | |
928 | | - | |
| 945 | + | |
| 946 | + | |
929 | 947 | | |
930 | 948 | | |
931 | 949 | | |
| |||
937 | 955 | | |
938 | 956 | | |
939 | 957 | | |
940 | | - | |
941 | | - | |
942 | | - | |
943 | | - | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
944 | 972 | | |
945 | 973 | | |
946 | 974 | | |
| |||
968 | 996 | | |
969 | 997 | | |
970 | 998 | | |
971 | | - | |
972 | | - | |
973 | | - | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
974 | 1004 | | |
975 | 1005 | | |
976 | 1006 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
640 | 640 | | |
641 | 641 | | |
642 | 642 | | |
| 643 | + | |
643 | 644 | | |
644 | 645 | | |
645 | 646 | | |
| |||
744 | 745 | | |
745 | 746 | | |
746 | 747 | | |
747 | | - | |
748 | | - | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
749 | 752 | | |
750 | | - | |
| 753 | + | |
| 754 | + | |
751 | 755 | | |
752 | 756 | | |
753 | 757 | | |
754 | 758 | | |
755 | 759 | | |
756 | 760 | | |
757 | 761 | | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
758 | 767 | | |
759 | 768 | | |
760 | | - | |
| 769 | + | |
| 770 | + | |
761 | 771 | | |
762 | 772 | | |
763 | | - | |
764 | | - | |
765 | | - | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
766 | 776 | | |
767 | 777 | | |
768 | | - | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
769 | 841 | | |
770 | 842 | | |
771 | 843 | | |
| |||
0 commit comments