summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane2008-05-02 19:52:37 +0000
committerTom Lane2008-05-02 19:52:37 +0000
commit57f94ffcddcc46eebdd91ef9431fe55e07ca469d (patch)
tree0da5c391d0ebcdba7cc0945119d03998ee0ca6aa
parentad86b03bde86a2e04bbe56f4b46a5eba28da91b4 (diff)
Extend yesterday's patch making BLCKSZ and RELSEG_SIZE configurable to also
let XLOG_BLCKSZ and XLOG_SEG_SIZE be set via configure. Per a proposal by Mark Wong, though I thought it better to call the switches after "wal" rather than "xlog".
-rwxr-xr-xconfigure116
-rw-r--r--configure.in61
-rw-r--r--doc/src/sgml/installation.sgml28
-rw-r--r--doc/src/sgml/wal.sgml7
-rw-r--r--src/include/pg_config.h.in12
-rw-r--r--src/include/pg_config_manual.h19
6 files changed, 216 insertions, 27 deletions
diff --git a/configure b/configure
index 31c163b654..bb7145e5d7 100755
--- a/configure
+++ b/configure
@@ -1373,8 +1373,10 @@ Optional Packages:
--with-libraries=DIRS look for additional libraries in DIRS
--with-libs=DIRS alternative spelling of --with-libraries
--with-pgport=PORTNUM set default port number [5432]
- --with-blocksize=BLOCKSIZE set block size in kB [8]
- --with-segsize=SEGSIZE set segment size in GB [1]
+ --with-blocksize=BLOCKSIZE set table block size in kB [8]
+ --with-segsize=SEGSIZE set table segment size in GB [1]
+ --with-wal-blocksize=BLOCKSIZE set WAL block size in kB [8]
+ --with-wal-segsize=SEGSIZE set WAL segment size in MB [16]
--with-tcl build Tcl modules (PL/Tcl)
--with-tclconfig=DIR tclConfig.sh is in DIR
--with-perl build Perl modules (PL/Perl)
@@ -2603,7 +2605,7 @@ _ACEOF
#
-# File segment size
+# Relation segment size
#
{ echo "$as_me:$LINENO: checking for segment size" >&5
echo $ECHO_N "checking for segment size... $ECHO_C" >&6; }
@@ -2648,6 +2650,114 @@ _ACEOF
#
+# WAL block size
+#
+{ echo "$as_me:$LINENO: checking for WAL block size" >&5
+echo $ECHO_N "checking for WAL block size... $ECHO_C" >&6; }
+
+pgac_args="$pgac_args with_wal_blocksize"
+
+
+# Check whether --with-wal-blocksize was given.
+if test "${with_wal_blocksize+set}" = set; then
+ withval=$with_wal_blocksize;
+ case $withval in
+ yes)
+ { { echo "$as_me:$LINENO: error: argument required for --with-wal-blocksize option" >&5
+echo "$as_me: error: argument required for --with-wal-blocksize option" >&2;}
+ { (exit 1); exit 1; }; }
+ ;;
+ no)
+ { { echo "$as_me:$LINENO: error: argument required for --with-wal-blocksize option" >&5
+echo "$as_me: error: argument required for --with-wal-blocksize option" >&2;}
+ { (exit 1); exit 1; }; }
+ ;;
+ *)
+ wal_blocksize=$withval
+ ;;
+ esac
+
+else
+ wal_blocksize=8
+fi
+
+
+case ${wal_blocksize} in
+ 1) XLOG_BLCKSZ=1024;;
+ 2) XLOG_BLCKSZ=2048;;
+ 4) XLOG_BLCKSZ=4096;;
+ 8) XLOG_BLCKSZ=8192;;
+ 16) XLOG_BLCKSZ=16384;;
+ 32) XLOG_BLCKSZ=32768;;
+ 64) XLOG_BLCKSZ=65536;;
+ *) { { echo "$as_me:$LINENO: error: Invalid WAL block size. Allowed values are 1,2,4,8,16,32,64." >&5
+echo "$as_me: error: Invalid WAL block size. Allowed values are 1,2,4,8,16,32,64." >&2;}
+ { (exit 1); exit 1; }; }
+esac
+{ echo "$as_me:$LINENO: result: ${wal_blocksize}kB" >&5
+echo "${ECHO_T}${wal_blocksize}kB" >&6; }
+
+
+cat >>confdefs.h <<_ACEOF
+#define XLOG_BLCKSZ ${XLOG_BLCKSZ}
+_ACEOF
+
+
+#
+# WAL segment size
+#
+{ echo "$as_me:$LINENO: checking for WAL segment size" >&5
+echo $ECHO_N "checking for WAL segment size... $ECHO_C" >&6; }
+
+pgac_args="$pgac_args with_wal_segsize"
+
+
+# Check whether --with-wal-segsize was given.
+if test "${with_wal_segsize+set}" = set; then
+ withval=$with_wal_segsize;
+ case $withval in
+ yes)
+ { { echo "$as_me:$LINENO: error: argument required for --with-wal-segsize option" >&5
+echo "$as_me: error: argument required for --with-wal-segsize option" >&2;}
+ { (exit 1); exit 1; }; }
+ ;;
+ no)
+ { { echo "$as_me:$LINENO: error: argument required for --with-wal-segsize option" >&5
+echo "$as_me: error: argument required for --with-wal-segsize option" >&2;}
+ { (exit 1); exit 1; }; }
+ ;;
+ *)
+ wal_segsize=$withval
+ ;;
+ esac
+
+else
+ wal_segsize=16
+fi
+
+
+case ${wal_segsize} in
+ 1) ;;
+ 2) ;;
+ 4) ;;
+ 8) ;;
+ 16) ;;
+ 32) ;;
+ 64) ;;
+ *) { { echo "$as_me:$LINENO: error: Invalid WAL segment size. Allowed values are 1,2,4,8,16,32,64." >&5
+echo "$as_me: error: Invalid WAL segment size. Allowed values are 1,2,4,8,16,32,64." >&2;}
+ { (exit 1); exit 1; }; }
+esac
+{ echo "$as_me:$LINENO: result: ${wal_segsize}MB" >&5
+echo "${ECHO_T}${wal_segsize}MB" >&6; }
+
+
+cat >>confdefs.h <<_ACEOF
+#define XLOG_SEG_SIZE (${wal_segsize} * 1024 * 1024)
+_ACEOF
+
+
+#
# C compiler
#
diff --git a/configure.in b/configure.in
index b9faecfa67..661ddeb6b1 100644
--- a/configure.in
+++ b/configure.in
@@ -221,7 +221,7 @@ AC_SUBST(enable_dtrace)
# Block size
#
AC_MSG_CHECKING([for block size])
-PGAC_ARG_REQ(with, blocksize, [ --with-blocksize=BLOCKSIZE set block size in kB [[8]]],
+PGAC_ARG_REQ(with, blocksize, [ --with-blocksize=BLOCKSIZE set table block size in kB [[8]]],
[blocksize=$withval],
[blocksize=8])
case ${blocksize} in
@@ -250,10 +250,10 @@ AC_DEFINE_UNQUOTED([BLCKSZ], ${BLCKSZ}, [
])
#
-# File segment size
+# Relation segment size
#
AC_MSG_CHECKING([for segment size])
-PGAC_ARG_REQ(with, segsize, [ --with-segsize=SEGSIZE set segment size in GB [[1]]],
+PGAC_ARG_REQ(with, segsize, [ --with-segsize=SEGSIZE set table segment size in GB [[1]]],
[segsize=$withval],
[segsize=1])
# this expression is set up to avoid unnecessary integer overflow
@@ -281,6 +281,61 @@ AC_DEFINE_UNQUOTED([RELSEG_SIZE], ${RELSEG_SIZE}, [
])
#
+# WAL block size
+#
+AC_MSG_CHECKING([for WAL block size])
+PGAC_ARG_REQ(with, wal-blocksize, [ --with-wal-blocksize=BLOCKSIZE set WAL block size in kB [[8]]],
+ [wal_blocksize=$withval],
+ [wal_blocksize=8])
+case ${wal_blocksize} in
+ 1) XLOG_BLCKSZ=1024;;
+ 2) XLOG_BLCKSZ=2048;;
+ 4) XLOG_BLCKSZ=4096;;
+ 8) XLOG_BLCKSZ=8192;;
+ 16) XLOG_BLCKSZ=16384;;
+ 32) XLOG_BLCKSZ=32768;;
+ 64) XLOG_BLCKSZ=65536;;
+ *) AC_MSG_ERROR([Invalid WAL block size. Allowed values are 1,2,4,8,16,32,64.])
+esac
+AC_MSG_RESULT([${wal_blocksize}kB])
+
+AC_DEFINE_UNQUOTED([XLOG_BLCKSZ], ${XLOG_BLCKSZ}, [
+ Size of a WAL file block. This need have no particular relation to BLCKSZ.
+ XLOG_BLCKSZ must be a power of 2, and if your system supports O_DIRECT I/O,
+ XLOG_BLCKSZ must be a multiple of the alignment requirement for direct-I/O
+ buffers, else direct I/O may fail.
+
+ Changing XLOG_BLCKSZ requires an initdb.
+])
+
+#
+# WAL segment size
+#
+AC_MSG_CHECKING([for WAL segment size])
+PGAC_ARG_REQ(with, wal-segsize, [ --with-wal-segsize=SEGSIZE set WAL segment size in MB [[16]]],
+ [wal_segsize=$withval],
+ [wal_segsize=16])
+case ${wal_segsize} in
+ 1) ;;
+ 2) ;;
+ 4) ;;
+ 8) ;;
+ 16) ;;
+ 32) ;;
+ 64) ;;
+ *) AC_MSG_ERROR([Invalid WAL segment size. Allowed values are 1,2,4,8,16,32,64.])
+esac
+AC_MSG_RESULT([${wal_segsize}MB])
+
+AC_DEFINE_UNQUOTED([XLOG_SEG_SIZE], [(${wal_segsize} * 1024 * 1024)], [
+ XLOG_SEG_SIZE is the size of a single WAL file. This must be a power of 2
+ and larger than XLOG_BLCKSZ (preferably, a great deal larger than
+ XLOG_BLCKSZ).
+
+ Changing XLOG_SEG_SIZE requires an initdb.
+])
+
+#
# C compiler
#
diff --git a/doc/src/sgml/installation.sgml b/doc/src/sgml/installation.sgml
index 0fbbe8fa7e..271138dfe5 100644
--- a/doc/src/sgml/installation.sgml
+++ b/doc/src/sgml/installation.sgml
@@ -1104,6 +1104,34 @@ su - postgres
</varlistentry>
<varlistentry>
+ <term><option>--with-wal-segsize=<replaceable>SEGSIZE</replaceable></option></term>
+ <listitem>
+ <para>
+ Set the <firstterm>WAL segment size</>, in megabytes. This is
+ the size of each individual file in the WAL log. It may be useful
+ to adjust this size to control the granularity of WAL log shipping.
+ The default size is 16 megabytes.
+ The value must be a power of 2 between 1 and 64 (megabytes).
+ Note that changing this value requires an initdb.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>--with-wal-blocksize=<replaceable>BLOCKSIZE</replaceable></option></term>
+ <listitem>
+ <para>
+ Set the <firstterm>WAL block size</>, in kilobytes. This is the unit
+ of storage and I/O within the WAL log. The default, 8 kilobytes,
+ is suitable for most situations; but other values may be useful
+ in special cases.
+ The value must be a power of 2 between 1 and 64 (kilobytes).
+ Note that changing this value requires an initdb.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
<term><option>--disable-spinlocks</option></term>
<listitem>
<para>
diff --git a/doc/src/sgml/wal.sgml b/doc/src/sgml/wal.sgml
index 24758b8053..907e9c8762 100644
--- a/doc/src/sgml/wal.sgml
+++ b/doc/src/sgml/wal.sgml
@@ -487,8 +487,11 @@
<para>
<acronym>WAL</acronym> logs are stored in the directory
<filename>pg_xlog</filename> under the data directory, as a set of
- segment files, normally each 16 MB in size. Each segment is divided into
- pages, normally 8 kB each. The log record headers are described in
+ segment files, normally each 16 MB in size (but the size can be changed
+ by altering the <option>--with-wal-segsize</> configure option when
+ building the server). Each segment is divided into pages, normally
+ 8 kB each (this size can be changed via the <option>--with-wal-blocksize</>
+ configure option). The log record headers are described in
<filename>access/xlog.h</filename>; the record content is dependent
on the type of event that is being logged. Segment files are given
ever-increasing numbers as names, starting at
diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in
index 608e75cd7b..2314d81965 100644
--- a/src/include/pg_config.h.in
+++ b/src/include/pg_config.h.in
@@ -747,6 +747,18 @@
first (like Motorola and SPARC, unlike Intel and VAX). */
#undef WORDS_BIGENDIAN
+/* Size of a WAL file block. This need have no particular relation to BLCKSZ.
+ XLOG_BLCKSZ must be a power of 2, and if your system supports O_DIRECT I/O,
+ XLOG_BLCKSZ must be a multiple of the alignment requirement for direct-I/O
+ buffers, else direct I/O may fail. Changing XLOG_BLCKSZ requires an initdb.
+ */
+#undef XLOG_BLCKSZ
+
+/* XLOG_SEG_SIZE is the size of a single WAL file. This must be a power of 2
+ and larger than XLOG_BLCKSZ (preferably, a great deal larger than
+ XLOG_BLCKSZ). Changing XLOG_SEG_SIZE requires an initdb. */
+#undef XLOG_SEG_SIZE
+
/* Number of bits in a file offset, on hosts where this is settable. */
#undef _FILE_OFFSET_BITS
diff --git a/src/include/pg_config_manual.h b/src/include/pg_config_manual.h
index 525f2d3146..ff543992d3 100644
--- a/src/include/pg_config_manual.h
+++ b/src/include/pg_config_manual.h
@@ -11,25 +11,6 @@
*/
/*
- * Size of a WAL file block. This need have no particular relation to BLCKSZ.
- * XLOG_BLCKSZ must be a power of 2, and if your system supports O_DIRECT I/O,
- * XLOG_BLCKSZ must be a multiple of the alignment requirement for direct-I/O
- * buffers, else direct I/O may fail.
- *
- * Changing XLOG_BLCKSZ requires an initdb.
- */
-#define XLOG_BLCKSZ 8192
-
-/*
- * XLOG_SEG_SIZE is the size of a single WAL file. This must be a power of 2
- * and larger than XLOG_BLCKSZ (preferably, a great deal larger than
- * XLOG_BLCKSZ).
- *
- * Changing XLOG_SEG_SIZE requires an initdb.
- */
-#define XLOG_SEG_SIZE (16*1024*1024)
-
-/*
* Maximum length for identifiers (e.g. table names, column names,
* function names). It must be a multiple of sizeof(int) (typically
* 4).