Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Revert "Track statistics for spilling of changes from ReorderBuffer".
authorAmit Kapila <akapila@postgresql.org>
Mon, 13 Jul 2020 02:57:40 +0000 (08:27 +0530)
committerAmit Kapila <akapila@postgresql.org>
Mon, 13 Jul 2020 03:16:56 +0000 (08:46 +0530)
The stats with this commit was available only for WALSenders, however,
users might want to see for backends doing logical decoding via SQL API.
Then, users might want to reset and access these stats across server
restart which was not possible with the current patch.

List of commits reverted:

caa3c4242c   Don't call elog() while holding spinlock.
e641b2a995   Doc: Update the documentation for spilled transaction
statistics.
5883f5fe27   Fix unportable printf format introduced in commit 9290ad198.
9290ad198b   Track statistics for spilling of changes from ReorderBuffer.

Additionaly, remove the release notes entry for this feature.

Backpatch-through: 13, where it was introduced
Discussion: https://postgr.es/m/CA+fd4k5_pPAYRTDrO2PbtTOe0eHQpBvuqmCr8ic39uTNmR49Eg@mail.gmail.com

doc/src/sgml/monitoring.sgml
doc/src/sgml/release-13.sgml
src/backend/catalog/system_views.sql
src/backend/replication/logical/reorderbuffer.c
src/backend/replication/walsender.c
src/include/catalog/catversion.h
src/include/catalog/pg_proc.dat
src/include/replication/reorderbuffer.h
src/include/replication/walsender_private.h
src/test/regress/expected/rules.out

index 405c09c9497206387f32b782a74ea257eb449313..b5c0bd78ac8606ef73c42e01b8cc77d337dce81d 100644 (file)
@@ -2462,38 +2462,6 @@ SELECT pid, wait_event_type, wait_event FROM pg_stat_activity WHERE wait_event i
        Send time of last reply message received from standby server
       </para></entry>
      </row>
-
-     <row>
-      <entry role="catalog_table_entry"><para role="column_definition">
-       <structfield>spill_txns</structfield> <type>bigint</type>
-      </para>
-      <para>
-       Number of transactions spilled to disk after the memory used by
-       logical decoding exceeds <literal>logical_decoding_work_mem</literal>. The
-       counter gets incremented both for top-level transactions and
-       subtransactions.
-      </para></entry>
-     </row>
-
-     <row>
-      <entry role="catalog_table_entry"><para role="column_definition">
-       <structfield>spill_count</structfield> <type>bigint</type>
-      </para>
-      <para>
-       Number of times transactions were spilled to disk. Transactions
-       may get spilled repeatedly, and this counter gets incremented on every
-       such invocation.
-      </para></entry>
-     </row>
-
-     <row>
-      <entry role="catalog_table_entry"><para role="column_definition">
-       <structfield>spill_bytes</structfield> <type>bigint</type>
-      </para>
-      <para>
-       Amount of decoded transaction data spilled to disk.
-      </para></entry>
-     </row>
     </tbody>
    </tgroup>
   </table>
@@ -2518,12 +2486,6 @@ SELECT pid, wait_event_type, wait_event FROM pg_stat_activity WHERE wait_event i
    mechanism will simply display NULL lag.
   </para>
 
-  <para>
-   Tracking of spilled transactions works only for logical replication.  In
-   physical replication, the tracking mechanism will display 0 for spilled
-   statistics.
-  </para>
-
   <note>
    <para>
     The reported lag times are not predictions of how long it will take for
index 7395edb5ba5fd4b0c070440a7756b412c6a575e2..b893b7d6c3ffb07fba159b484a2395cd8c02215f 100644 (file)
@@ -983,20 +983,6 @@ Author: Alvaro Herrera <alvherre@alvh.no-ip.org>
 
       <listitem>
 <!--
