v2-fix-parallel-vacuum.patch
text/x-patch
Filename: v2-fix-parallel-vacuum.patch
Type: text/x-patch
Part: 0
Patch
Format: unified
Series: patch v2
| File | + | − |
|---|---|---|
| src/backend/access/heap/vacuumlazy.c | 1 | 3 |
| src/backend/commands/vacuumparallel.c | 7 | 10 |
diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c
index 793bd33cb4..667b1c54e1 100644
--- a/src/backend/access/heap/vacuumlazy.c
+++ b/src/backend/access/heap/vacuumlazy.c
@@ -2917,8 +2917,6 @@ dead_items_add(LVRelState *vacrel, BlockNumber blkno, OffsetNumber *offsets,
static void
dead_items_reset(LVRelState *vacrel)
{
- TidStore *dead_items = vacrel->dead_items;
-
if (ParallelVacuumIsActive(vacrel))
{
parallel_vacuum_reset_dead_items(vacrel->pvs);
@@ -2926,7 +2924,7 @@ dead_items_reset(LVRelState *vacrel)
}
/* Recreate the tidstore with the same max_bytes limitation */
- TidStoreDestroy(dead_items);
+ TidStoreDestroy(vacrel->dead_items);
vacrel->dead_items = TidStoreCreateLocal(vacrel->dead_items_info->max_bytes, true);
/* Reset the counter */
diff --git a/src/backend/commands/vacuumparallel.c b/src/backend/commands/vacuumparallel.c
index 4fd6574e12..4b0669b1e6 100644
--- a/src/backend/commands/vacuumparallel.c
+++ b/src/backend/commands/vacuumparallel.c
@@ -247,7 +247,6 @@ parallel_vacuum_init(Relation rel, Relation *indrels, int nindexes,
ParallelVacuumState *pvs;
ParallelContext *pcxt;
PVShared *shared;
- TidStore *dead_items;
PVIndStats *indstats;
BufferUsage *buffer_usage;
WalUsage *wal_usage;
@@ -378,11 +377,10 @@ parallel_vacuum_init(Relation rel, Relation *indrels, int nindexes,
shared->dead_items_info.max_bytes = vac_work_mem * 1024L;
/* Prepare DSA space for dead items */
- dead_items = TidStoreCreateShared(shared->dead_items_info.max_bytes,
- LWTRANCHE_PARALLEL_VACUUM_DSA);
- pvs->dead_items = dead_items;
- shared->dead_items_handle = TidStoreGetHandle(dead_items);
- shared->dead_items_dsa_handle = dsa_get_handle(TidStoreGetDSA(dead_items));
+ pvs->dead_items = TidStoreCreateShared(shared->dead_items_info.max_bytes,
+ LWTRANCHE_PARALLEL_VACUUM_DSA);
+ shared->dead_items_handle = TidStoreGetHandle(pvs->dead_items);
+ shared->dead_items_dsa_handle = dsa_get_handle(TidStoreGetDSA(pvs->dead_items));
/* Use the same buffer size for all workers */
shared->ring_nbuffers = GetAccessStrategyBufferCount(bstrategy);
@@ -474,7 +472,6 @@ parallel_vacuum_get_dead_items(ParallelVacuumState *pvs, VacDeadItemsInfo **dead
void
parallel_vacuum_reset_dead_items(ParallelVacuumState *pvs)
{
- TidStore *dead_items = pvs->dead_items;
VacDeadItemsInfo *dead_items_info = &(pvs->shared->dead_items_info);
/*
@@ -482,13 +479,13 @@ parallel_vacuum_reset_dead_items(ParallelVacuumState *pvs)
* operating system. Then we recreate the tidstore with the same max_bytes
* limitation we just used.
*/
- TidStoreDestroy(dead_items);
+ TidStoreDestroy(pvs->dead_items);
pvs->dead_items = TidStoreCreateShared(dead_items_info->max_bytes,
LWTRANCHE_PARALLEL_VACUUM_DSA);
/* Update the DSA pointer for dead_items to the new one */
- pvs->shared->dead_items_dsa_handle = dsa_get_handle(TidStoreGetDSA(dead_items));
- pvs->shared->dead_items_handle = TidStoreGetHandle(dead_items);
+ pvs->shared->dead_items_dsa_handle = dsa_get_handle(TidStoreGetDSA(pvs->dead_items));
+ pvs->shared->dead_items_handle = TidStoreGetHandle(pvs->dead_items);
/* Reset the counter */
dead_items_info->num_items = 0;