summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorSampson Crowley2017-07-21 13:30:27 -0600
committerSampson Crowley2017-07-21 13:30:27 -0600
commit67732f41719ed4d1da7abd29e59ce7dee8aac17a (patch)
tree6ba4e2ebdc8bccd173007d3de497dc26c3c75c79
parent5248fd856769df97cbb5e084519a0b5608e70966 (diff)
downloadaur-67732f41719ed4d1da7abd29e59ce7dee8aac17a.tar.gz
rebuild repo
-rw-r--r--.SRCINFO17
-rw-r--r--.gitignore3
-rw-r--r--PKGBUILD35
-rw-r--r--pgpool-ii.diff286
4 files changed, 322 insertions, 19 deletions
diff --git a/.SRCINFO b/.SRCINFO
index 1bf85bb4ee57..c35a6096c9aa 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,21 +1,24 @@
pkgbase = pgpool-ii
- pkgdesc = pgpool-II is a connection pool server for PostgreSQL.
- pkgver = 3.2.5
- pkgrel = 1
+ pkgdesc = Middleware that works between PostgreSQL servers and a PostgreSQL database client.
+ pkgver = 3.6.4
+ pkgrel = 2
url = http://www.pgpool.net
arch = i686
arch = x86_64
license = custom
+ depends = openssl
depends = postgresql-libs
replaces = pgpool
options = !libtool
backup = etc/conf.d/pgpool-ii
- source = http://www.pgpool.net/download.php?f=pgpool-II-3.2.5.tar.gz
+ source = http://www.pgpool.net/download.php?f=pgpool-II-3.6.4.tar.gz
source = pgpool-ii.service
source = pgpool-ii.conf.d
- sha256sums = aecac952fd3d292584c9aa359d72f89b144c29f45c9f848cb030e46215a814f7
- sha256sums = 6c797a94c1648890a613e201c2ce2e3e2b602103daecc009ebf189578e8e15a0
- sha256sums = 9d0c12d735595424fad799499d50bc4da8b7f1e7ffc2c21317f8824559bb7aea
+ source = pgpool-ii.diff
+ md5sums = e31eedc9cf00b0b27596449a20f4c83d
+ md5sums = 6f1996c211e6f512289565e162752b04
+ md5sums = 74e1450ec40a5915341d7901736aca45
+ md5sums = b11938850095c777c80238ed878e158d
pkgname = pgpool-ii
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 000000000000..590541ceb647
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+*
+/*
+/*/
diff --git a/PKGBUILD b/PKGBUILD
index 49ccc646ccaf..073976d422bb 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -1,3 +1,4 @@
+# Maintainer: Sampson Crowley <sampsonsprojects at gmail dot com>
#Contributors:
# Trương Xuân Tính <xuantinh@gmail.com>
# henning mueller <henning@orgizm.net>
@@ -5,27 +6,34 @@
pkgname=pgpool-ii
_pkgname=pgpool-II
-pkgver=3.2.5
-pkgrel=1
-pkgdesc='pgpool-II is a connection pool server for PostgreSQL.'
+pkgver=3.6.4
+pkgrel=2
+pkgdesc="Middleware that works between PostgreSQL servers and a PostgreSQL database client."
+arch=()
+url="http://www.pgpool.net"
arch=(i686 x86_64)
-url='http://www.pgpool.net'
license=(custom)
-depends=(postgresql-libs)
+depends=(openssl postgresql-libs)
options=(!libtool)
replaces=(pgpool)
backup=(etc/conf.d/$pkgname)
source=(
http://www.pgpool.net/download.php?f=$_pkgname-$pkgver.tar.gz
- $pkgname.{service,conf.d}
+ $pkgname.{service,conf.d,diff}
)
+prepare(){
+ cd $srcdir/$_pkgname-$pkgver
+ patch -Np1 -i "$srcdir/$pkgname.diff"
+}
+
build() {
cd $srcdir/$_pkgname-$pkgver
./configure \
--prefix=/usr \
--sysconfdir=/etc/pgpool \
- --mandir=/usr/share/man
+ --mandir=/usr/share/man \
+ --with-openssl=openssl
make
}
@@ -37,15 +45,18 @@ package() {
make DESTDIR=$pkgdir install
- mkdir -p $pkgdir/{var/run/pgpool,usr/share/doc}
+ mkdir -p $pkgdir/{run/pgpool,usr/share/doc}
install -D COPYING $pkgdir/usr/share/licenses/$pkgname/LICENSE
cp -r doc $pkgdir/usr/share/doc/$pkgname
mv $pkgdir/usr/share/$_pkgname $pkgdir/usr/share/$pkgname
- cp sample/* $pkgdir/usr/share/$pkgname
+ cd $srcdir/$_pkgname-$pkgver/src/sql/pgpool-recovery
+ sudo make && sudo make install
}
-sha256sums=('aecac952fd3d292584c9aa359d72f89b144c29f45c9f848cb030e46215a814f7'
- '6c797a94c1648890a613e201c2ce2e3e2b602103daecc009ebf189578e8e15a0'
- '9d0c12d735595424fad799499d50bc4da8b7f1e7ffc2c21317f8824559bb7aea')
+md5sums=('e31eedc9cf00b0b27596449a20f4c83d'
+ '6f1996c211e6f512289565e162752b04'
+ '74e1450ec40a5915341d7901736aca45'
+ 'b11938850095c777c80238ed878e158d')
+
diff --git a/pgpool-ii.diff b/pgpool-ii.diff
new file mode 100644
index 000000000000..3d15d7f172c5
--- /dev/null
+++ b/pgpool-ii.diff
@@ -0,0 +1,286 @@
+diff --git a/src/context/pool_query_context.c b/src/context/pool_query_context.c
+index 88464d0..b450cd8 100644
+--- a/src/context/pool_query_context.c
++++ b/src/context/pool_query_context.c
+@@ -304,7 +304,7 @@ int pool_virtual_master_db_node_id(void)
+ return REAL_MASTER_NODE_ID;
+ }
+
+- if (sc->query_context)
++ if (sc->in_progress && sc->query_context)
+ {
+ int node_id = sc->query_context->virtual_master_node_id;
+
+diff --git a/src/protocol/pool_process_query.c b/src/protocol/pool_process_query.c
+index 547ec3e..92c19ef 100644
+--- a/src/protocol/pool_process_query.c
++++ b/src/protocol/pool_process_query.c
+@@ -3179,6 +3179,7 @@ void read_kind_from_backend(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *bac
+ ereport(DEBUG1,
+ (errmsg("read_kind_from_backend: sync pending message exists")));
+ session_context->query_context = NULL;
++ pool_unset_ignore_till_sync();
+ pool_unset_query_in_progress();
+ }
+ else
+@@ -3386,16 +3387,28 @@ void read_kind_from_backend(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *bac
+ * various scenario, probably we should employ this strategy for 'Z'
+ * (ready for response) case only, since it's a good candidate to
+ * re-sync primary and standby.
++ *
++ * 2017/7/16 Tatsuo Ishii wrote: The issue above has been solved since
++ * the pending message mechanism was introduced. However, in error
++ * cases it is possible that similar issue could happen since returned
++ * messages do not follow the sequence recorded in the pending
++ * messages because the backend ignores requests till sync message is
++ * received. In this case we need to re-sync either master or
++ * standby. So we check not only the standby but master node.
+ */
+-
+ if (session_context->load_balance_node_id != MASTER_NODE_ID &&
+- kind_list[MASTER_NODE_ID] == 'Z' && STREAM)
++ (kind_list[MASTER_NODE_ID] == 'Z' ||
++ kind_list[session_context->load_balance_node_id] == 'Z')
++ && STREAM)
+ {
+ POOL_CONNECTION *s;
+ char *buf;
+ int len;
+
+- s = CONNECTION(backend, session_context->load_balance_node_id);
++ if (kind_list[MASTER_NODE_ID] == 'Z')
++ s = CONNECTION(backend, session_context->load_balance_node_id);
++ else
++ s = CONNECTION(backend, MASTER_NODE_ID);
+
+ /* skip len and contents corresponding standby data */
+ pool_read(s, &len, sizeof(len));
+diff --git a/src/protocol/pool_proto_modules.c b/src/protocol/pool_proto_modules.c
+index dea6367..3a0a387 100644
+--- a/src/protocol/pool_proto_modules.c
++++ b/src/protocol/pool_proto_modules.c
+@@ -96,6 +96,9 @@ static char *
+ flatten_set_variable_args(const char *name, List *args);
+ static bool
+ process_pg_terminate_backend_func(POOL_QUERY_CONTEXT *query_context);
++static void pool_wait_till_ready_for_query(POOL_CONNECTION_POOL *backend);
++static void pool_discard_except_sync_and_ready_for_query(POOL_CONNECTION *frontend,
++ POOL_CONNECTION_POOL *backend);
+
+ /*
+ * This is the workhorse of processing the pg_terminate_backend function to
+@@ -1570,8 +1573,8 @@ POOL_STATUS Close(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend,
+ query_context->where_to_send[session_context->load_balance_node_id] = true;
+ }
+
+- pool_extended_send_and_wait(query_context, "C", len, contents, 1, MASTER_NODE_ID, false);
+- pool_extended_send_and_wait(query_context, "C", len, contents, -1, MASTER_NODE_ID, false);
++ pool_extended_send_and_wait(query_context, "C", len, contents, 1, MASTER_NODE_ID, true);
++ pool_extended_send_and_wait(query_context, "C", len, contents, -1, MASTER_NODE_ID, true);
+
+ /* Add pending message */
+ pmsg = pool_pending_message_create('C', len, contents);
+@@ -2212,8 +2215,9 @@ POOL_STATUS ErrorResponse3(POOL_CONNECTION *frontend,
+ if (ret != POOL_CONTINUE)
+ return ret;
+
+- raise_intentional_error_if_need(backend);
+-
++ if (!STREAM)
++ raise_intentional_error_if_need(backend);
++
+ return POOL_CONTINUE;
+ }
+
+@@ -2462,6 +2466,12 @@ POOL_STATUS ProcessFrontendResponse(POOL_CONNECTION *frontend,
+ else if (!pool_is_query_in_progress())
+ pool_set_query_in_progress();
+ status = SimpleForwardToBackend(fkind, frontend, backend, len, contents);
++
++ if (STREAM)
++ {
++ /* Wait till Ready for query received */
++ pool_wait_till_ready_for_query(backend);
++ }
+ break;
+
+ case 'F': /* FunctionCall */
+@@ -2635,7 +2645,7 @@ POOL_STATUS ProcessBackendResponse(POOL_CONNECTION *frontend,
+ {
+ /* parse_before_bind() was called. Do not foward the
+ * close complete message to frontend. */
+- ereport(LOG,
++ ereport(DEBUG1,
+ (errmsg("processing backend response"),
+ errdetail("do not forward close complete message to frontend")));
+ pool_discard_packet_contents(backend);
+@@ -2662,31 +2672,8 @@ POOL_STATUS ProcessBackendResponse(POOL_CONNECTION *frontend,
+ {
+ pool_set_ignore_till_sync();
+ pool_unset_query_in_progress();
+-
+ if (STREAM)
+- {
+- POOL_PENDING_MESSAGE *pmsg;
+- int i;
+-
+- /* Remove all pending messages */
+- do
+- {
+- pmsg = pool_pending_message_pull_out();
+- pool_pending_message_free_pending_message(pmsg);
+- }
+- while (pmsg);
+-
+- pool_pending_message_reset_previous_message();
+-
+- /* Discard read buffer */
+- for (i=0;i<NUM_BACKENDS;i++)
+- {
+- if (VALID_BACKEND(i))
+- {
+- pool_discard_read_buffer(CONNECTION(backend, i));
+- }
+- }
+- }
++ pool_discard_except_sync_and_ready_for_query(frontend, backend);
+ }
+ break;
+
+@@ -3528,3 +3515,136 @@ flatten_set_variable_args(const char *name, List *args)
+
+ return buf.data;
+ }
++
++/* Called when sync message is received.
++ * Wait till ready for query received.
++ */
++static void pool_wait_till_ready_for_query(POOL_CONNECTION_POOL *backend)
++{
++ char kind;
++ int len;
++ int poplen;
++ char *buf;
++ int i;
++
++ for (i=0;i<NUM_BACKENDS;i++)
++ {
++ if (VALID_BACKEND(i))
++ {
++ for (;;)
++ {
++ pool_read(CONNECTION(backend, i), &kind, sizeof(kind));
++ pool_push(CONNECTION(backend, i), &kind, sizeof(kind));
++ pool_read(CONNECTION(backend, i), &len, sizeof(len));
++ pool_push(CONNECTION(backend, i), &len, sizeof(len));
++ if ((ntohl(len)-sizeof(len)) > 0)
++ {
++ buf = pool_read2(CONNECTION(backend, i), ntohl(len)-sizeof(len));
++ pool_push(CONNECTION(backend, i), buf, ntohl(len)-sizeof(len));
++ }
++
++ if (kind == 'Z') /* Ready for query? */
++ {
++ pool_pop(CONNECTION(backend, i), &poplen);
++ ereport(DEBUG1,
++ (errmsg("pool_wait_till_ready_for_query: backend:%d ready for query found. buffer length:%d",
++ i, CONNECTION(backend, i)->len)));
++ break;
++ }
++ }
++ }
++ }
++}
++
++/*
++ * Called when error response received in streaming replication mode and doing
++ * extended query. Remove all pending messages and backend message buffer data
++ * except POOL_SYNC pending message and ready for query. If sync message is
++ * not received yet, call ProcessFrontendResponse() to read data from
++ * frontend.
++ */
++static void pool_discard_except_sync_and_ready_for_query(POOL_CONNECTION *frontend,
++ POOL_CONNECTION_POOL *backend)
++{
++ POOL_PENDING_MESSAGE *pmsg;
++ int i;
++
++ if (!pool_is_doing_extended_query_message() || !STREAM)
++ return;
++
++ /*
++ * Check to see if we aready received a sync
++ * message. If not, call ProcessFrontendResponse() to
++ * get the sync message from client.
++ */
++ pmsg = pool_pending_message_get(POOL_SYNC);
++ if (pmsg == NULL)
++ {
++ ProcessFrontendResponse(frontend, backend);
++ }
++ pool_pending_message_free_pending_message(pmsg);
++
++ /* Remove all pending messages except sync message */
++ do
++ {
++ pmsg = pool_pending_message_head_message();
++ if (pmsg && pmsg->type == POOL_SYNC)
++ {
++ ereport(LOG,
++ (errmsg("Process backend response: sync pending message found after receiving error response")));
++ pool_unset_ignore_till_sync();
++ pool_pending_message_free_pending_message(pmsg);
++ break;
++ }
++ pool_pending_message_free_pending_message(pmsg);
++ pmsg = pool_pending_message_pull_out();
++ pool_pending_message_free_pending_message(pmsg);
++ }
++ while (pmsg);
++
++ pool_pending_message_reset_previous_message();
++
++ /* Discard read buffer execpt "Ready for query" */
++ for (i=0;i<NUM_BACKENDS;i++)
++ {
++ if (VALID_BACKEND(i))
++ {
++ char kind;
++ int len;
++ int sts;
++
++ while (!pool_read_buffer_is_empty(CONNECTION(backend, i)))
++ {
++ sts = pool_read(CONNECTION(backend, i), &kind, sizeof(kind));
++ if (sts < 0 || kind == '\0')
++ {
++ ereport(DEBUG1,
++ (errmsg("pool_discard_except_sync_and_ready_for_query: EOF detected while reading from backend: %d buffer length: %d sts: %d",
++ i, CONNECTION(backend, i)->len, sts)));
++ pool_unread(CONNECTION(backend, i), &kind, sizeof(kind));
++ break;
++ }
++
++ if (kind == 'Z') /* Ready for query? */
++ {
++ pool_unread(CONNECTION(backend, i), &kind, sizeof(kind));
++ ereport(DEBUG1,
++ (errmsg("pool_discard_except_sync_and_ready_for_query: Ready for query found. backend:%d",
++ i)));
++ break;
++ }
++ else
++ {
++ /* Read and discard packet */
++ pool_read(CONNECTION(backend, i), &len, sizeof(len));
++ if ((ntohl(len)-sizeof(len)) > 0)
++ {
++ pool_read2(CONNECTION(backend, i), ntohl(len)-sizeof(len));
++ }
++ ereport(DEBUG1,
++ (errmsg("pool_discard_except_sync_and_ready_for_query: discarding packet %c (len:%lu) of backend:%d", kind, ntohl(len)-sizeof(len), i)));
++ }
++ }
++ }
++ }
++}