-Author: Amit Kapila <akapila@postgresql.org>
-2019-11-21 [9290ad198] Track statistics for spilling of changes from ReorderBuf
--->
-
-       <para>
-        Add columns to the <link
-        linkend="monitoring-stats-dynamic-views-table"><structname>pg_stat_replication</structname></link>
-        system view to report how much logical decoding information has been
-        spilled to disk (Tomas Vondra)
-       </para>
-      </listitem>
-
-      <listitem>
-<!--
 Author: Robert Haas <rhaas@postgresql.org>
 2020-01-09 [ed10f32e3] Add pg_shmem_allocations view.
 -->
index d1177c6b57ea17b8903d7878db5ee7c28776cd75..76154a8d5f2aa07bef6349f651bf9fa34f8e1d54 100644 (file)
@@ -785,10 +785,7 @@ CREATE VIEW pg_stat_replication AS
             W.replay_lag,
             W.sync_priority,
             W.sync_state,
-            W.reply_time,
-            W.spill_txns,
-            W.spill_count,
-            W.spill_bytes
+            W.reply_time
     FROM pg_stat_get_activity(NULL) AS S
         JOIN pg_stat_get_wal_senders() AS W ON (S.pid = W.pid)
         LEFT JOIN pg_authid AS U ON (S.usesysid = U.oid);
index 7afa2271bd8d2a5f75f7e7424a9537d586f8813d..5251932669074a65828173985a48348a53b60b18 100644 (file)
@@ -317,10 +317,6 @@ ReorderBufferAllocate(void)
    buffer->outbufsize = 0;
    buffer->size = 0;
 
-   buffer->spillCount = 0;
-   buffer->spillTxns = 0;
-   buffer->spillBytes = 0;
-
    buffer->current_restart_decoding_lsn = InvalidXLogRecPtr;
 
    dlist_init(&buffer->toplevel_by_lsn);
@@ -2418,7 +2414,6 @@ ReorderBufferSerializeTXN(ReorderBuffer *rb, ReorderBufferTXN *txn)
    int         fd = -1;
    XLogSegNo   curOpenSegNo = 0;
    Size        spilled = 0;
-   Size        size = txn->size;
 
    elog(DEBUG2, "spill %u changes in XID %u to disk",
         (uint32) txn->nentries_mem, txn->xid);
@@ -2477,13 +2472,6 @@ ReorderBufferSerializeTXN(ReorderBuffer *rb, ReorderBufferTXN *txn)
        spilled++;
    }
 
-   /* update the statistics */
-   rb->spillCount += 1;
-   rb->spillBytes += size;
-
-   /* Don't consider already serialized transactions. */
-   rb->spillTxns += rbtxn_is_serialized(txn) ? 0 : 1;
-
    Assert(spilled == txn->nentries_mem);
    Assert(dlist_is_empty(&txn->changes));
    txn->nentries_mem = 0;
index e2477c47e0a164ecbeacaafd53a2807bb2b87fe2..136e9c6585c18cd61775ccc9fe3b93516d1ebaf4 100644 (file)
@@ -254,7 +254,6 @@ static bool TransactionIdInRecentPast(TransactionId xid, uint32 epoch);
 
 static void WalSndSegmentOpen(XLogReaderState *state, XLogSegNo nextSegNo,
                              TimeLineID *tli_p);
-static void UpdateSpillStats(LogicalDecodingContext *ctx);
 
 
 /* Initialize walsender process before entering the main command loop */
