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

* [PATCH v3 1/3] Ignore parallel workers in pg_stat_statements.
@ 2021-04-08 05:59 Julien Rouhaud <[email protected]>
  0 siblings, 0 replies; 3+ 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


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



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

* Re: pg_upgrade instructions involving "rsync --size-only" might lead to standby corruption?
@ 2023-06-30 20:16 Robert Haas <[email protected]>
  2023-07-01 09:02 ` Re: pg_upgrade instructions involving "rsync --size-only" might lead to standby corruption? Andrey M. Borodin <[email protected]>
  0 siblings, 1 reply; 3+ messages in thread

From: Robert Haas @ 2023-06-30 20:16 UTC (permalink / raw)
  To: Bruce Momjian <[email protected]>; +Cc: Nikolay Samokhvalov <[email protected]>; pgsql-hackers; Stephen Frost <[email protected]>

On Fri, Jun 30, 2023 at 1:41 PM Bruce Momjian <[email protected]> wrote:
> I think --size-only was chosen only because it is the minimal comparison
> option.

I think it's worse than that. I think that the procedure relies on
using the --size-only option to intentionally trick rsync into
thinking that files are identical when they're not.

Say we have a file like base/23246/78901 on the primary. Unless
wal_log_hints=on, the standby version is very likely different, but
only in ways that don't matter to WAL replay. So the procedure aims to
trick rsync into hard-linking the version of that file that exists on
the standby in the old cluster into the new cluster on the standby,
instead of copying the slightly-different version from the master,
thus making the upgrade very fast. If rsync actually checksummed the
files, it would realize that they're different and copy the file from
the original primary, which the person who wrote this procedure does
not want.

That's kind of a crazy thing for us to be documenting. I think we
really ought to consider removing from this documentation. If somebody
wants to write a reliable tool for this to ship as part of PostgreSQL,
well and good. But this procedure has no real sanity checks and is
based on very fragile assumptions. That doesn't seem suitable for
end-user use.

I'm not quite clear on how Nikolay got into trouble here. I don't
think I understand under exactly what conditions the procedure is
reliable and under what conditions it isn't. But there is no way in
heck I would ever advise anyone to use this procedure on a database
they actually care about. This is a great party trick or something to
show off in a lightning talk at PGCon, not something you ought to be
doing with valuable data that you actually care about.

-- 
Robert Haas
EDB: http://www.enterprisedb.com






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

* Re: pg_upgrade instructions involving "rsync --size-only" might lead to standby corruption?
  2023-06-30 20:16 Re: pg_upgrade instructions involving "rsync --size-only" might lead to standby corruption? Robert Haas <[email protected]>
@ 2023-07-01 09:02 ` Andrey M. Borodin <[email protected]>
  0 siblings, 0 replies; 3+ messages in thread

From: Andrey M. Borodin @ 2023-07-01 09:02 UTC (permalink / raw)
  To: Robert Haas <[email protected]>; +Cc: Bruce Momjian <[email protected]>; Nikolay Samokhvalov <[email protected]>; pgsql-hackers; Stephen Frost <[email protected]>

Fast upgrade of highly available cluster is a vital part of being industry-acceptable solution for any data management system. Because the cluster is required to be highly available.

Without this documented technique upgrade of 1Tb cluster would last many hours, not seconds.
There are industry concerns about scalability beyond tens of terabytes per cluster, but such downtime would significantly lower that boundary.

> On 1 Jul 2023, at 01:16, Robert Haas <[email protected]> wrote:
> 
>  If somebody
> wants to write a reliable tool for this to ship as part of PostgreSQL,
> well and good.

IMV that's a good idea. We could teach pg_upgrade or some new tool to do that reliably. The tricky part is that the tool must stop-start standby remotely...


Best regards, Andrey Borodin.

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


end of thread, other threads:[~2023-07-01 09:02 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-04-08 05:59 [PATCH v3 1/3] Ignore parallel workers in pg_stat_statements. Julien Rouhaud <[email protected]>
2023-06-30 20:16 Re: pg_upgrade instructions involving "rsync --size-only" might lead to standby corruption? Robert Haas <[email protected]>
2023-07-01 09:02 ` Re: pg_upgrade instructions involving "rsync --size-only" might lead to standby corruption? Andrey M. Borodin <[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