Age Owner Branch data TLA Line data Source code
1 : : /*-------------------------------------------------------------------------
2 : : *
3 : : * method_worker.c
4 : : * AIO - perform AIO using worker processes
5 : : *
6 : : * IO workers consume IOs from a shared memory submission queue, run
7 : : * traditional synchronous system calls, and perform the shared completion
8 : : * handling immediately. Client code submits most requests by pushing IOs
9 : : * into the submission queue, and waits (if necessary) using condition
10 : : * variables. Some IOs cannot be performed in another process due to lack of
11 : : * infrastructure for reopening the file, and must processed synchronously by
12 : : * the client code when submitted.
13 : : *
14 : : * The pool of workers tries to stabilize at a size that can handle recently
15 : : * seen variation in demand, within the configured limits.
16 : : *
17 : : * This method of AIO is available in all builds on all operating systems, and
18 : : * is the default.
19 : : *
20 : : * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
21 : : * Portions Copyright (c) 1994, Regents of the University of California
22 : : *
23 : : * IDENTIFICATION
24 : : * src/backend/storage/aio/method_worker.c
25 : : *
26 : : *-------------------------------------------------------------------------
27 : : */
28 : :
29 : : #include "postgres.h"
30 : :
31 : : #include <limits.h>
32 : :
33 : : #include "libpq/pqsignal.h"
34 : : #include "miscadmin.h"
35 : : #include "port/pg_bitutils.h"
36 : : #include "postmaster/auxprocess.h"
37 : : #include "postmaster/interrupt.h"
38 : : #include "storage/aio.h"
39 : : #include "storage/aio_internal.h"
40 : : #include "storage/aio_subsys.h"
41 : : #include "storage/io_worker.h"
42 : : #include "storage/ipc.h"
43 : : #include "storage/latch.h"
44 : : #include "storage/lwlock.h"
45 : : #include "storage/pmsignal.h"
46 : : #include "storage/proc.h"
47 : : #include "storage/procsignal.h"
48 : : #include "storage/shmem.h"
49 : : #include "tcop/tcopprot.h"
50 : : #include "utils/injection_point.h"
51 : : #include "utils/memdebug.h"
52 : : #include "utils/ps_status.h"
53 : : #include "utils/wait_event.h"
54 : :
55 : : /*
56 : : * Saturation for counters used to estimate wakeup:IO ratio.
57 : : *
58 : : * We maintain hist_wakeups for wakeups received and hist_ios for IOs
59 : : * processed by each worker. When either counter reaches this saturation
60 : : * value, we divide both by two. The result is an exponentially decaying
61 : : * ratio of wakeups to IOs, with a very short memory.
62 : : *
63 : : * If a worker is itself experiencing useless wakeups, it assumes that
64 : : * higher-numbered workers would experience even more, so it should end the
65 : : * chain.
66 : : */
67 : : #define PGAIO_WORKER_WAKEUP_RATIO_SATURATE 4
68 : :
69 : : /* Debugging support: show current IO and wakeups:ios statistics in ps. */
70 : : /* #define PGAIO_WORKER_SHOW_PS_INFO */
71 : :
72 : : typedef struct PgAioWorkerSubmissionQueue
73 : : {
74 : : uint32 size;
75 : : uint32 head;
76 : : uint32 tail;
77 : : int sqes[FLEXIBLE_ARRAY_MEMBER];
78 : : } PgAioWorkerSubmissionQueue;
79 : :
80 : : typedef struct PgAioWorkerSlot
81 : : {
82 : : ProcNumber proc_number;
83 : : } PgAioWorkerSlot;
84 : :
85 : : /*
86 : : * Sets of worker IDs are held in a simple bitmap, accessed through functions
87 : : * that provide a more readable abstraction. If we wanted to support more
88 : : * workers than that, the contention on the single queue would surely get too
89 : : * high, so we might want to consider multiple pools instead of widening this.
90 : : */
91 : : typedef uint64 PgAioWorkerSet;
92 : :
93 : : #define PGAIO_WORKERSET_BITS (sizeof(PgAioWorkerSet) * CHAR_BIT)
94 : :
95 : : static_assert(PGAIO_WORKERSET_BITS >= MAX_IO_WORKERS, "too small");
96 : :
97 : : typedef struct PgAioWorkerControl
98 : : {
99 : : /* Seen by postmaster */
100 : : bool grow;
101 : : bool grow_signal_sent;
102 : :
103 : : /* Protected by AioWorkerSubmissionQueueLock. */
104 : : PgAioWorkerSet idle_workerset;
105 : :
106 : : /* Protected by AioWorkerControlLock. */
107 : : PgAioWorkerSet workerset;
108 : : int nworkers;
109 : :
110 : : /* Protected by AioWorkerControlLock. */
111 : : PgAioWorkerSlot workers[FLEXIBLE_ARRAY_MEMBER];
112 : : } PgAioWorkerControl;
113 : :
114 : :
115 : : static void pgaio_worker_shmem_request(void *arg);
116 : : static void pgaio_worker_shmem_init(void *arg);
117 : :
118 : : static bool pgaio_worker_needs_synchronous_execution(PgAioHandle *ioh);
119 : : static int pgaio_worker_submit(uint16 num_staged_ios, PgAioHandle **staged_ios);
120 : :
121 : :
122 : : const IoMethodOps pgaio_worker_ops = {
123 : : .shmem_callbacks.request_fn = pgaio_worker_shmem_request,
124 : : .shmem_callbacks.init_fn = pgaio_worker_shmem_init,
125 : :
126 : : .needs_synchronous_execution = pgaio_worker_needs_synchronous_execution,
127 : : .submit = pgaio_worker_submit,
128 : : };
129 : :
130 : :
131 : : /* GUCs */
132 : : int io_min_workers = 2;
133 : : int io_max_workers = 8;
134 : : int io_worker_idle_timeout = 60000;
135 : : int io_worker_launch_interval = 100;
136 : :
137 : :
138 : : static int io_worker_queue_size = 64;
139 : : static int MyIoWorkerId = -1;
140 : : static PgAioWorkerSubmissionQueue *io_worker_submission_queue;
141 : : static PgAioWorkerControl *io_worker_control;
142 : :
143 : :
144 : : static void
234 tmunro@postgresql.or 145 :CBC 2636 : pgaio_workerset_initialize(PgAioWorkerSet *set)
146 : : {
147 : 2636 : *set = 0;
148 : 2636 : }
149 : :
150 : : static bool
151 : 1184507 : pgaio_workerset_is_empty(PgAioWorkerSet *set)
152 : : {
153 : 1184507 : return *set == 0;
154 : : }
155 : :
156 : : static PgAioWorkerSet
157 : 1467136 : pgaio_workerset_singleton(int worker)
158 : : {
159 [ + - - + ]: 1467136 : Assert(worker >= 0 && worker < MAX_IO_WORKERS);
160 : 1467136 : return UINT64_C(1) << worker;
161 : : }
162 : :
163 : : static void
164 : 1417 : pgaio_workerset_all(PgAioWorkerSet *set)
165 : : {
166 : 1417 : *set = UINT64_MAX >> (PGAIO_WORKERSET_BITS - MAX_IO_WORKERS);
167 : 1417 : }
168 : :
169 : : static void
170 : 1417 : pgaio_workerset_subtract(PgAioWorkerSet *set1, const PgAioWorkerSet *set2)
171 : : {
172 : 1417 : *set1 &= ~*set2;
173 : 1417 : }
174 : :
175 : : static void
176 : 440944 : pgaio_workerset_insert(PgAioWorkerSet *set, int worker)
177 : : {
178 [ + - - + ]: 440944 : Assert(worker >= 0 && worker < MAX_IO_WORKERS);
179 : 440944 : *set |= pgaio_workerset_singleton(worker);
180 : 440944 : }
181 : :
182 : : static void
183 : 1023358 : pgaio_workerset_remove(PgAioWorkerSet *set, int worker)
184 : : {
185 [ + - - + ]: 1023358 : Assert(worker >= 0 && worker < MAX_IO_WORKERS);
186 : 1023358 : *set &= ~pgaio_workerset_singleton(worker);
187 : 1023358 : }
188 : :
189 : : static void
190 : 8737 : pgaio_workerset_remove_lte(PgAioWorkerSet *set, int worker)
191 : : {
192 [ + - - + ]: 8737 : Assert(worker >= 0 && worker < MAX_IO_WORKERS);
193 : 8737 : *set &= (~(PgAioWorkerSet) 0) << (worker + 1);
194 : 8737 : }
195 : :
196 : : static int
197 : 6178 : pgaio_workerset_get_highest(PgAioWorkerSet *set)
198 : : {
199 [ - + ]: 6178 : Assert(!pgaio_workerset_is_empty(set));
200 : 6178 : return pg_leftmost_one_pos64(*set);
201 : : }
202 : :
203 : : static int
204 : 576250 : pgaio_workerset_get_lowest(PgAioWorkerSet *set)
205 : : {
206 [ - + ]: 576250 : Assert(!pgaio_workerset_is_empty(set));
207 : 576250 : return pg_rightmost_one_pos64(*set);
208 : : }
209 : :
210 : : static int
211 : 3464 : pgaio_workerset_pop_lowest(PgAioWorkerSet *set)
212 : : {
213 : 3464 : int worker = pgaio_workerset_get_lowest(set);
214 : :
215 : 3464 : pgaio_workerset_remove(set, worker);
216 : 3464 : return worker;
217 : : }
218 : :
219 : : #ifdef USE_ASSERT_CHECKING
220 : : static bool
221 : 2834 : pgaio_workerset_contains(PgAioWorkerSet *set, int worker)
222 : : {
223 [ + - - + ]: 2834 : Assert(worker >= 0 && worker < MAX_IO_WORKERS);
224 : 2834 : return (*set & pgaio_workerset_singleton(worker)) != 0;
225 : : }
226 : :
227 : : static int
228 : 2834 : pgaio_workerset_count(PgAioWorkerSet *set)
229 : : {
230 : 2834 : return pg_popcount64(*set);
231 : : }
232 : : #endif
233 : :
234 : : static void
236 heikki.linnakangas@i 235 : 1322 : pgaio_worker_shmem_request(void *arg)
236 : : {
237 : : size_t size;
238 : : int queue_size;
239 : :
240 : : /* Round size up to next power of two so we can make a mask. */
241 : 1322 : queue_size = pg_nextpower2_32(io_worker_queue_size);
242 : :
243 : 1322 : size = offsetof(PgAioWorkerSubmissionQueue, sqes) + sizeof(int) * queue_size;
244 : 1322 : ShmemRequestStruct(.name = "AioWorkerSubmissionQueue",
245 : : .size = size,
246 : : .ptr = (void **) &io_worker_submission_queue,
247 : : );
248 : :
249 : 1322 : size = offsetof(PgAioWorkerControl, workers) + sizeof(PgAioWorkerSlot) * MAX_IO_WORKERS;
250 : 1322 : ShmemRequestStruct(.name = "AioWorkerControl",
251 : : .size = size,
252 : : .ptr = (void **) &io_worker_control,
253 : : );
620 andres@anarazel.de 254 : 1322 : }
255 : :
256 : : static void
236 heikki.linnakangas@i 257 : 1318 : pgaio_worker_shmem_init(void *arg)
258 : : {
259 : : int queue_size;
260 : :
261 : : /* Round size up like in pgaio_worker_shmem_request() */
262 : 1318 : queue_size = pg_nextpower2_32(io_worker_queue_size);
263 : :
264 : 1318 : io_worker_submission_queue->size = queue_size;
265 : 1318 : io_worker_submission_queue->head = 0;
266 : 1318 : io_worker_submission_queue->tail = 0;
234 tmunro@postgresql.or 267 : 1318 : io_worker_control->grow = false;
268 : 1318 : pgaio_workerset_initialize(&io_worker_control->workerset);
269 : 1318 : pgaio_workerset_initialize(&io_worker_control->idle_workerset);
270 : :
236 heikki.linnakangas@i 271 [ + + ]: 43494 : for (int i = 0; i < MAX_IO_WORKERS; ++i)
234 tmunro@postgresql.or 272 : 42176 : io_worker_control->workers[i].proc_number = INVALID_PROC_NUMBER;
273 : 1318 : }
274 : :
275 : : /*
276 : : * Tell postmaster that we think a new worker is needed.
277 : : */
278 : : static void
279 : 52 : pgaio_worker_request_grow(void)
280 : : {
281 : : /*
282 : : * Suppress useless signaling if we already know that we're at the
283 : : * maximum. This uses an unlocked read of nworkers, but that's OK for
284 : : * this heuristic purpose.
285 : : */
286 [ - + ]: 52 : if (io_worker_control->nworkers >= io_max_workers)
234 tmunro@postgresql.or 287 :UBC 0 : return;
288 : :
289 : : /* Already requested? */
234 tmunro@postgresql.or 290 [ + + ]:CBC 52 : if (io_worker_control->grow)
291 : 17 : return;
292 : :
293 : 35 : io_worker_control->grow = true;
294 : 35 : pg_memory_barrier();
295 : :
296 : : /*
297 : : * If the postmaster has already been signaled, don't do it again until
298 : : * the postmaster clears this flag. There is no point in repeated signals
299 : : * if grow is being set and cleared repeatedly while the postmaster is
300 : : * waiting for io_worker_launch_interval, which it applies even to
301 : : * canceled requests.
302 : : */
303 [ + + ]: 35 : if (io_worker_control->grow_signal_sent)
304 : 1 : return;
305 : :
306 : 34 : io_worker_control->grow_signal_sent = true;
307 : 34 : pg_memory_barrier();
308 : 34 : SendPostmasterSignal(PMSIGNAL_IO_WORKER_GROW);
309 : : }
310 : :
311 : : /*
312 : : * Cancel any request for a new worker, after observing an empty queue.
313 : : */
314 : : static void
315 : 439527 : pgaio_worker_cancel_grow(void)
316 : : {
317 [ + + ]: 439527 : if (!io_worker_control->grow)
318 : 439492 : return;
319 : :
320 : 35 : io_worker_control->grow = false;
321 : 35 : pg_memory_barrier();
322 : : }
323 : :
324 : : /*
325 : : * Called by the postmaster to check if a new worker has been requested (but
326 : : * possibly canceled since).
327 : : */
328 : : bool
329 : 90442 : pgaio_worker_pm_test_grow_signal_sent(void)
330 : : {
331 : 90442 : pg_memory_barrier();
332 [ + - + + ]: 90442 : return io_worker_control && io_worker_control->grow_signal_sent;
333 : : }
334 : :
335 : : /*
336 : : * Called by the postmaster to check if a new worker has been requested and
337 : : * not canceled since.
338 : : */
339 : : bool
340 : 56 : pgaio_worker_pm_test_grow(void)
341 : : {
342 : 56 : pg_memory_barrier();
343 [ + - + + ]: 56 : return io_worker_control && io_worker_control->grow;
344 : : }
345 : :
346 : : /*
347 : : * Called by the postmaster to clear the request for a new worker.
348 : : */
349 : : void
350 : 39 : pgaio_worker_pm_clear_grow_signal_sent(void)
351 : : {
352 [ - + ]: 39 : if (!io_worker_control)
234 tmunro@postgresql.or 353 :UBC 0 : return;
354 : :
234 tmunro@postgresql.or 355 :CBC 39 : io_worker_control->grow = false;
356 : 39 : io_worker_control->grow_signal_sent = false;
357 : 39 : pg_memory_barrier();
358 : : }
359 : :
360 : : static int
361 : 594364 : pgaio_worker_choose_idle(int only_workers_above)
362 : : {
363 : : PgAioWorkerSet workerset;
364 : : int worker;
365 : :
366 [ - + ]: 594364 : Assert(LWLockHeldByMeInMode(AioWorkerSubmissionQueueLock, LW_EXCLUSIVE));
367 : :
368 : 594364 : workerset = io_worker_control->idle_workerset;
369 [ + + ]: 594364 : if (only_workers_above >= 0)
370 : 8737 : pgaio_workerset_remove_lte(&workerset, only_workers_above);
371 [ + + ]: 594364 : if (pgaio_workerset_is_empty(&workerset))
620 andres@anarazel.de 372 : 22995 : return -1;
373 : :
374 : : /* Find the lowest numbered idle worker and mark it not idle. */
234 tmunro@postgresql.or 375 : 571369 : worker = pgaio_workerset_get_lowest(&workerset);
376 : 571369 : pgaio_workerset_remove(&io_worker_control->idle_workerset, worker);
377 : :
620 andres@anarazel.de 378 : 571369 : return worker;
379 : : }
380 : :
381 : : /*
382 : : * Try to wake a worker by setting its latch, to tell it there are IOs to
383 : : * process in the submission queue.
384 : : */
385 : : static void
234 tmunro@postgresql.or 386 : 574833 : pgaio_worker_wake(int worker)
387 : : {
388 : : ProcNumber proc_number;
389 : :
390 : : /*
391 : : * If the selected worker is concurrently exiting, then pgaio_worker_die()
392 : : * had not yet removed it as of when we saw it in idle_workerset. That's
393 : : * OK, because it will wake all remaining workers to close wakeup-vs-exit
394 : : * races: *someone* will see the queued IO. If there are no workers
395 : : * running, the postmaster will start a new one.
396 : : */
397 : 574833 : proc_number = io_worker_control->workers[worker].proc_number;
398 [ + + ]: 574833 : if (proc_number != INVALID_PROC_NUMBER)
399 : 574816 : SetLatch(&GetPGProcByNumber(proc_number)->procLatch);
400 : 574833 : }
401 : :
402 : : /*
403 : : * Try to wake a set of workers. Used on pool change, to close races
404 : : * described in the callers.
405 : : */
406 : : static void
407 : 2834 : pgaio_workerset_wake(PgAioWorkerSet workerset)
408 : : {
409 [ + + ]: 6298 : while (!pgaio_workerset_is_empty(&workerset))
410 : 3464 : pgaio_worker_wake(pgaio_workerset_pop_lowest(&workerset));
411 : 2834 : }
412 : :
413 : : static bool
620 andres@anarazel.de 414 : 585764 : pgaio_worker_submission_queue_insert(PgAioHandle *ioh)
415 : : {
416 : : PgAioWorkerSubmissionQueue *queue;
417 : : uint32 new_head;
418 : :
234 tmunro@postgresql.or 419 [ - + ]: 585764 : Assert(LWLockHeldByMeInMode(AioWorkerSubmissionQueueLock, LW_EXCLUSIVE));
420 : :
620 andres@anarazel.de 421 : 585764 : queue = io_worker_submission_queue;
422 : 585764 : new_head = (queue->head + 1) & (queue->size - 1);
423 [ - + ]: 585764 : if (new_head == queue->tail)
424 : : {
620 andres@anarazel.de 425 [ # # ]:UBC 0 : pgaio_debug(DEBUG3, "io queue is full, at %u elements",
426 : : io_worker_submission_queue->size);
427 : 0 : return false; /* full */
428 : : }
429 : :
504 tmunro@postgresql.or 430 :CBC 585764 : queue->sqes[queue->head] = pgaio_io_get_id(ioh);
620 andres@anarazel.de 431 : 585764 : queue->head = new_head;
432 : :
433 : 585764 : return true;
434 : : }
435 : :
436 : : static int
437 : 885218 : pgaio_worker_submission_queue_consume(void)
438 : : {
439 : : PgAioWorkerSubmissionQueue *queue;
440 : : int result;
441 : :
234 tmunro@postgresql.or 442 [ - + ]: 885218 : Assert(LWLockHeldByMeInMode(AioWorkerSubmissionQueueLock, LW_EXCLUSIVE));
443 : :
620 andres@anarazel.de 444 : 885218 : queue = io_worker_submission_queue;
445 [ + + ]: 885218 : if (queue->tail == queue->head)
464 peter@eisentraut.org 446 : 439527 : return -1; /* empty */
447 : :
504 tmunro@postgresql.or 448 : 445691 : result = queue->sqes[queue->tail];
620 andres@anarazel.de 449 : 445691 : queue->tail = (queue->tail + 1) & (queue->size - 1);
450 : :
451 : 445691 : return result;
452 : : }
453 : :
454 : : static uint32
455 : 245159 : pgaio_worker_submission_queue_depth(void)
456 : : {
457 : : uint32 head;
458 : : uint32 tail;
459 : :
234 tmunro@postgresql.or 460 [ - + ]: 245159 : Assert(LWLockHeldByMeInMode(AioWorkerSubmissionQueueLock, LW_EXCLUSIVE));
461 : :
620 andres@anarazel.de 462 : 245159 : head = io_worker_submission_queue->head;
463 : 245159 : tail = io_worker_submission_queue->tail;
464 : :
465 [ + + ]: 245159 : if (tail > head)
466 : 147 : head += io_worker_submission_queue->size;
467 : :
468 [ - + ]: 245159 : Assert(head >= tail);
469 : :
470 : 245159 : return head - tail;
471 : : }
472 : :
473 : : static bool
474 : 1178639 : pgaio_worker_needs_synchronous_execution(PgAioHandle *ioh)
475 : : {
476 : : return
477 : 1178639 : !IsUnderPostmaster
478 [ + + ]: 1174768 : || ioh->flags & PGAIO_HF_REFERENCES_LOCAL
479 [ + + - + ]: 2353407 : || !pgaio_io_can_reopen(ioh);
480 : : }
481 : :
482 : : static int
237 tmunro@postgresql.or 483 : 586913 : pgaio_worker_submit(uint16 num_staged_ios, PgAioHandle **staged_ios)
484 : : {
262 tomas.vondra@postgre 485 : 586913 : PgAioHandle **synchronous_ios = NULL;
620 andres@anarazel.de 486 : 586913 : int nsync = 0;
234 tmunro@postgresql.or 487 : 586913 : int worker = -1;
488 : :
504 489 [ - + ]: 586913 : Assert(num_staged_ios <= PGAIO_SUBMIT_BATCH_SIZE);
490 : :
237 491 [ + + ]: 1173963 : for (int i = 0; i < num_staged_ios; i++)
492 : 587050 : pgaio_io_prepare_submit(staged_ios[i]);
493 : :
262 tomas.vondra@postgre 494 [ + + ]: 586913 : if (LWLockConditionalAcquire(AioWorkerSubmissionQueueLock, LW_EXCLUSIVE))
495 : : {
496 [ + + ]: 1171391 : for (int i = 0; i < num_staged_ios; ++i)
497 : : {
498 [ - + ]: 585764 : Assert(!pgaio_worker_needs_synchronous_execution(staged_ios[i]));
499 [ - + ]: 585764 : if (!pgaio_worker_submission_queue_insert(staged_ios[i]))
500 : : {
501 : : /*
502 : : * Do the rest synchronously. If the queue is full, give up
503 : : * and do the rest synchronously. We're holding an exclusive
504 : : * lock on the queue so nothing can consume entries.
505 : : */
262 tomas.vondra@postgre 506 :UBC 0 : synchronous_ios = &staged_ios[i];
507 : 0 : nsync = (num_staged_ios - i);
508 : :
509 : 0 : break;
510 : : }
511 : : }
512 : : /* Choose one worker to wake for this batch. */
234 tmunro@postgresql.or 513 :CBC 585627 : worker = pgaio_worker_choose_idle(-1);
262 tomas.vondra@postgre 514 : 585627 : LWLockRelease(AioWorkerSubmissionQueueLock);
515 : :
516 : : /* Wake up chosen worker. It will wake peers if necessary. */
234 tmunro@postgresql.or 517 [ + + ]: 585627 : if (worker != -1)
518 : 570121 : pgaio_worker_wake(worker);
519 : : }
520 : : else
521 : : {
522 : : /* do everything synchronously, no wakeup needed */
262 tomas.vondra@postgre 523 : 1286 : synchronous_ios = staged_ios;
524 : 1286 : nsync = num_staged_ios;
525 : : }
526 : :
527 : : /* Run whatever is left synchronously. */
620 andres@anarazel.de 528 [ + + ]: 586913 : if (nsync > 0)
529 : : {
530 [ + + ]: 2572 : for (int i = 0; i < nsync; ++i)
531 : : {
532 : 1286 : pgaio_io_perform_synchronously(synchronous_ios[i]);
533 : : }
534 : : }
535 : :
536 : 586913 : return num_staged_ios;
537 : : }
538 : :
539 : : /*
540 : : * on_shmem_exit() callback that releases the worker's slot in
541 : : * io_worker_control.
542 : : */
543 : : static void
544 : 1417 : pgaio_worker_die(int code, Datum arg)
545 : : {
546 : : PgAioWorkerSet notify_set;
547 : :
234 tmunro@postgresql.or 548 : 1417 : LWLockAcquire(AioWorkerSubmissionQueueLock, LW_EXCLUSIVE);
549 : 1417 : pgaio_workerset_remove(&io_worker_control->idle_workerset, MyIoWorkerId);
620 andres@anarazel.de 550 : 1417 : LWLockRelease(AioWorkerSubmissionQueueLock);
551 : :
234 tmunro@postgresql.or 552 : 1417 : LWLockAcquire(AioWorkerControlLock, LW_EXCLUSIVE);
553 [ - + ]: 1417 : Assert(io_worker_control->workers[MyIoWorkerId].proc_number == MyProcNumber);
554 : 1417 : io_worker_control->workers[MyIoWorkerId].proc_number = INVALID_PROC_NUMBER;
555 [ - + ]: 1417 : Assert(pgaio_workerset_contains(&io_worker_control->workerset, MyIoWorkerId));
556 : 1417 : pgaio_workerset_remove(&io_worker_control->workerset, MyIoWorkerId);
557 : 1417 : notify_set = io_worker_control->workerset;
558 [ - + ]: 1417 : Assert(io_worker_control->nworkers > 0);
559 : 1417 : io_worker_control->nworkers--;
560 [ - + ]: 1417 : Assert(pgaio_workerset_count(&io_worker_control->workerset) ==
561 : : io_worker_control->nworkers);
562 : 1417 : LWLockRelease(AioWorkerControlLock);
563 : :
564 : : /*
565 : : * Notify other workers on pool change. This allows the new highest
566 : : * worker to know that it is now the one that can time out, and closes a
567 : : * wakeup-loss race described in pgaio_worker_wake().
568 : : */
569 : 1417 : pgaio_workerset_wake(notify_set);
620 andres@anarazel.de 570 : 1417 : }
571 : :
572 : : /*
573 : : * Register the worker in shared memory, assign MyIoWorkerId and register a
574 : : * shutdown callback to release registration.
575 : : */
576 : : static void
577 : 1417 : pgaio_worker_register(void)
578 : : {
579 : : PgAioWorkerSet free_workerset;
580 : : PgAioWorkerSet old_workerset;
581 : :
582 : 1417 : MyIoWorkerId = -1;
583 : :
234 tmunro@postgresql.or 584 : 1417 : LWLockAcquire(AioWorkerControlLock, LW_EXCLUSIVE);
585 : : /* Find lowest unused worker ID. */
586 : 1417 : pgaio_workerset_all(&free_workerset);
587 : 1417 : pgaio_workerset_subtract(&free_workerset, &io_worker_control->workerset);
588 [ + - ]: 1417 : if (!pgaio_workerset_is_empty(&free_workerset))
589 : 1417 : MyIoWorkerId = pgaio_workerset_get_lowest(&free_workerset);
590 [ - + ]: 1417 : if (MyIoWorkerId == -1)
234 tmunro@postgresql.or 591 [ # # ]:UBC 0 : elog(ERROR, "couldn't find a free worker ID");
592 : :
234 tmunro@postgresql.or 593 [ - + ]:CBC 1417 : Assert(io_worker_control->workers[MyIoWorkerId].proc_number ==
594 : : INVALID_PROC_NUMBER);
595 : 1417 : io_worker_control->workers[MyIoWorkerId].proc_number = MyProcNumber;
596 : :
597 : 1417 : old_workerset = io_worker_control->workerset;
598 [ - + ]: 1417 : Assert(!pgaio_workerset_contains(&old_workerset, MyIoWorkerId));
599 : 1417 : pgaio_workerset_insert(&io_worker_control->workerset, MyIoWorkerId);
600 : 1417 : io_worker_control->nworkers++;
601 [ - + ]: 1417 : Assert(io_worker_control->nworkers <= MAX_IO_WORKERS);
602 [ - + ]: 1417 : Assert(pgaio_workerset_count(&io_worker_control->workerset) ==
603 : : io_worker_control->nworkers);
604 : 1417 : LWLockRelease(AioWorkerControlLock);
605 : :
606 : : /*
607 : : * Notify other workers on pool change. If we were the highest worker,
608 : : * this allows the new highest worker to know that it can time out.
609 : : */
610 : 1417 : pgaio_workerset_wake(old_workerset);
611 : :
620 andres@anarazel.de 612 : 1417 : on_shmem_exit(pgaio_worker_die, 0);
613 : 1417 : }
614 : :
615 : : static void
606 melanieplageman@gmai 616 : 1586 : pgaio_worker_error_callback(void *arg)
617 : : {
618 : : ProcNumber owner;
619 : : PGPROC *owner_proc;
620 : : int32 owner_pid;
621 : 1586 : PgAioHandle *ioh = arg;
622 : :
623 [ - + ]: 1586 : if (!ioh)
606 melanieplageman@gmai 624 :UBC 0 : return;
625 : :
606 melanieplageman@gmai 626 [ - + ]:CBC 1586 : Assert(ioh->owner_procno != MyProcNumber);
627 [ - + ]: 1586 : Assert(MyBackendType == B_IO_WORKER);
628 : :
629 : 1586 : owner = ioh->owner_procno;
630 : 1586 : owner_proc = GetPGProcByNumber(owner);
631 : 1586 : owner_pid = owner_proc->pid;
632 : :
633 : 1586 : errcontext("I/O worker executing I/O on behalf of process %d", owner_pid);
634 : : }
635 : :
636 : : /*
637 : : * Check if this backend is allowed to time out, and thus should use a
638 : : * non-infinite sleep time. Only the highest-numbered worker is allowed to
639 : : * time out, and only if the pool is above io_min_workers. Serializing
640 : : * timeouts keeps IDs in a range 0..N without gaps, and avoids undershooting
641 : : * io_min_workers.
642 : : *
643 : : * The result is only instantaneously true and may be temporarily inconsistent
644 : : * in different workers around transitions, but all workers are woken up on
645 : : * pool size or GUC changes making the result eventually consistent.
646 : : */
647 : : static bool
234 tmunro@postgresql.or 648 : 439553 : pgaio_worker_can_timeout(void)
649 : : {
650 : : PgAioWorkerSet workerset;
651 : :
652 [ + + ]: 439553 : if (MyIoWorkerId < io_min_workers)
653 : 433375 : return false;
654 : :
655 : : /* Serialize against pool size changes. */
656 : 6178 : LWLockAcquire(AioWorkerControlLock, LW_SHARED);
657 : 6178 : workerset = io_worker_control->workerset;
658 : 6178 : LWLockRelease(AioWorkerControlLock);
659 : :
660 [ + + ]: 6178 : if (MyIoWorkerId != pgaio_workerset_get_highest(&workerset))
661 : 3641 : return false;
662 : :
663 : 2537 : return true;
664 : : }
665 : :
666 : : /*
667 : : * Emit a WARNING if io_min_workers > io_max_workers, since the worker
668 : : * pool will never exceed io_max_workers regardless of the minimum setting.
669 : : */
670 : : static void
145 michael@paquier.xyz 671 :GNC 1461 : check_io_worker_gucs(void)
672 : : {
673 : : /* Only do the check in one worker, to limit noise */
674 [ + + ]: 1461 : if (MyIoWorkerId != 0)
675 : 784 : return;
676 : :
677 [ - + ]: 677 : if (io_min_workers > io_max_workers)
145 michael@paquier.xyz 678 [ # # ]:UNC 0 : ereport(WARNING,
679 : : (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
680 : : errmsg("\"%s\" (%d) should be less than or equal to \"%s\" (%d)",
681 : : "io_min_workers", io_min_workers,
682 : : "io_max_workers", io_max_workers),
683 : : errdetail("The I/O worker pool will not exceed \"%s\" (%d) workers.",
684 : : "io_max_workers", io_max_workers)));
685 : : }
686 : :
687 : : void
620 andres@anarazel.de 688 :CBC 1417 : IoWorkerMain(const void *startup_data, size_t startup_data_len)
689 : : {
690 : : sigjmp_buf local_sigjmp_buf;
234 tmunro@postgresql.or 691 : 1417 : TimestampTz idle_timeout_abs = 0;
692 : 1417 : int timeout_guc_used = 0;
620 andres@anarazel.de 693 : 1417 : PgAioHandle *volatile error_ioh = NULL;
606 melanieplageman@gmai 694 : 1417 : ErrorContextCallback errcallback = {0};
620 andres@anarazel.de 695 : 1417 : volatile int error_errno = 0;
696 : : char cmd[128];
234 tmunro@postgresql.or 697 : 1417 : int hist_ios = 0;
698 : 1417 : int hist_wakeups = 0;
699 : :
620 andres@anarazel.de 700 : 1417 : AuxiliaryProcessMainCommon();
701 : :
702 : 1417 : pqsignal(SIGHUP, SignalHandlerForConfigReload);
703 : 1417 : pqsignal(SIGINT, die); /* to allow manually triggering worker restart */
704 : :
705 : : /*
706 : : * Ignore SIGTERM, will get explicit shutdown via SIGUSR2 later in the
707 : : * shutdown sequence, similar to checkpointer.
708 : : */
228 andrew@dunslane.net 709 : 1417 : pqsignal(SIGTERM, PG_SIG_IGN);
710 : : /* SIGQUIT handler was already set up by InitPostmasterChild */
711 : 1417 : pqsignal(SIGALRM, PG_SIG_IGN);
712 : 1417 : pqsignal(SIGPIPE, PG_SIG_IGN);
620 andres@anarazel.de 713 : 1417 : pqsignal(SIGUSR1, procsignal_sigusr1_handler);
714 : 1417 : pqsignal(SIGUSR2, SignalHandlerForShutdownRequest);
715 : :
716 : : /* also registers a shutdown callback to unregister */
717 : 1417 : pgaio_worker_register();
718 : :
145 michael@paquier.xyz 719 :GNC 1417 : check_io_worker_gucs();
720 : :
616 tmunro@postgresql.or 721 :CBC 1417 : sprintf(cmd, "%d", MyIoWorkerId);
620 andres@anarazel.de 722 : 1417 : set_ps_display(cmd);
723 : :
606 melanieplageman@gmai 724 : 1417 : errcallback.callback = pgaio_worker_error_callback;
725 : 1417 : errcallback.previous = error_context_stack;
726 : 1417 : error_context_stack = &errcallback;
727 : :
728 : : /* see PostgresMain() */
620 andres@anarazel.de 729 [ + + ]: 1417 : if (sigsetjmp(local_sigjmp_buf, 1) != 0)
730 : : {
731 : 1 : error_context_stack = NULL;
732 : 1 : HOLD_INTERRUPTS();
733 : :
734 : 1 : EmitErrorReport();
735 : :
736 : : /*
737 : : * In the - very unlikely - case that the IO failed in a way that
738 : : * raises an error we need to mark the IO as failed.
739 : : *
740 : : * Need to do just enough error recovery so that we can mark the IO as
741 : : * failed and then exit (postmaster will start a new worker).
742 : : */
743 : 1 : LWLockReleaseAll();
744 : :
745 [ + - ]: 1 : if (error_ioh != NULL)
746 : : {
747 : : /* should never fail without setting error_errno */
748 [ - + ]: 1 : Assert(error_errno != 0);
749 : :
750 : 1 : errno = error_errno;
751 : :
752 : 1 : START_CRIT_SECTION();
753 : 1 : pgaio_io_process_completion(error_ioh, -error_errno);
754 [ - + ]: 1 : END_CRIT_SECTION();
755 : : }
756 : :
757 : 1 : proc_exit(1);
758 : : }
759 : :
760 : : /* We can now handle ereport(ERROR) */
761 : 1417 : PG_exception_stack = &local_sigjmp_buf;
762 : :
763 : 1417 : sigprocmask(SIG_SETMASK, &UnBlockSig, NULL);
764 : :
765 [ + + ]: 886598 : while (!ShutdownRequestPending)
766 : : {
767 : : uint32 io_index;
234 tmunro@postgresql.or 768 : 885218 : int worker = -1;
769 : 885218 : int queue_depth = 0;
770 : 885218 : bool maybe_grow = false;
771 : :
772 : : /*
773 : : * Try to get a job to do.
774 : : *
775 : : * The lwlock acquisition also provides the necessary memory barrier
776 : : * to ensure that we don't see an outdated data in the handle.
777 : : */
620 andres@anarazel.de 778 : 885218 : LWLockAcquire(AioWorkerSubmissionQueueLock, LW_EXCLUSIVE);
464 peter@eisentraut.org 779 [ + + ]: 885218 : if ((io_index = pgaio_worker_submission_queue_consume()) == -1)
780 : : {
781 : : /* Nothing to do. Mark self idle. */
234 tmunro@postgresql.or 782 : 439527 : pgaio_workerset_insert(&io_worker_control->idle_workerset,
783 : : MyIoWorkerId);
784 : : }
785 : : else
786 : : {
787 : : /* Got one. Clear idle flag. */
788 : 445691 : pgaio_workerset_remove(&io_worker_control->idle_workerset,
789 : : MyIoWorkerId);
790 : :
791 : : /*
792 : : * See if we should wake up a higher numbered peer. Only do that
793 : : * if this worker is not receiving spurious wakeups itself. The
794 : : * intention is create a frontier beyond which idle workers stay
795 : : * asleep.
796 : : *
797 : : * This heuristic tries to discover the useful wakeup propagation
798 : : * chain length when IOs are very fast and workers wake up to find
799 : : * that all IOs have already been taken.
800 : : *
801 : : * If we chose not to wake a worker when we ideally should have,
802 : : * then the ratio will soon change to correct that.
803 : : */
804 [ + + ]: 445691 : if (hist_wakeups <= hist_ios)
805 : : {
806 : 245159 : queue_depth = pgaio_worker_submission_queue_depth();
807 [ + + ]: 245159 : if (queue_depth > 0)
808 : : {
809 : : /* Choose a worker higher than me to wake. */
810 : 8737 : worker = pgaio_worker_choose_idle(MyIoWorkerId);
811 [ + + ]: 8737 : if (worker == -1)
812 : 7489 : maybe_grow = true;
813 : : }
814 : : }
815 : : }
620 andres@anarazel.de 816 : 885218 : LWLockRelease(AioWorkerSubmissionQueueLock);
817 : :
818 : : /* Propagate wakeups. */
234 tmunro@postgresql.or 819 [ + + ]: 885218 : if (worker != -1)
820 : : {
821 : 1248 : pgaio_worker_wake(worker);
822 : : }
823 [ + + ]: 883970 : else if (maybe_grow)
824 : : {
825 : : /*
826 : : * We know there was at least one more item in the queue, and we
827 : : * failed to find a higher-numbered idle worker to wake. Now we
828 : : * decide if we should try to start one more worker.
829 : : *
830 : : * We do this with a simple heuristic: is the queue depth greater
831 : : * than the current number of workers?
832 : : *
833 : : * Consider the following situations:
834 : : *
835 : : * 1. The queue depth is constantly increasing, because IOs are
836 : : * arriving faster than they can possibly be serviced. It doesn't
837 : : * matter much which threshold we choose, as we will surely hit
838 : : * it. Crossing the current worker count is a useful signal
839 : : * because it's clearly too deep to avoid queuing latency already,
840 : : * but still leaves a small window of opportunity to improve the
841 : : * situation before the queue overflows.
842 : : *
843 : : * 2. The worker pool is keeping up, no latency is being
844 : : * introduced and an extra worker would be a waste of resources.
845 : : * Queue depth distributions tend to be heavily skewed, with long
846 : : * tails of low probability spikes (due to submission clustering,
847 : : * scheduling, jitter, stalls, noisy neighbors, etc). We want a
848 : : * number that is very unlikely to be triggered by an outlier, and
849 : : * we bet that an exponential or similar distribution whose
850 : : * outliers never reach this threshold must be almost entirely
851 : : * concentrated at the low end. If we do see a spike as big as
852 : : * the worker count, we take it as a signal that the distribution
853 : : * is surely too wide.
854 : : *
855 : : * On its own, this is an extremely crude signal. When combined
856 : : * with the wakeup propagation test that precedes it (but on its
857 : : * own tends to overshoot) and io_worker_launch_interval, the
858 : : * result is that we gradually test each pool size until we find
859 : : * one that doesn't trigger further expansion, and then hold it
860 : : * for at least io_worker_idle_timeout.
861 : : *
862 : : * XXX Perhaps ideas from queueing theory or control theory could
863 : : * do a better job of this.
864 : : */
865 : :
866 : : /* Read nworkers without lock for this heuristic purpose. */
867 [ + + ]: 7489 : if (queue_depth > io_worker_control->nworkers)
868 : 52 : pgaio_worker_request_grow();
869 : : }
870 : :
464 peter@eisentraut.org 871 [ + + ]: 885218 : if (io_index != -1)
872 : : {
620 andres@anarazel.de 873 : 445691 : PgAioHandle *ioh = NULL;
874 : :
875 : : /* Cancel timeout and update wakeup:work ratio. */
234 tmunro@postgresql.or 876 : 445691 : idle_timeout_abs = 0;
877 [ + + ]: 445691 : if (++hist_ios == PGAIO_WORKER_WAKEUP_RATIO_SATURATE)
878 : : {
879 : 122559 : hist_wakeups /= 2;
880 : 122559 : hist_ios /= 2;
881 : : }
882 : :
620 andres@anarazel.de 883 : 445691 : ioh = &pgaio_ctl->io_handles[io_index];
884 : 445691 : error_ioh = ioh;
606 melanieplageman@gmai 885 : 445691 : errcallback.arg = ioh;
886 : :
620 andres@anarazel.de 887 [ - + ]: 445691 : pgaio_debug_io(DEBUG4, ioh,
888 : : "worker %d processing IO",
889 : : MyIoWorkerId);
890 : :
891 : : /*
892 : : * Prevent interrupts between pgaio_io_reopen() and
893 : : * pgaio_io_perform_synchronously() that otherwise could lead to
894 : : * the FD getting closed in that window.
895 : : */
612 896 : 445691 : HOLD_INTERRUPTS();
897 : :
898 : : /*
899 : : * It's very unlikely, but possible, that reopen fails. E.g. due
900 : : * to memory allocations failing or file permissions changing or
901 : : * such. In that case we need to fail the IO.
902 : : *
903 : : * There's not really a good errno we can report here.
904 : : */
620 905 : 445691 : error_errno = ENOENT;
906 : 445691 : pgaio_io_reopen(ioh);
907 : :
908 : : /*
909 : : * To be able to exercise the reopen-fails path, allow injection
910 : : * points to trigger a failure at this point.
911 : : */
567 michael@paquier.xyz 912 : 445691 : INJECTION_POINT("aio-worker-after-reopen", ioh);
913 : :
620 andres@anarazel.de 914 : 445690 : error_errno = 0;
915 : 445690 : error_ioh = NULL;
916 : :
917 : : /*
918 : : * As part of IO completion the buffer will be marked as NOACCESS,
919 : : * until the buffer is pinned again - which never happens in io
920 : : * workers. Therefore the next time there is IO for the same
921 : : * buffer, the memory will be considered inaccessible. To avoid
922 : : * that, explicitly allow access to the memory before reading data
923 : : * into it.
924 : : */
925 : : #ifdef USE_VALGRIND
926 : : {
927 : : struct iovec *iov;
928 : : uint16 iov_length = pgaio_io_get_iovec_length(ioh, &iov);
929 : :
930 : : for (int i = 0; i < iov_length; i++)
931 : : VALGRIND_MAKE_MEM_UNDEFINED(iov[i].iov_base, iov[i].iov_len);
932 : : }
933 : : #endif
934 : :
935 : : #ifdef PGAIO_WORKER_SHOW_PS_INFO
936 : : {
937 : : char *description = pgaio_io_get_target_description(ioh);
938 : :
939 : : sprintf(cmd, "%d: [%s] %s",
940 : : MyIoWorkerId,
941 : : pgaio_io_get_op_name(ioh),
942 : : description);
943 : : pfree(description);
944 : : set_ps_display(cmd);
945 : : }
946 : : #endif
947 : :
948 : : /*
949 : : * We don't expect this to ever fail with ERROR or FATAL, no need
950 : : * to keep error_ioh set to the IO.
951 : : * pgaio_io_perform_synchronously() contains a critical section to
952 : : * ensure we don't accidentally fail.
953 : : */
954 : 445690 : pgaio_io_perform_synchronously(ioh);
955 : :
612 956 [ - + ]: 445690 : RESUME_INTERRUPTS();
606 melanieplageman@gmai 957 : 445690 : errcallback.arg = NULL;
958 : : }
959 : : else
960 : : {
961 : : int timeout_ms;
962 : :
963 : : /* Cancel new worker request if pending. */
234 tmunro@postgresql.or 964 : 439527 : pgaio_worker_cancel_grow();
965 : :
966 : : /* Compute the remaining allowed idle time. */
967 [ - + ]: 439527 : if (io_worker_idle_timeout == -1)
968 : : {
969 : : /* Never time out. */
234 tmunro@postgresql.or 970 :UBC 0 : timeout_ms = -1;
971 : : }
972 : : else
973 : : {
234 tmunro@postgresql.or 974 :CBC 439527 : TimestampTz now = GetCurrentTimestamp();
975 : :
976 : : /* If the GUC changes, reset timer. */
977 [ + + ]: 439527 : if (idle_timeout_abs != 0 &&
978 [ - + ]: 640 : io_worker_idle_timeout != timeout_guc_used)
234 tmunro@postgresql.or 979 :UBC 0 : idle_timeout_abs = 0;
980 : :
981 : : /* Only the highest-numbered worker can time out. */
234 tmunro@postgresql.or 982 [ + + ]:CBC 439527 : if (pgaio_worker_can_timeout())
983 : : {
984 [ + + ]: 2511 : if (idle_timeout_abs == 0)
985 : : {
986 : : /*
987 : : * I have just been promoted to the timeout worker, or
988 : : * the GUC changed. Compute new absolute time from
989 : : * now.
990 : : */
991 : 1873 : idle_timeout_abs =
992 : 1873 : TimestampTzPlusMilliseconds(now,
993 : : io_worker_idle_timeout);
994 : 1873 : timeout_guc_used = io_worker_idle_timeout;
995 : : }
996 : 2511 : timeout_ms =
997 : 2511 : TimestampDifferenceMilliseconds(now, idle_timeout_abs);
998 : : }
999 : : else
1000 : : {
1001 : : /* No timeout for me. */
1002 : 437016 : idle_timeout_abs = 0;
1003 : 437016 : timeout_ms = -1;
1004 : : }
1005 : : }
1006 : :
1007 : : #ifdef PGAIO_WORKER_SHOW_PS_INFO
1008 : : sprintf(cmd, "%d: idle, wakeups:ios = %d:%d",
1009 : : MyIoWorkerId, hist_wakeups, hist_ios);
1010 : : set_ps_display(cmd);
1011 : : #endif
1012 : :
1013 [ + + ]: 439527 : if (WaitLatch(MyLatch, WL_LATCH_SET | WL_EXIT_ON_PM_DEATH | WL_TIMEOUT,
1014 : : timeout_ms,
1015 : : WAIT_EVENT_IO_WORKER_MAIN) == WL_TIMEOUT)
1016 : : {
1017 : : /* WL_TIMEOUT */
1018 [ + - ]: 26 : if (pgaio_worker_can_timeout())
1019 [ + - ]: 26 : if (GetCurrentTimestamp() >= idle_timeout_abs)
1020 : 26 : break;
1021 : : }
1022 : : else
1023 : : {
1024 : : /* WL_LATCH_SET */
1025 [ + + ]: 439495 : if (++hist_wakeups == PGAIO_WORKER_WAKEUP_RATIO_SATURATE)
1026 : : {
1027 : 104374 : hist_wakeups /= 2;
1028 : 104374 : hist_ios /= 2;
1029 : : }
1030 : : }
620 andres@anarazel.de 1031 : 439495 : ResetLatch(MyLatch);
1032 : : }
1033 : :
1034 [ + + ]: 885185 : CHECK_FOR_INTERRUPTS();
1035 : :
504 tmunro@postgresql.or 1036 [ + + ]: 885181 : if (ConfigReloadPending)
1037 : : {
145 michael@paquier.xyz 1038 :GNC 222 : int io_max_workers_prev = io_max_workers;
1039 : 222 : int io_min_workers_prev = io_min_workers;
1040 : :
504 tmunro@postgresql.or 1041 :CBC 222 : ConfigReloadPending = false;
1042 : 222 : ProcessConfigFile(PGC_SIGHUP);
1043 : :
1044 : : /*
1045 : : * Emit a WARNING if io_min_workers > io_max_workers. If no bound
1046 : : * has changed, skip this to avoid too many log messages.
1047 : : */
145 michael@paquier.xyz 1048 [ + + ]:GNC 222 : if (io_min_workers_prev != io_min_workers ||
1049 [ - + ]: 178 : io_max_workers_prev != io_max_workers)
1050 : 44 : check_io_worker_gucs();
1051 : :
1052 : : /* If io_max_workers has been decreased, exit highest first. */
234 tmunro@postgresql.or 1053 [ - + ]:CBC 222 : if (MyIoWorkerId >= io_max_workers)
234 tmunro@postgresql.or 1054 :UBC 0 : break;
1055 : : }
1056 : : }
1057 : :
606 melanieplageman@gmai 1058 :CBC 1406 : error_context_stack = errcallback.previous;
620 andres@anarazel.de 1059 : 1406 : proc_exit(0);
1060 : : }
1061 : :
1062 : : bool
1063 : 101156 : pgaio_workers_enabled(void)
1064 : : {
1065 : 101156 : return io_method == IOMETHOD_WORKER;
1066 : : }
|