- Notifications
You must be signed in to change notification settings - Fork5
Commit52f5d57
committed
Create a function to reliably identify which sessions block which others.
This patch introduces "pg_blocking_pids(int) returns int[]", which returnsthe PIDs of any sessions that are blocking the session with the given PID.Historically people have obtained such information using a self-join onthe pg_locks view, but it's unreasonably tedious to do it that way with anymodicum of correctness, and the addition of parallel queries has prettymuch broken that approach altogether. (Given some more columns in the viewthan there are today, you could imagine handling parallel-query cases witha 4-way join; but ugh.)The new function has the following behaviors that are painful or impossibleto get right via pg_locks:1. Correctly understands which lock modes block which other ones.2. In soft-block situations (two processes both waiting for conflicting lockmodes), only the one that's in front in the wait queue is reported toblock the other.3. In parallel-query cases, reports all sessions blocking any member ofthe given PID's lock group, and reports a session by naming its leaderprocess's PID, which will be the pg_backend_pid() value visible toclients.The motivation for doing this right now is mostly to fix the isolationtests. Commit38f8bdc lobotomizedisolationtester's is-it-waiting query by removing its ability to recognizenonconflicting lock modes, as a crude workaround for the inability tohandle soft-block situations properly. But even without the lock modetests, the old query was excessively slow, particularly inCLOBBER_CACHE_ALWAYS builds; some of our buildfarm animals fail the newdeadlock-hard test because the deadlock timeout elapses before they canprobe the waiting status of all eight sessions. Replacing the pg_locksself-join with use of pg_blocking_pids() is not only much more correct, buta lot faster: I measure it at about 9X faster in a typical dev build withAsserts, and 3X faster in CLOBBER_CACHE_ALWAYS builds. That should provideenough headroom for the slower CLOBBER_CACHE_ALWAYS animals to pass thetest, without having to lengthen deadlock_timeout yet more and thus slowdown the test for everyone else.1 parent73bf871 commit52f5d57
File tree
11 files changed
+470
-54
lines changed- doc/src/sgml
- src
- backend
- storage
- ipc
- lmgr
- utils/adt
- include
- catalog
- storage
- utils
- test/isolation
11 files changed
+470
-54
lines changedLines changed: 35 additions & 21 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
7376 | 7376 |
| |
7377 | 7377 |
| |
7378 | 7378 |
| |
7379 |
| - | |
| 7379 | + | |
7380 | 7380 |
| |
7381 | 7381 |
| |
7382 | 7382 |
| |
| |||
8015 | 8015 |
| |
8016 | 8016 |
| |
8017 | 8017 |
| |
8018 |
| - | |
| 8018 | + | |
8019 | 8019 |
| |
8020 | 8020 |
| |
8021 | 8021 |
| |
8022 | 8022 |
| |
8023 | 8023 |
| |
8024 | 8024 |
| |
8025 |
| - | |
| 8025 | + | |
8026 | 8026 |
| |
8027 |
| - | |
| 8027 | + | |
8028 | 8028 |
| |
8029 | 8029 |
| |
8030 | 8030 |
| |
| |||
8200 | 8200 |
| |
8201 | 8201 |
| |
8202 | 8202 |
| |
8203 |
| - | |
8204 |
| - | |
8205 |
| - | |
8206 |
| - | |
8207 |
| - | |
8208 |
| - | |
| 8203 | + | |
| 8204 | + | |
| 8205 | + | |
| 8206 | + | |
| 8207 | + | |
| 8208 | + | |
8209 | 8209 |
| |
8210 | 8210 |
| |
8211 | 8211 |
| |
8212 |
| - | |
8213 |
| - | |
8214 |
| - | |
8215 |
| - | |
8216 |
| - | |
8217 |
| - | |
8218 |
| - | |
8219 |
| - | |
8220 |
| - | |
| 8212 | + | |
| 8213 | + | |
| 8214 | + | |
| 8215 | + | |
| 8216 | + | |
| 8217 | + | |
| 8218 | + | |
| 8219 | + | |
| 8220 | + | |
8221 | 8221 |
| |
8222 | 8222 |
| |
8223 | 8223 |
| |
8224 | 8224 |
| |
8225 | 8225 |
| |
8226 | 8226 |
| |
8227 |
| - | |
| 8227 | + | |
8228 | 8228 |
| |
8229 | 8229 |
| |
8230 | 8230 |
| |
| |||
8260 | 8260 |
| |
8261 | 8261 |
| |
8262 | 8262 |
| |
8263 |
| - | |
| 8263 | + | |
8264 | 8264 |
| |
8265 | 8265 |
| |
8266 | 8266 |
| |
| |||
8280 | 8280 |
| |
8281 | 8281 |
| |
8282 | 8282 |
| |
| 8283 | + | |
| 8284 | + | |
| 8285 | + | |
| 8286 | + | |
| 8287 | + | |
| 8288 | + | |
| 8289 | + | |
| 8290 | + | |
| 8291 | + | |
| 8292 | + | |
| 8293 | + | |
| 8294 | + | |
| 8295 | + | |
| 8296 | + | |
8283 | 8297 |
| |
8284 | 8298 |
| |
8285 | 8299 |
| |
|
Lines changed: 29 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
14996 | 14996 |
| |
14997 | 14997 |
| |
14998 | 14998 |
| |
| 14999 | + | |
| 15000 | + | |
| 15001 | + | |
| 15002 | + | |
| 15003 | + | |
| 15004 | + | |
14999 | 15005 |
| |
15000 | 15006 |
| |
15001 | 15007 |
| |
| |||
15183 | 15189 |
| |
15184 | 15190 |
| |
15185 | 15191 |
| |
| 15192 | + | |
| 15193 | + | |
| 15194 | + | |
| 15195 | + | |
| 15196 | + | |
| 15197 | + | |
| 15198 | + | |
| 15199 | + | |
| 15200 | + | |
| 15201 | + | |
| 15202 | + | |
| 15203 | + | |
| 15204 | + | |
| 15205 | + | |
| 15206 | + | |
| 15207 | + | |
| 15208 | + | |
| 15209 | + | |
| 15210 | + | |
| 15211 | + | |
| 15212 | + | |
| 15213 | + | |
| 15214 | + | |
15186 | 15215 |
| |
15187 | 15216 |
| |
15188 | 15217 |
| |
|
Lines changed: 23 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2312 | 2312 |
| |
2313 | 2313 |
| |
2314 | 2314 |
| |
| 2315 | + | |
| 2316 | + | |
| 2317 | + | |
| 2318 | + | |
| 2319 | + | |
| 2320 | + | |
| 2321 | + | |
| 2322 | + | |
| 2323 | + | |
| 2324 | + | |
| 2325 | + | |
| 2326 | + | |
| 2327 | + | |
| 2328 | + | |
| 2329 | + | |
| 2330 | + | |
| 2331 | + | |
| 2332 | + | |
| 2333 | + | |
| 2334 | + | |
| 2335 | + | |
| 2336 | + | |
| 2337 | + | |
2315 | 2338 |
| |
2316 | 2339 |
| |
2317 | 2340 |
| |
| |||
2320 | 2343 |
| |
2321 | 2344 |
| |
2322 | 2345 |
| |
2323 |
| - | |
2324 |
| - | |
2325 | 2346 |
| |
2326 | 2347 |
| |
2327 | 2348 |
| |
| |||
2333 | 2354 |
| |
2334 | 2355 |
| |
2335 | 2356 |
| |
2336 |
| - | |
2337 |
| - | |
2338 | 2357 |
| |
2339 | 2358 |
| |
2340 | 2359 |
| |
|
0 commit comments
Comments
(0)