Commit cbf64e1
authored
When prepared statements are disabled, avoid relying on them harder (#1065)
It appears that PgBouncer's `transaction` pooling mode does not consider
implicit transactions properly, and so in a [`Parse`, `Flush`, `Bind`,
`Execute`, `Sync`] sequence, `Flush` would be (incorrectly) considered by
PgBouncer as a transaction boundary and it will happily send the
following `Bind` / `Execute` messages to a different backend process.
This makes it so that when `statement_cache_size` is set to `0`, asyncpg
assumes a pessimistic stance on prepared statement persistence and does
not rely on them even in implicit transactions. The above message
sequence thus becomes `Parse`, `Flush`, `Parse` (a second time), `Bind`,
`Execute`, `Sync`.
This obviously has negative performance impact due to the extraneous
`Parse`.
Fixes: #1058
Fixes: #10411 parent 87ab143 commit cbf64e1Copy full SHA for cbf64e1
File tree
Expand file treeCollapse file tree
6 files changed
+81
-25
lines changedOpen diff view settings
Filter options
- asyncpg
- protocol
Expand file treeCollapse file tree
6 files changed
+81
-25
lines changedOpen diff view settings
Collapse file
+31-15Lines changed: 31 additions & 15 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
47 | 47 | |
48 | 48 | |
49 | 49 | |
| 50 | + |
50 | 51 | |
51 | 52 | |
52 | 53 | |
| ||
79 | 80 | |
80 | 81 | |
81 | 82 | |
| 83 | + |
82 | 84 | |
83 | 85 | |
84 | 86 | |
| ||
381 | 383 | |
382 | 384 | |
383 | 385 | |
384 | | - |
385 | | - |
386 | | - |
387 | | - |
388 | | - |
| 386 | + |
| 387 | + |
| 388 | + |
| 389 | + |
| 390 | + |
| 391 | + |
| 392 | + |
389 | 393 | |
390 | 394 | |
391 | 395 | |
| ||
434 | 438 | |
435 | 439 | |
436 | 440 | |
437 | | - |
438 | | - |
439 | | - |
440 | | - |
441 | | - |
442 | | - |
443 | | - |
444 | | - |
| 441 | + |
| 442 | + |
| 443 | + |
| 444 | + |
| 445 | + |
| 446 | + |
| 447 | + |
| 448 | + |
| 449 | + |
| 450 | + |
445 | 451 | |
446 | 452 | |
447 | 453 | |
| ||
1679 | 1685 | |
1680 | 1686 | |
1681 | 1687 | |
1682 | | - |
| 1688 | + |
| 1689 | + |
| 1690 | + |
| 1691 | + |
| 1692 | + |
| 1693 | + |
| 1694 | + |
1683 | 1695 | |
1684 | 1696 | |
1685 | 1697 | |
| ||
1691 | 1703 | |
1692 | 1704 | |
1693 | 1705 | |
1694 | | - |
| 1706 | + |
| 1707 | + |
| 1708 | + |
| 1709 | + |
| 1710 | + |
1695 | 1711 | |
1696 | 1712 | |
1697 | 1713 | |
|
Collapse file
asyncpg/protocol/coreproto.pxd
Copy file name to clipboardExpand all lines: asyncpg/protocol/coreproto.pxd+2-1Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
167 | 167 | |
168 | 168 | |
169 | 169 | |
170 | | - |
| 170 | + |
| 171 | + |
171 | 172 | |
172 | 173 | |
173 | 174 | |
|
Collapse file
asyncpg/protocol/coreproto.pyx
Copy file name to clipboardExpand all lines: asyncpg/protocol/coreproto.pyx+17-1Lines changed: 17 additions & 1 deletion
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
237 | 237 | |
238 | 238 | |
239 | 239 | |
| 240 | + |
| 241 | + |
| 242 | + |
| 243 | + |
240 | 244 | |
241 | 245 | |
242 | 246 | |
| ||
269 | 273 | |
270 | 274 | |
271 | 275 | |
| 276 | + |
| 277 | + |
| 278 | + |
| 279 | + |
272 | 280 | |
273 | 281 | |
274 | 282 | |
| ||
874 | 882 | |
875 | 883 | |
876 | 884 | |
877 | | - |
| 885 | + |
| 886 | + |
| 887 | + |
| 888 | + |
| 889 | + |
| 890 | + |
| 891 | + |
| 892 | + |
| 893 | + |
878 | 894 | |
879 | 895 | |
880 | 896 | |
|
Collapse file
asyncpg/protocol/prepared_stmt.pxd
Copy file name to clipboardExpand all lines: asyncpg/protocol/prepared_stmt.pxd+1Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
10 | 10 | |
11 | 11 | |
12 | 12 | |
| 13 | + |
13 | 14 | |
14 | 15 | |
15 | 16 | |
|
Collapse file
asyncpg/protocol/prepared_stmt.pyx
Copy file name to clipboardExpand all lines: asyncpg/protocol/prepared_stmt.pyx+7Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
27 | 27 | |
28 | 28 | |
29 | 29 | |
| 30 | + |
30 | 31 | |
31 | 32 | |
32 | 33 | |
| ||
101 | 102 | |
102 | 103 | |
103 | 104 | |
| 105 | + |
| 106 | + |
| 107 | + |
| 108 | + |
| 109 | + |
| 110 | + |
104 | 111 | |
105 | 112 | |
106 | 113 | |
|
Collapse file
asyncpg/protocol/protocol.pyx
Copy file name to clipboardExpand all lines: asyncpg/protocol/protocol.pyx+23-8Lines changed: 23 additions & 8 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
155 | 155 | |
156 | 156 | |
157 | 157 | |
158 | | - |
| 158 | + |
159 | 159 | |
160 | 160 | |
161 | 161 | |
| ||
168 | 168 | |
169 | 169 | |
170 | 170 | |
171 | | - |
172 | | - |
173 | | - |
174 | | - |
| 171 | + |
| 172 | + |
| 173 | + |
| 174 | + |
| 175 | + |
| 176 | + |
| 177 | + |
| 178 | + |
| 179 | + |
175 | 180 | |
176 | 181 | |
177 | 182 | |
| ||
184 | 189 | |
185 | 190 | |
186 | 191 | |
| 192 | + |
| 193 | + |
| 194 | + |
187 | 195 | |
188 | 196 | |
189 | 197 | |
| ||
201 | 209 | |
202 | 210 | |
203 | 211 | |
204 | | - |
205 | | - |
206 | | - |
| 212 | + |
| 213 | + |
| 214 | + |
| 215 | + |
| 216 | + |
| 217 | + |
| 218 | + |
207 | 219 | |
208 | 220 | |
209 | 221 | |
| ||
222 | 234 | |
223 | 235 | |
224 | 236 | |
| 237 | + |
| 238 | + |
| 239 | + |
225 | 240 | |
226 | 241 | |
227 | 242 | |
|
0 commit comments