Re: Hot Standby (v9d) - Mailing list pgsql-hackers

From Heikki Linnakangas
Subject Re: Hot Standby (v9d)
Date
Msg-id 4979D0D9.6010904@enterprisedb.com
Whole thread Raw
In response to Hot Standby (v9d)  (Simon Riggs <simon@2ndQuadrant.com>)
Responses Re: Hot Standby (v9d)  (Simon Riggs <simon@2ndQuadrant.com>)
Re: Hot Standby (v9d)  (Simon Riggs <simon@2ndQuadrant.com>)
List pgsql-hackers
Simon Riggs wrote:
> * Put corrected version into GIT
> * Produce outstanding items as patch-on-patch via GIT

I've applied the hot standby patch and recovery infra v9 patch to
branches in my git repository, and pushed those to:

git://git.postgresql.org/git/~hlinnaka/pgsql.git

You can clone that to get started.

I've set those branches up so that the hot standby branch is branched
off from the recovery infra branch. I'd like to keep the two separate,
as the recovery infra patch is useful on it's own, and can be reviewed
separately.

As a teaser, I made a couple of minor changes after importing your
patches. For the sake of the archives, I've also included those changes
as patches here.

--
   Heikki Linnakangas
   EnterpriseDB   http://www.enterprisedb.com
>From 6d583356063c9d3c8d0e69233a40065bc5d7bde1 Mon Sep 17 00:00:00 2001
From: Heikki Linnakangas <heikki@enterprisedb.com>
Date: Fri, 23 Jan 2009 14:37:05 +0200
Subject: [PATCH] Remove padding in XLogCtl; might be a good idea, but let's keep it simple
 for now.

Also remove the XLogCtl->mode_lck spinlock, which is pretty pointless for
a single boolean that's only written by one process.
---
 src/backend/access/transam/xlog.c |   24 +-----------------------
 1 files changed, 1 insertions(+), 23 deletions(-)

diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index fcf5657..42c4552 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -340,18 +340,11 @@ typedef struct XLogCtlWrite

 /*
  * Total shared-memory state for XLOG.
- *
- * This small structure is accessed by many backends, so we take care to
- * pad out the parts of the structure so they can be accessed by separate
- * CPUs without causing false sharing cache flushes. Padding is generous
- * to allow for a wide variety of CPU architectures.
  */
-#define    XLOGCTL_BUFFER_SPACING    128
 typedef struct XLogCtlData
 {
     /* Protected by WALInsertLock: */
     XLogCtlInsert Insert;
-    char    InsertPadding[XLOGCTL_BUFFER_SPACING - sizeof(XLogCtlInsert)];

     /* Protected by info_lck: */
     XLogwrtRqst LogwrtRqst;
@@ -359,16 +352,9 @@ typedef struct XLogCtlData
     uint32        ckptXidEpoch;    /* nextXID & epoch of latest checkpoint */
     TransactionId ckptXid;
     XLogRecPtr    asyncCommitLSN; /* LSN of newest async commit */
-    /* add data structure padding for above info_lck declarations */
-    char    InfoPadding[XLOGCTL_BUFFER_SPACING - sizeof(XLogwrtRqst)
-                                            - sizeof(XLogwrtResult)
-                                            - sizeof(uint32)
-                                            - sizeof(TransactionId)
-                                            - sizeof(XLogRecPtr)];

     /* Protected by WALWriteLock: */
     XLogCtlWrite Write;
-    char    WritePadding[XLOGCTL_BUFFER_SPACING - sizeof(XLogCtlWrite)];

     /*
      * These values do not change after startup, although the pointed-to pages
@@ -390,11 +376,8 @@ typedef struct XLogCtlData
      * always during Recovery Processing Mode. This allows us to identify
      * code executed *during* Recovery Processing Mode but not necessarily
      * by Startup process itself.
-     *
-     * Protected by mode_lck
      */
     bool        SharedRecoveryProcessingMode;
-    slock_t        mode_lck;

     /*
      * recovery target control information
@@ -410,8 +393,6 @@ typedef struct XLogCtlData
     TransactionId     recoveryLastXid;
     XLogRecPtr        recoveryLastRecPtr;

-    char        InfoLockPadding[XLOGCTL_BUFFER_SPACING];
-
     slock_t        info_lck;        /* locks shared variables shown above */
 } XLogCtlData;

@@ -4399,7 +4380,6 @@ XLOGShmemInit(void)
     XLogCtl->XLogCacheBlck = XLOGbuffers - 1;
     XLogCtl->Insert.currpage = (XLogPageHeader) (XLogCtl->pages);
     SpinLockInit(&XLogCtl->info_lck);
-    SpinLockInit(&XLogCtl->mode_lck);

     /*
      * If we are not in bootstrap mode, pg_control should already exist. Read
@@ -6183,9 +6163,7 @@ IsRecoveryProcessingMode(void)
         if (xlogctl == NULL)
             return false;

-        SpinLockAcquire(&xlogctl->mode_lck);
-        LocalRecoveryProcessingMode = XLogCtl->SharedRecoveryProcessingMode;
-        SpinLockRelease(&xlogctl->mode_lck);
+        LocalRecoveryProcessingMode = xlogctl->SharedRecoveryProcessingMode;
     }

     knownProcessingMode = true;
--
1.5.6.5

>From 4061ac8f84cc699bf0f417689f853791089ed472 Mon Sep 17 00:00:00 2001
From: Heikki Linnakangas <heikki@enterprisedb.com>
Date: Fri, 23 Jan 2009 15:55:33 +0200
Subject: [PATCH] Remove knownProcessingMode variable.

---
 src/backend/access/transam/xlog.c |   19 ++++++++-----------
 1 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 7e480e2..e64fb48 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -126,9 +126,11 @@ bool        InRecovery = false;
 /* Are we recovering using offline XLOG archives? */
 static bool InArchiveRecovery = false;

-/* Local copy of shared RecoveryProcessingMode state */
+/*
+ * Local copy of shared RecoveryProcessingMode state. True actually
+ * means "not known, need to check the shared state"
+ */
 static bool LocalRecoveryProcessingMode = true;
-static bool knownProcessingMode = false;

 /* Was the last xlog file restored from archive, or local? */
 static bool restoredFromArchive = false;
@@ -5608,21 +5610,16 @@ StartupXLOG(void)
 bool
 IsRecoveryProcessingMode(void)
 {
-    if (knownProcessingMode && !LocalRecoveryProcessingMode)
+    if (!LocalRecoveryProcessingMode)
         return false;
-
+    else
     {
         /* use volatile pointer to prevent code rearrangement */
         volatile XLogCtlData *xlogctl = XLogCtl;

-        SpinLockAcquire(&xlogctl->mode_lck);
-        LocalRecoveryProcessingMode = XLogCtl->SharedRecoveryProcessingMode;
-        SpinLockRelease(&xlogctl->mode_lck);
+        LocalRecoveryProcessingMode = xlogctl->SharedRecoveryProcessingMode;
+        return LocalRecoveryProcessingMode;
     }
-
-    knownProcessingMode = true;
-
-    return LocalRecoveryProcessingMode;
 }

 /*
--
1.5.6.5


pgsql-hackers by date:

Previous
From: Zdenek Kotala
Date:
Subject: Re: [PATCH] reloptions - RELOPT_KIND_ALL
Next
From: Alvaro Herrera
Date:
Subject: Re: [PATCH] reloptions - RELOPT_KIND_ALL