]> granicus.if.org Git - postgresql/blobdiff - src/backend/postmaster/pgstat.c
Avoid counting transaction stats for parallel worker cooperating
[postgresql] / src / backend / postmaster / pgstat.c
index 2a8472b91aee2453a8c34ac916ed93743dcbf62a..7c0b24a16fa6b15dcae035677ea2e9ec3154f84e 100644 (file)
@@ -2089,18 +2089,22 @@ pgstat_update_heap_dead_tuples(Relation rel, int delta)
  * ----------
  */
 void
-AtEOXact_PgStat(bool isCommit)
+AtEOXact_PgStat(bool isCommit, bool parallel)
 {
        PgStat_SubXactStatus *xact_state;
 
-       /*
-        * Count transaction commit or abort.  (We use counters, not just bools,
-        * in case the reporting message isn't sent right away.)
-        */
-       if (isCommit)
-               pgStatXactCommit++;
-       else
-               pgStatXactRollback++;
+       /* Don't count parallel worker transaction stats */
+       if (!parallel)
+       {
+               /*
+                * Count transaction commit or abort.  (We use counters, not just
+                * bools, in case the reporting message isn't sent right away.)
+                */
+               if (isCommit)
+                       pgStatXactCommit++;
+               else
+                       pgStatXactRollback++;
+       }
 
        /*
         * Transfer transactional insert/update counts into the base tabstat
@@ -2634,6 +2638,9 @@ static Size BackendActivityBufferSize = 0;
 #ifdef USE_SSL
 static PgBackendSSLStatus *BackendSslStatusBuffer = NULL;
 #endif
+#ifdef ENABLE_GSS
+static PgBackendGSSStatus *BackendGssStatusBuffer = NULL;
+#endif
 
 
 /*
@@ -2766,6 +2773,28 @@ CreateSharedBackendStatus(void)
                }
        }
 #endif
+
+#ifdef ENABLE_GSS
+       /* Create or attach to the shared GSSAPI status buffer */
+       size = mul_size(sizeof(PgBackendGSSStatus), NumBackendStatSlots);
+       BackendGssStatusBuffer = (PgBackendGSSStatus *)
+               ShmemInitStruct("Backend GSS Status Buffer", size, &found);
+
+       if (!found)
+       {
+               PgBackendGSSStatus *ptr;
+
+               MemSet(BackendGssStatusBuffer, 0, size);
+
+               /* Initialize st_gssstatus pointers. */
+               ptr = BackendGssStatusBuffer;
+               for (i = 0; i < NumBackendStatSlots; i++)
+               {
+                       BackendStatusArray[i].st_gssstatus = ptr;
+                       ptr++;
+               }
+       }
+#endif
 }
 
 
@@ -2953,6 +2982,24 @@ pgstat_bestart(void)
 #else
        beentry->st_ssl = false;
 #endif
+
+#ifdef ENABLE_GSS
+       if (MyProcPort && MyProcPort->gss != NULL)
+       {
+               beentry->st_gss = true;
+               beentry->st_gssstatus->gss_auth = be_gssapi_get_auth(MyProcPort);
+               beentry->st_gssstatus->gss_enc = be_gssapi_get_enc(MyProcPort);
+
+               if (beentry->st_gssstatus->gss_auth)
+                       strlcpy(beentry->st_gssstatus->gss_princ, be_gssapi_get_princ(MyProcPort), NAMEDATALEN);
+       }
+       else
+       {
+               beentry->st_gss = false;
+       }
+#else
+       beentry->st_gss = false;
+#endif
        beentry->st_state = STATE_UNDEFINED;
        beentry->st_appname[0] = '\0';
        beentry->st_activity_raw[0] = '\0';
@@ -3595,6 +3642,9 @@ pgstat_get_wait_client(WaitEventClient w)
                case WAIT_EVENT_WAL_SENDER_WRITE_DATA:
                        event_name = "WalSenderWriteData";
                        break;
+               case WAIT_EVENT_GSS_OPEN_SERVER:
+                       event_name = "GSSOpenServer";
+                       break;
                        /* no default case, so that compiler will warn */
        }