forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitfa91d4c
committed
Make parallel worker shutdown complete entirely via before_shmem_exit().
This is a step toward storing stats in dynamic shared memory. As dynamicshared memory segments are detached from just after before_shmem_exit()callbacks are processed, but before on_shmem_exit() callbacks are, no statscan be collected after before_shmem_exit() callbacks have been processed.Parallel worker shutdown can cause stats to be emitted during DSM detachcallbacks, e.g. for SharedFileSet (which closes its files, which can causesfd.c to emit stats about temporary files). Therefore parallel worker shutdownneeds to complete during the processing of before_shmem_exit callbacks.One might think this problem could instead be solved by carefully ordering theattaching to DSM segments, so that the pgstats segments get detached fromlater than the parallel query ones. That turns out to not work because thestats hash might need to grow which can cause new segments to beallocated, which then will be detached from earlier.There are two code changes:First, call ParallelWorkerShutdown() via before_shmem_exit. That's a good ideaon its own, because other shutdown callbacks like ShutdownPostgres andShutdownAuxiliaryProcess are called via before_*.Second, explicitly detach from the parallel query DSM segment, therebyensuring all stats are emitted during ParallelWorkerShutdown().There are nicer solutions to these problems, but it's not obvious which ofthose solutions is the correct one. As the shared memory stats work already isa huge amount of work...Author: Andres Freund <andres@anarazel.de>Discussion:https://postgr.es/m/20210405092914.mmxqe7j56lsjfsej@alap3.anarazel.deDiscussion:https://postgr.es/m/20210803023612.iziacxk5syn2r4ut@alap3.anarazel.de1 parentee3f8d3 commitfa91d4c
1 file changed
+13
-1
lines changedLines changed: 13 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1305 | 1305 |
| |
1306 | 1306 |
| |
1307 | 1307 |
| |
1308 |
| - | |
| 1308 | + | |
1309 | 1309 |
| |
1310 | 1310 |
| |
1311 | 1311 |
| |
| |||
1507 | 1507 |
| |
1508 | 1508 |
| |
1509 | 1509 |
| |
| 1510 | + | |
| 1511 | + | |
| 1512 | + | |
| 1513 | + | |
| 1514 | + | |
| 1515 | + | |
| 1516 | + | |
| 1517 | + | |
| 1518 | + | |
| 1519 | + | |
1510 | 1520 |
| |
1511 | 1521 |
| |
1512 | 1522 |
| |
1513 | 1523 |
| |
1514 | 1524 |
| |
1515 | 1525 |
| |
1516 | 1526 |
| |
| 1527 | + | |
| 1528 | + | |
1517 | 1529 |
| |
1518 | 1530 |
| |
1519 | 1531 |
| |
|
0 commit comments
Comments
(0)