fix_getsnapshotdata.v2.patch
application/octet-stream
Filename: fix_getsnapshotdata.v2.patch
Type: application/octet-stream
Part: 0
Message:
Re: Not HOT enough
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: unified
Series: patch v2
| File | + | − |
|---|---|---|
| src/backend/access/heap/pruneheap.c | 8 | 1 |
| src/backend/storage/ipc/procarray.c | 8 | 0 |
diff --git a/src/backend/access/heap/pruneheap.c b/src/backend/access/heap/pruneheap.c
index 61f2ce4..44ed5a4 100644
--- a/src/backend/access/heap/pruneheap.c
+++ b/src/backend/access/heap/pruneheap.c
@@ -16,13 +16,13 @@
#include "access/heapam.h"
#include "access/transam.h"
+#include "catalog/catalog.h"
#include "miscadmin.h"
#include "pgstat.h"
#include "storage/bufmgr.h"
#include "utils/rel.h"
#include "utils/tqual.h"
-
/* Working data for heap_page_prune and subroutines */
typedef struct
{
@@ -91,6 +91,13 @@ heap_page_prune_opt(Relation relation, Buffer buffer, TransactionId OldestXmin)
return;
/*
+ * RecentGlobalXmin is valid only for non-shared relations, so we cannot
+ * prune shared relations while reading them with MVCC snapshots.
+ */
+ if (IsSharedRelation(relation->rd_id))
+ return;
+
+ /*
* We prune when a previous UPDATE failed to find enough space on the page
* for a new tuple version, or when free space falls below the relation's
* fill-factor target (but not less than 10%).
diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/procarray.c
index 1a48485..9b2eede 100644
--- a/src/backend/storage/ipc/procarray.c
+++ b/src/backend/storage/ipc/procarray.c
@@ -55,6 +55,7 @@
#include "storage/spin.h"
#include "utils/builtins.h"
#include "utils/snapmgr.h"
+#include "utils/tqual.h"
/* Our shared memory area */
@@ -1200,6 +1201,7 @@ GetSnapshotData(Snapshot snapshot)
int count = 0;
int subcount = 0;
bool suboverflowed = false;
+ bool allDbs = !IsMVCCSnapshot(snapshot);
Assert(snapshot != NULL);
@@ -1278,6 +1280,12 @@ GetSnapshotData(Snapshot snapshot)
if (proc->vacuumFlags & PROC_IN_VACUUM)
continue;
+ /* MVCC snapshots ignore other databases */
+ if (!allDbs &&
+ proc->databaseId != MyDatabaseId &&
+ proc->databaseId != 0) /* always include WalSender */
+ continue;
+
/* Update globalxmin to be the smallest valid xmin */
xid = proc->xmin; /* fetch just once */
if (TransactionIdIsNormal(xid) &&