@@ -1348,8 +1347,7 @@ WalSndWriteData(LogicalDecodingContext *ctx, XLogRecPtr lsn, TransactionId xid,
 /*
  * LogicalDecodingContext 'update_progress' callback.
  *
- * Write the current position to the lag tracker (see XLogSendPhysical),
- * and update the spill statistics.
+ * Write the current position to the lag tracker (see XLogSendPhysical).
  */
 static void
 WalSndUpdateProgress(LogicalDecodingContext *ctx, XLogRecPtr lsn, TransactionId xid)
@@ -1368,11 +1366,6 @@ WalSndUpdateProgress(LogicalDecodingContext *ctx, XLogRecPtr lsn, TransactionId
 
    LagTrackerWrite(lsn, now);
    sendTime = now;
-
-   /*
-    * Update statistics about transactions that spilled to disk.
-    */
-   UpdateSpillStats(ctx);
 }
 
 /*
@@ -2418,9 +2411,6 @@ InitWalSenderSlot(void)
            walsnd->sync_standby_priority = 0;
            walsnd->latch = &MyProc->procLatch;
            walsnd->replyTime = 0;
-           walsnd->spillTxns = 0;
-           walsnd->spillCount = 0;
-           walsnd->spillBytes = 0;
            SpinLockRelease(&walsnd->mutex);
            /* don't need the lock anymore */
            MyWalSnd = (WalSnd *) walsnd;
@@ -3256,7 +3246,7 @@ offset_to_interval(TimeOffset offset)
 Datum
 pg_stat_get_wal_senders(PG_FUNCTION_ARGS)
 {
-#define PG_STAT_GET_WAL_SENDERS_COLS   15
+#define PG_STAT_GET_WAL_SENDERS_COLS   12
    ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo;
    TupleDesc   tupdesc;
    Tuplestorestate *tupstore;
@@ -3310,9 +3300,6 @@ pg_stat_get_wal_senders(PG_FUNCTION_ARGS)
        int         pid;
        WalSndState state;
        TimestampTz replyTime;
-       int64       spillTxns;
-       int64       spillCount;
-       int64       spillBytes;
        bool        is_sync_standby;
        Datum       values[PG_STAT_GET_WAL_SENDERS_COLS];
        bool        nulls[PG_STAT_GET_WAL_SENDERS_COLS];
@@ -3336,9 +3323,6 @@ pg_stat_get_wal_senders(PG_FUNCTION_ARGS)
        applyLag = walsnd->applyLag;
        priority = walsnd->sync_standby_priority;
        replyTime = walsnd->replyTime;
-       spillTxns = walsnd->spillTxns;
-       spillCount = walsnd->spillCount;
-       spillBytes = walsnd->spillBytes;
        SpinLockRelease(&walsnd->mutex);
 
        /*
@@ -3436,11 +3420,6 @@ pg_stat_get_wal_senders(PG_FUNCTION_ARGS)
                nulls[11] = true;
            else
                values[11] = TimestampTzGetDatum(replyTime);
-
-           /* spill to disk */
-           values[12] = Int64GetDatum(spillTxns);
-           values[13] = Int64GetDatum(spillCount);
-           values[14] = Int64GetDatum(spillBytes);
        }
 
        tuplestore_putvalues(tupstore, tupdesc, values, nulls);
@@ -3677,21 +3656,3 @@ LagTrackerRead(int head, XLogRecPtr lsn, TimestampTz now)
    Assert(time != 0);
    return now - time;
 }
-
-static void
-UpdateSpillStats(LogicalDecodingContext *ctx)
-{
-   ReorderBuffer *rb = ctx->reorder;
-
-   elog(DEBUG2, "UpdateSpillStats: updating stats %p %lld %lld %lld",
-        rb,
-        (long long) rb->spillTxns,
-        (long long) rb->spillCount,
-        (long long) rb->spillBytes);
-
-   SpinLockAcquire(&MyWalSnd->mutex);
-   MyWalSnd->spillTxns = rb->spillTxns;
-   MyWalSnd->spillCount = rb->spillCount;
-   MyWalSnd->spillBytes = rb->spillBytes;
-   SpinLockRelease(&MyWalSnd->mutex);
-}
index 1b35510d46dc03a006dd24b028e2beaa6a6dbf82..6b3aa7c0063e28eef06bd76701cab8453e41e540 100644 (file)
@@ -53,6 +53,6 @@
  */
 
 /*                         yyyymmddN */
-#define CATALOG_VERSION_NO 202007071
+#define CATALOG_VERSION_NO 202007131
 
 #endif
index 46619197739e81f0b94a528cbc63222af45e9cee..298ff4c4d1d6f7d9acf14596af18ab51aae556b7 100644 (file)
   proname => 'pg_stat_get_wal_senders', prorows => '10', proisstrict => 'f',
   proretset => 't', provolatile => 's', proparallel => 'r',
   prorettype => 'record', proargtypes => '',
