forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit92f33bb
committed
Rethink definition of cancel.c's CancelRequested flag.
As it stands, this flag is only set when we've successfully sent acancel request, not if we get SIGINT and then fail to send a cancel.However, for almost all callers, that's the Wrong Thing: we'd preferto abort processing after control-C even if no cancel could be sent.As an example, since commit1d468b9 "pgbench -i" fails to give upsending COPY data even after control-C, if the postmaster has beenstopped, which is clearly not what the code intends and not what anyonewould want. (The fact that it keeps going at all is the fault of aseparate bug in libpq, but not letting CancelRequested become set isclearly not what we want here.)The sole exception, as far as I can find, is that scripts_parallel.c'sParallelSlotsGetIdle tries to consume a query result after issuing acancel, which of course might not terminate quickly if no cancelhappened. But that behavior was poorly thought out too. No user ofParallelSlotsGetIdle tries to continue processing after a cancel,so there is really no point in trying to clear the connection's state.Moreover this has the same defect as for other users of cancel.c,that if the cancel request fails for some reason then we end up withcontrol-C being completely ignored. (On top of that, select_loop failedto distinguish clearly between SIGINT and other reasons for select(2)failing, which means that it's possible that the existing code wouldthink that a cancel has been sent when it hasn't.)Hence, redefine CancelRequested as simply meaning that SIGINT wasreceived. We could add a second flag with the other meaning, butin the absence of any compelling argument why such a flag is needed,I think it would just offer an opportunity for future callers toget it wrong. Also remove the consumeQueryResult call inParallelSlotsGetIdle's failure exit. In passing, simplify theAPI of select_loop.It would now be possible to re-unify psql's cancel_pressed withCancelRequested, partly undoing5d43c3c. But I'm not reallyconvinced that that's worth the trouble, so I left psql alone,other than fixing a misleading comment.This code is new in v13 (cfa4fd3aa), so no need for back-patch.Per investigation of a complaint from Andres Freund.Discussion:https://postgr.es/m/20200603201242.ofvm4jztpqytwfye@alap3.anarazel.de1 parent1fbb6c9 commit92f33bb
File tree
3 files changed
+19
-35
lines changed- src
- bin
- psql
- scripts
- fe_utils
3 files changed
+19
-35
lines changedLines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
240 | 240 |
| |
241 | 241 |
| |
242 | 242 |
| |
243 |
| - | |
| 243 | + | |
244 | 244 |
| |
245 | 245 |
| |
246 | 246 |
| |
|
Lines changed: 9 additions & 23 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
28 | 28 |
| |
29 | 29 |
| |
30 | 30 |
| |
31 |
| - | |
| 31 | + | |
32 | 32 |
| |
33 | 33 |
| |
34 | 34 |
| |
| |||
39 | 39 |
| |
40 | 40 |
| |
41 | 41 |
| |
42 |
| - | |
| 42 | + | |
43 | 43 |
| |
44 |
| - | |
45 |
| - | |
46 |
| - | |
| 44 | + | |
| 45 | + | |
47 | 46 |
| |
48 | 47 |
| |
49 |
| - | |
| 48 | + | |
50 | 49 |
| |
51 | 50 |
| |
52 | 51 |
| |
53 | 52 |
| |
54 | 53 |
| |
55 |
| - | |
56 |
| - | |
57 | 54 |
| |
58 |
| - | |
59 |
| - | |
60 |
| - | |
61 | 55 |
| |
62 | 56 |
| |
63 | 57 |
| |
| |||
90 | 84 |
| |
91 | 85 |
| |
92 | 86 |
| |
93 |
| - | |
| 87 | + | |
94 | 88 |
| |
95 | 89 |
| |
96 | 90 |
| |
| |||
135 | 129 |
| |
136 | 130 |
| |
137 | 131 |
| |
138 |
| - | |
139 | 132 |
| |
140 | 133 |
| |
141 | 134 |
| |
| |||
157 | 150 |
| |
158 | 151 |
| |
159 | 152 |
| |
160 |
| - | |
| 153 | + | |
161 | 154 |
| |
162 | 155 |
| |
163 |
| - | |
164 |
| - | |
165 |
| - | |
166 |
| - | |
167 |
| - | |
168 |
| - | |
169 |
| - | |
| 156 | + | |
| 157 | + | |
170 | 158 |
| |
171 |
| - | |
172 |
| - | |
173 | 159 |
| |
174 | 160 |
| |
175 | 161 |
| |
|
Lines changed: 9 additions & 11 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
43 | 43 |
| |
44 | 44 |
| |
45 | 45 |
| |
46 |
| - | |
47 |
| - | |
48 |
| - | |
49 |
| - | |
50 |
| - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
51 | 51 |
| |
52 | 52 |
| |
53 | 53 |
| |
| |||
148 | 148 |
| |
149 | 149 |
| |
150 | 150 |
| |
| 151 | + | |
| 152 | + | |
151 | 153 |
| |
152 | 154 |
| |
153 | 155 |
| |
| |||
156 | 158 |
| |
157 | 159 |
| |
158 | 160 |
| |
159 |
| - | |
160 | 161 |
| |
161 | 162 |
| |
162 | 163 |
| |
| |||
165 | 166 |
| |
166 | 167 |
| |
167 | 168 |
| |
168 |
| - | |
169 |
| - | |
170 | 169 |
| |
171 | 170 |
| |
172 | 171 |
| |
| |||
193 | 192 |
| |
194 | 193 |
| |
195 | 194 |
| |
| 195 | + | |
| 196 | + | |
196 | 197 |
| |
197 | 198 |
| |
198 | 199 |
| |
| |||
203 | 204 |
| |
204 | 205 |
| |
205 | 206 |
| |
206 |
| - | |
207 | 207 |
| |
208 | 208 |
| |
209 | 209 |
| |
210 | 210 |
| |
211 | 211 |
| |
212 | 212 |
| |
213 | 213 |
| |
214 |
| - | |
215 |
| - | |
216 | 214 |
| |
217 | 215 |
| |
218 | 216 |
| |
|
0 commit comments
Comments
(0)