pgstat-coalesce-v2.patch
text/x-patch
Filename: pgstat-coalesce-v2.patch
Type: text/x-patch
Part: 0
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/postmaster/pgstat.c | 14 | 1 |
diff --git a/src/backend/postmaster/pgstat.c b/src/backend/postmaster/pgstat.c
index 14afef6..e750d46 100644
--- a/src/backend/postmaster/pgstat.c
+++ b/src/backend/postmaster/pgstat.c
@@ -4836,6 +4836,20 @@ pgstat_recv_inquiry(PgStat_MsgInquiry *msg, int len)
}
/*
+ * Ignore requests that are already resolved by the last write.
+ *
+ * We discard the queue of requests at the end of pgstat_write_statsfiles(),
+ * so the requests already waiting on the UDP socket at that moment can't
+ * be discarded in the previous loop.
+ *
+ * XXX Maybe this should also care about the clock skew, just like the
+ * block a few lines down.
+ */
+ dbentry = pgstat_get_db_entry(msg->databaseid, false);
+ if ((dbentry != NULL) && (msg->cutoff_time <= dbentry->stats_timestamp))
+ return;
+
+ /*
* There's no request for this DB yet, so create one.
*/
newreq = palloc(sizeof(DBWriteRequest));
@@ -4852,7 +4866,6 @@ pgstat_recv_inquiry(PgStat_MsgInquiry *msg, int len)
* retreat in the system clock reading could otherwise cause us to neglect
* to update the stats file for a long time.
*/
- dbentry = pgstat_get_db_entry(msg->databaseid, false);
if ((dbentry != NULL) && (msg->clock_time < dbentry->stats_timestamp))
{
TimestampTz cur_ts = GetCurrentTimestamp();