-  proallargtypes => '{int4,text,pg_lsn,pg_lsn,pg_lsn,pg_lsn,interval,interval,interval,int4,text,timestamptz,int8,int8,int8}',
-  proargmodes => '{o,o,o,o,o,o,o,o,o,o,o,o,o,o,o}',
-  proargnames => '{pid,state,sent_lsn,write_lsn,flush_lsn,replay_lsn,write_lag,flush_lag,replay_lag,sync_priority,sync_state,reply_time,spill_txns,spill_count,spill_bytes}',
+  proallargtypes => '{int4,text,pg_lsn,pg_lsn,pg_lsn,pg_lsn,interval,interval,interval,int4,text,timestamptz}',
+  proargmodes => '{o,o,o,o,o,o,o,o,o,o,o,o}',
+  proargnames => '{pid,state,sent_lsn,write_lsn,flush_lsn,replay_lsn,write_lag,flush_lag,replay_lag,sync_priority,sync_state,reply_time}',
   prosrc => 'pg_stat_get_wal_senders' },
 { oid => '3317', descr => 'statistics: information about WAL receiver',
   proname => 'pg_stat_get_wal_receiver', proisstrict => 'f', provolatile => 's',
index 626ecf4dc96aabc6ef3891e3bebcf3980192770d..019bd382de9b9cecfbd3ccfa2e6378874cd9925f 100644 (file)
@@ -413,17 +413,6 @@ struct ReorderBuffer
 
    /* memory accounting */
    Size        size;
-
-   /*
-    * Statistics about transactions spilled to disk.
-    *
-    * A single transaction may be spilled repeatedly, which is why we keep
-    * two different counters. For spilling, the transaction counter includes
-    * both toplevel transactions and subtransactions.
-    */
-   int64       spillCount;     /* spill-to-disk invocation counter */
-   int64       spillTxns;      /* number of transactions spilled to disk  */
-   int64       spillBytes;     /* amount of data spilled to disk */
 };
 
 
index 734acec2a41977276f2327c5a56f2cde9559ca27..509856c057ec3f2c29c9b9d41b9ffbe7ffd134b0 100644 (file)
@@ -78,11 +78,6 @@ typedef struct WalSnd
     * Timestamp of the last message received from standby.
     */
    TimestampTz replyTime;
-
-   /* Statistics for transactions spilled to disk. */
-   int64       spillTxns;
-   int64       spillCount;
-   int64       spillBytes;
 } WalSnd;
 
 extern WalSnd *MyWalSnd;
index 93bb2159ca892b6fb2e85b0e3831f3abf8cd5d7e..fa436f2caa0a17108923c0e2cc4e56f43342d498 100644 (file)
@@ -2002,12 +2002,9 @@ pg_stat_replication| SELECT s.pid,
     w.replay_lag,
     w.sync_priority,
     w.sync_state,
-    w.reply_time,
-    w.spill_txns,
-    w.spill_count,
-    w.spill_bytes
+    w.reply_time
    FROM ((pg_stat_get_activity(NULL::integer) s(datid, pid, usesysid, application_name, state, query, wait_event_type, wait_event, xact_start, query_start, backend_start, state_change, client_addr, client_hostname, client_port, backend_xid, backend_xmin, backend_type, ssl, sslversion, sslcipher, sslbits, sslcompression, ssl_client_dn, ssl_client_serial, ssl_issuer_dn, gss_auth, gss_princ, gss_enc, leader_pid)
-     JOIN pg_stat_get_wal_senders() w(pid, state, sent_lsn, write_lsn, flush_lsn, replay_lsn, write_lag, flush_lag, replay_lag, sync_priority, sync_state, reply_time, spill_txns, spill_count, spill_bytes) ON ((s.pid = w.pid)))
+     JOIN pg_stat_get_wal_senders() w(pid, state, sent_lsn, write_lsn, flush_lsn, replay_lsn, write_lag, flush_lag, replay_lag, sync_priority, sync_state, reply_time) ON ((s.pid = w.pid)))
      LEFT JOIN pg_authid u ON ((s.usesysid = u.oid)));
 pg_stat_slru| SELECT s.name,
     s.blks_zeroed,