Skip to content

Commit 7508169

Browse files
Add ParallelSlotSetIdle().
This commit refactors the code for marking a ParallelSlot as idle to a new static inline function. This can be used to mark a slot that was obtained via ParallelSlotGetIdle() but that we don't intend to actually use for a query as idle again. This is preparatory work for a follow-up commit that will add a --dry-run option to vacuumdb. Reviewed-by: Corey Huinker <corey.huinker@gmail.com> Reviewed-by: Kirill Reshke <reshkekirill@gmail.com> Reviewed-by: Chao Li <li.evan.chao@gmail.com Discussion: https://postgr.es/m/CADkLM%3DckHkX7Of5SrK7g0LokPUwJ%3Dkk8JU1GXGF5pZ1eBVr0%3DQ%40mail.gmail.com
1 parent cf1450e commit 7508169

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/fe_utils/parallel_slot.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,7 @@ wait_on_slots(ParallelSlotArray *sa)
269269
else
270270
{
271271
/* This connection has become idle */
272-
sa->slots[i].inUse = false;
273-
ParallelSlotClearHandler(&sa->slots[i]);
272+
ParallelSlotSetIdle(&sa->slots[i]);
274273
break;
275274
}
276275
}
@@ -509,8 +508,7 @@ ParallelSlotsWaitCompletion(ParallelSlotArray *sa)
509508
if (!consumeQueryResult(&sa->slots[i]))
510509
return false;
511510
/* Mark connection as idle */
512-
sa->slots[i].inUse = false;
513-
ParallelSlotClearHandler(&sa->slots[i]);
511+
ParallelSlotSetIdle(&sa->slots[i]);
514512
}
515513

516514
return true;

src/include/fe_utils/parallel_slot.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ ParallelSlotClearHandler(ParallelSlot *slot)
5858
slot->handler_context = NULL;
5959
}
6060

61+
static inline void
62+
ParallelSlotSetIdle(ParallelSlot *slot)
63+
{
64+
slot->inUse = false;
65+
ParallelSlotClearHandler(slot);
66+
}
67+
6168
extern ParallelSlot *ParallelSlotsGetIdle(ParallelSlotArray *sa,
6269
const char *dbname);
6370

0 commit comments

Comments
 (0)