public inbox for [email protected]  
help / color / mirror / Atom feed
[PATCH v4 1/3] Ignore parallel workers in pg_stat_statements.
2+ messages / 2 participants
[nested] [flat]

* [PATCH v4 1/3] Ignore parallel workers in pg_stat_statements.
@ 2021-04-08 05:59  Julien Rouhaud <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: Julien Rouhaud @ 2021-04-08 05:59 UTC (permalink / raw)

Oversight in 4f0b0966c8 which exposed queryid in parallel workers.  Counters
are aggregated by the main backend process so parallel workers would report
duplicated activity, and could also report activity for the wrong entry as they
are only aware of the top level queryid.

Author: Julien Rouhaud
Reported-by: Andres Freund
Discussion: https://postgr.es/m/[email protected]
---
 contrib/pg_stat_statements/pg_stat_statements.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/contrib/pg_stat_statements/pg_stat_statements.c b/contrib/pg_stat_statements/pg_stat_statements.c
index fc2677643b..dbd0d41d88 100644
--- a/contrib/pg_stat_statements/pg_stat_statements.c
+++ b/contrib/pg_stat_statements/pg_stat_statements.c
@@ -47,6 +47,7 @@
 #include <sys/stat.h>
 #include <unistd.h>
 
+#include "access/parallel.h"
 #include "catalog/pg_authid.h"
 #include "common/hashfn.h"
 #include "executor/instrument.h"
@@ -278,8 +279,9 @@ static bool pgss_save;			/* whether to save stats across shutdown */
 
 
 #define pgss_enabled(level) \
+	(!IsParallelWorker() && \
 	(pgss_track == PGSS_TRACK_ALL || \
-	(pgss_track == PGSS_TRACK_TOP && (level) == 0))
+	(pgss_track == PGSS_TRACK_TOP && (level) == 0)))
 
 #define record_gc_qtexts() \
 	do { \
-- 
2.30.1


--3dscpv5qh7n262k2
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v4-0002-Fix-thinko-in-pg_stat_get_activity-when-retrievin.patch"



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: libpq minor TOCTOU violation
@ 2024-08-16 04:48  Peter Eisentraut <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: Peter Eisentraut @ 2024-08-16 04:48 UTC (permalink / raw)
  To: Andreas Karlsson <[email protected]>; pgsql-hackers

On 14.08.24 03:12, Andreas Karlsson wrote:
> On 8/10/24 9:10 AM, Peter Eisentraut wrote:
>> Thoughts?
> 
> I like it. Not because of the security issue but mainly because it is 
> more correct to do it this way. Plus the old code running stat() on 
> Windows also made little sense.
> 
> I think this simple fix can be committed.

committed







^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2024-08-16 04:48 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-04-08 05:59 [PATCH v4 1/3] Ignore parallel workers in pg_stat_statements. Julien Rouhaud <[email protected]>
2024-08-16 04:48 Re: libpq minor TOCTOU violation Peter Eisentraut <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox