public inbox for [email protected]  
help / color / mirror / Atom feed
[PATCH 1/4] demote: setter functions for LocalXLogInsert local variable
5+ messages / 4 participants
[nested] [flat]

* [PATCH 1/4] demote: setter functions for LocalXLogInsert local variable
@ 2020-07-31 08:58 Jehan-Guillaume de Rorthais <[email protected]>
  0 siblings, 0 replies; 5+ messages in thread

From: Jehan-Guillaume de Rorthais @ 2020-07-31 08:58 UTC (permalink / raw)

Adds functions extern LocalSetXLogInsertNotAllowed() and
LocalSetXLogInsertCheckRecovery() to set the local variable
LocalXLogInsert respectively to 0 and -1.

These functions are declared as extern for future need in
the demote patch.

Function LocalSetXLogInsertAllowed() already exists and
declared as static as it is not needed outside of xlog.h.
---
 src/backend/access/transam/xlog.c | 27 +++++++++++++++++++++++----
 src/include/access/xlog.h         |  2 ++
 2 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 09c01ed4ae..c0d79f192c 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -7711,7 +7711,7 @@ StartupXLOG(void)
 	Insert->fullPageWrites = lastFullPageWrites;
 	LocalSetXLogInsertAllowed();
 	UpdateFullPageWrites();
-	LocalXLogInsertAllowed = -1;
+	LocalSetXLogInsertCheckRecovery();
 
 	if (InRecovery)
 	{
@@ -8219,6 +8219,25 @@ LocalSetXLogInsertAllowed(void)
 	InitXLOGAccess();
 }
 
+/*
+ * Make XLogInsertAllowed() return false in the current process only.
+ */
+void
+LocalSetXLogInsertNotAllowed(void)
+{
+	LocalXLogInsertAllowed = 0;
+}
+
+/*
+ * Make XLogInsertCheckRecovery() return false in the current process only.
+ */
+void
+LocalSetXLogInsertCheckRecovery(void)
+{
+	LocalXLogInsertAllowed = -1;
+}
+
+
 /*
  * Subroutine to try to fetch and validate a prior checkpoint record.
  *
@@ -9004,9 +9023,9 @@ CreateCheckPoint(int flags)
 	if (shutdown)
 	{
 		if (flags & CHECKPOINT_END_OF_RECOVERY)
-			LocalXLogInsertAllowed = -1;	/* return to "check" state */
+			LocalSetXLogInsertCheckRecovery(); /* return to "check" state */
 		else
-			LocalXLogInsertAllowed = 0; /* never again write WAL */
+			LocalSetXLogInsertNotAllowed(); /* never again write WAL */
 	}
 
 	/*
@@ -9159,7 +9178,7 @@ CreateEndOfRecoveryRecord(void)
 
 	END_CRIT_SECTION();
 
-	LocalXLogInsertAllowed = -1;	/* return to "check" state */
+	LocalSetXLogInsertCheckRecovery();	/* return to "check" state */
 }
 
 /*
diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h
index 221af87e71..8c9cadc6da 100644
--- a/src/include/access/xlog.h
+++ b/src/include/access/xlog.h
@@ -306,6 +306,8 @@ extern RecoveryState GetRecoveryState(void);
 extern bool HotStandbyActive(void);
 extern bool HotStandbyActiveInReplay(void);
 extern bool XLogInsertAllowed(void);
+extern void LocalSetXLogInsertNotAllowed(void);
+extern void LocalSetXLogInsertCheckRecovery(void);
 extern void GetXLogReceiptTime(TimestampTz *rtime, bool *fromStream);
 extern XLogRecPtr GetXLogReplayRecPtr(TimeLineID *replayTLI);
 extern XLogRecPtr GetXLogInsertRecPtr(void);
-- 
2.20.1


--MP_/6xG3U2Dzv0UR=.BCNK7fiL6
Content-Type: text/x-patch
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename=v5-0002-demote-support-demoting-instance-from-production-to-.patch



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

* First draft of back-branch release notes is done
@ 2023-02-03 19:32 Tom Lane <[email protected]>
  2023-02-05 12:10 ` Re: First draft of back-branch release notes is done Alvaro Herrera <[email protected]>
  2023-02-08 22:08 ` Re: First draft of back-branch release notes is done Justin Pryzby <[email protected]>
  0 siblings, 2 replies; 5+ messages in thread

From: Tom Lane @ 2023-02-03 19:32 UTC (permalink / raw)
  To: [email protected]

... at

https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=f282b026787da69d88a35404cf62f1cc2...

As usual, please send corrections/comments by Sunday.

			regards, tom lane






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

* Re: First draft of back-branch release notes is done
  2023-02-03 19:32 First draft of back-branch release notes is done Tom Lane <[email protected]>
@ 2023-02-05 12:10 ` Alvaro Herrera <[email protected]>
  2023-02-05 19:57   ` Re: First draft of back-branch release notes is done Tom Lane <[email protected]>
  1 sibling, 1 reply; 5+ messages in thread

From: Alvaro Herrera @ 2023-02-05 12:10 UTC (permalink / raw)
  To: Tom Lane <[email protected]>; +Cc: [email protected]

On 2023-Feb-03, Tom Lane wrote:

> ... at
> 
> https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=f282b026787da69d88a35404cf62f1cc2...
> 
> As usual, please send corrections/comments by Sunday.

      Fix edge-case data corruption in shared tuplestores (Dmitry Astapov)

      If the final chunk of a large tuple being written out to disk was
      exactly 32760 bytes, it would be corrupted due to a fencepost bug.
      This is a hazard for parallelized plans that require a tuplestore,
      such as parallel hash join.  The query would typically fail later
      with corrupted-data symptoms.

I think this sounds really scary, because people are going to think that
their stored data can get corrupted -- they don't necessarily know what
a "shared tuplestore" is.  Maybe "Avoid query failures in parallel hash
joins" as headline?

-- 
Álvaro Herrera        Breisgau, Deutschland  —  https://www.EnterpriseDB.com/
"The Gord often wonders why people threaten never to come back after they've
been told never to return" (www.actsofgord.com)






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

* Re: First draft of back-branch release notes is done
  2023-02-03 19:32 First draft of back-branch release notes is done Tom Lane <[email protected]>
  2023-02-05 12:10 ` Re: First draft of back-branch release notes is done Alvaro Herrera <[email protected]>
@ 2023-02-05 19:57   ` Tom Lane <[email protected]>
  0 siblings, 0 replies; 5+ messages in thread

From: Tom Lane @ 2023-02-05 19:57 UTC (permalink / raw)
  To: Alvaro Herrera <[email protected]>; +Cc: [email protected]

Alvaro Herrera <[email protected]> writes:
> On 2023-Feb-03, Tom Lane wrote:
>>       Fix edge-case data corruption in shared tuplestores (Dmitry Astapov)

> I think this sounds really scary, because people are going to think that
> their stored data can get corrupted -- they don't necessarily know what
> a "shared tuplestore" is.  Maybe "Avoid query failures in parallel hash
> joins" as headline?

Hmmm ... are we sure it *can't* lead to corruption of stored data,
if this happens during an INSERT or UPDATE plan?  I'll grant that
such a case seems pretty unlikely though, as the bogus data
retrieved from the tuplestore would have to not cause a failure
within the query before it can get written out.

Also, aren't shared tuplestores used in more places than just
parallel hash join?  I mentioned that as an example, not an
exhaustive list of trouble spots.

			regards, tom lane






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

* Re: First draft of back-branch release notes is done
  2023-02-03 19:32 First draft of back-branch release notes is done Tom Lane <[email protected]>
@ 2023-02-08 22:08 ` Justin Pryzby <[email protected]>
  1 sibling, 0 replies; 5+ messages in thread

From: Justin Pryzby @ 2023-02-08 22:08 UTC (permalink / raw)
  To: Tom Lane <[email protected]>; +Cc: [email protected]

On Fri, Feb 03, 2023 at 02:32:39PM -0500, Tom Lane wrote:
> ... at
> 
> https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=f282b026787da69d88a35404cf62f1cc2...
> 
> As usual, please send corrections/comments by Sunday.

It's of no concern, but I was curious why this one wasn't included:

commit 72aea955d49712a17c08748aa9abcbcf98c32fc5
Author: Thomas Munro <[email protected]>
Date:   Fri Jan 6 16:38:46 2023 +1300

    Fix pg_truncate() on Windows.
    
    Commit 57faaf376 added pg_truncate(const char *path, off_t length), but
    "length" was ignored under WIN32 and the file was unconditionally
    truncated to 0.
    
    There was no live bug, since the only caller passes 0.
    
    Fix, and back-patch to 14 where the function arrived.






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


end of thread, other threads:[~2023-02-08 22:08 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-07-31 08:58 [PATCH 1/4] demote: setter functions for LocalXLogInsert local variable Jehan-Guillaume de Rorthais <[email protected]>
2023-02-03 19:32 First draft of back-branch release notes is done Tom Lane <[email protected]>
2023-02-05 12:10 ` Re: First draft of back-branch release notes is done Alvaro Herrera <[email protected]>
2023-02-05 19:57   ` Re: First draft of back-branch release notes is done Tom Lane <[email protected]>
2023-02-08 22:08 ` Re: First draft of back-branch release notes is done Justin Pryzby <[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