Commit 9318075
retry: only wrap bodies when a request can be retried (#1039)
Currently, the decision of whether or not a request can be retried is
made in the `clone_request` implementation for the `Retry` type in
`linkerd_app_core`. This is problematic, because by the time
`clone_request` is called, the request body has _already_ been wrapped
in a `ReplayBody`. The `ReplayBody` will buffer _regardless_ of whether
or not it's cloned. This means that the maximum length to buffer doesn't
_actually_ stop us from buffering --- it just determines whether we will
actually attempt to retry on failure, and whether we will retain that
buffer past when the request ends. The request will still buffer all
body data, but it will be dropped when the single instance of the body
is dropped. This means that for very long streaming bodies, we may
buffer increasingly large amounts of data as long as that request is in
flight.
This branch fixes this by moving the determination of whether a request
is retryable to *before* we wrap it in a `ReplayBody`, so that requests
over the maximum buffered length are not buffered. We do this by
introducing a new trait that serves as a predicate for whether or not a
request is retryable, and checking that predicate before wrapping the
body _or_ calling `clone_request`.
Co-authored-by: Oliver Gould <[email protected]>1 parent f4a2a6b commit 9318075
2 files changed
+47
-63
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | 7 | | |
9 | 8 | | |
10 | | - | |
11 | 9 | | |
12 | 10 | | |
13 | 11 | | |
| |||
17 | 15 | | |
18 | 16 | | |
19 | 17 | | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | 18 | | |
25 | | - | |
| 19 | + | |
26 | 20 | | |
27 | | - | |
28 | 21 | | |
29 | 22 | | |
30 | | - | |
| 23 | + | |
| 24 | + | |
31 | 25 | | |
32 | 26 | | |
33 | 27 | | |
34 | | - | |
35 | 28 | | |
36 | 29 | | |
37 | | - | |
38 | | - | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
39 | 34 | | |
40 | 35 | | |
41 | 36 | | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
| 37 | + | |
53 | 38 | | |
54 | 39 | | |
55 | 40 | | |
56 | | - | |
57 | | - | |
| 41 | + | |
| 42 | + | |
58 | 43 | | |
59 | 44 | | |
60 | 45 | | |
| |||
64 | 49 | | |
65 | 50 | | |
66 | 51 | | |
67 | | - | |
68 | 52 | | |
69 | 53 | | |
70 | 54 | | |
71 | 55 | | |
72 | | - | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
73 | 59 | | |
74 | | - | |
| 60 | + | |
75 | 61 | | |
76 | 62 | | |
77 | 63 | | |
| |||
104 | 90 | | |
105 | 91 | | |
106 | 92 | | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
118 | 100 | | |
119 | | - | |
120 | | - | |
121 | 101 | | |
122 | | - | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
123 | 107 | | |
124 | | - | |
125 | | - | |
126 | | - | |
| 108 | + | |
| 109 | + | |
127 | 110 | | |
128 | 111 | | |
129 | | - | |
130 | | - | |
| 112 | + | |
| 113 | + | |
131 | 114 | | |
132 | 115 | | |
133 | 116 | | |
| |||
139 | 122 | | |
140 | 123 | | |
141 | 124 | | |
142 | | - | |
| 125 | + | |
143 | 126 | | |
144 | 127 | | |
145 | 128 | | |
146 | 129 | | |
147 | 130 | | |
148 | | - | |
| 131 | + | |
149 | 132 | | |
150 | 133 | | |
151 | 134 | | |
152 | 135 | | |
153 | 136 | | |
154 | 137 | | |
155 | 138 | | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
| 139 | + | |
164 | 140 | | |
165 | 141 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
46 | 52 | | |
47 | 53 | | |
48 | 54 | | |
| |||
108 | 114 | | |
109 | 115 | | |
110 | 116 | | |
111 | | - | |
| 117 | + | |
112 | 118 | | |
113 | 119 | | |
114 | 120 | | |
| |||
125 | 131 | | |
126 | 132 | | |
127 | 133 | | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
133 | 141 | | |
134 | 142 | | |
135 | 143 | | |
| |||
0 commit comments