Commit 127aae1
committed
fix(load): a failed status check must not discard a running job
Review found a regression this PR introduced, reachable from the opposite
direction to the one it fixes.
`_poll_job` aborted on the first bad `GET /v1/jobs/{id}`. That exception reaches
`ManagedDatabaseClient._request_with_retry`, which classifies a 502/503 as
transient and re-invokes THE WHOLE OPERATION for every non-append mode -- so a
single blipped status check discards a healthy running job and submits a second
load against a table whose write lock the first one still holds. 409
RESOURCE_LOCKED, which is also transient, and round it goes.
Worse than the behaviour it replaces, not better: before, a lost request took with
it a load that was genuinely being torn down. Now the first job is neither going
away nor releasing anything, and a load polls for up to `_LOAD_JOB_TIMEOUT_S`, so
there are hundreds of status checks where there used to be one request -- every
one a fresh chance to trigger the collision. Exposure up, collision from
incidental to certain.
So the poll tolerates a failed status check and keeps waiting, bounded by
consecutive failures rather than by the first one. An isolated 502 is noise; a run
of them means the API is gone and there is nothing to wait for. The poll's own
deadline bounds the total wait either way.
THE JOB ID IS NOW RETURNED. The docstring claimed the id removed `append`'s "did
it land?" ambiguity, which was not true as implemented: it was a local, discarded
on every failure path, and never reached the caller. `LoadManagedTableResult`
carries it now, for the same reason `CreateIndexResult` does. `append` stays
non-retryable -- knowing the id makes the question answerable, it does not make a
blind re-submission safe, and that call belongs to the caller. The docstring says
that instead of the stronger thing.
`result` is read with `getattr(..., "actual_instance", ...)`, matching the index
path rather than silently disagreeing with it: the strict read raised a bare
AttributeError if the model ever arrived unwrapped.
Did NOT add a strict isinstance check on the inline response. The index path can
assert its inline type because it names it positively first; here the inline shape
is read duck-typed and callers and tests rely on that, so asserting it narrows an
interface this change has no business narrowing. Only the job branch is
type-checked.
Import order fixed for ruff's I rule; `ruff check` clean.
149 passed.1 parent 115efd6 commit 127aae1
3 files changed
Lines changed: 130 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
28 | 27 | | |
| 28 | + | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
98 | 101 | | |
99 | 102 | | |
100 | 103 | | |
| |||
461 | 464 | | |
462 | 465 | | |
463 | 466 | | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
464 | 472 | | |
465 | | - | |
| 473 | + | |
| 474 | + | |
466 | 475 | | |
467 | 476 | | |
468 | 477 | | |
469 | 478 | | |
470 | 479 | | |
471 | 480 | | |
| 481 | + | |
472 | 482 | | |
473 | 483 | | |
474 | 484 | | |
| |||
911 | 921 | | |
912 | 922 | | |
913 | 923 | | |
| 924 | + | |
914 | 925 | | |
915 | 926 | | |
916 | 927 | | |
| 928 | + | |
917 | 929 | | |
918 | | - | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
919 | 945 | | |
920 | 946 | | |
921 | 947 | | |
| |||
929 | 955 | | |
930 | 956 | | |
931 | 957 | | |
932 | | - | |
933 | | - | |
934 | | - | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
935 | 963 | | |
936 | 964 | | |
937 | 965 | | |
| |||
943 | 971 | | |
944 | 972 | | |
945 | 973 | | |
946 | | - | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
947 | 977 | | |
948 | 978 | | |
949 | 979 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
86 | 91 | | |
87 | 92 | | |
88 | 93 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
714 | 714 | | |
715 | 715 | | |
716 | 716 | | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 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 | + | |
0 commit comments