pgpool2.git
9 years agoPrepare 3.3.10 V3_3_10 V3_3_10_RPM
pengbo [Tue, 26 Apr 2016 03:16:31 +0000 (12:16 +0900)]
Prepare 3.3.10

9 years agoPrepare 3.3.10
pengbo [Tue, 26 Apr 2016 01:42:37 +0000 (10:42 +0900)]
Prepare 3.3.10

9 years agoChange the PID length of pcp_proc_count command result to 6 characters long
pengbo [Wed, 20 Apr 2016 03:40:41 +0000 (12:40 +0900)]
Change the PID length of pcp_proc_count command result to 6 characters long

If the pgpool process ID are over 5 characters, the 6th character of each process ID
will be removed.This commit changes the process ID length of pcp_proc_count command
result to 6 characters long.

See bug 188 for related info.

9 years agoRedirect all user queries to primary server
Tatsuo Ishii [Fri, 15 Apr 2016 04:17:23 +0000 (13:17 +0900)]
Redirect all user queries to primary server

Up to now some user queries are sent to other than the primary server
even if load_balance_mode = off. This commit changes the behavior: if
load_balance_mode = off in streaming replication mode, now all the
user queries are sent to the primary server only.

See bug 189 for related info.

9 years agoremoving the limit on the maximum number of items in the black_function_list
Muhammad Usama [Thu, 7 Apr 2016 15:25:57 +0000 (20:25 +0500)]
removing the limit on the maximum number of items in the black_function_list
and white_function_list lists.

extract_string_tokens in pool_config uses the fixed size malloc on the array to
hold the black_function_list/white_function_list items. This imposes a limit of
maximum items in these lists. The fix is to use realloc to increase the array
size when it gets full.

9 years agoPrepare 3.3.9 V3_3_9 V3_3_9_RPM
Yugo Nagata [Mon, 4 Apr 2016 10:51:43 +0000 (19:51 +0900)]
Prepare 3.3.9

9 years agoPrepare 3.3.9
Yugo Nagata [Mon, 4 Apr 2016 10:21:52 +0000 (19:21 +0900)]
Prepare 3.3.9

9 years agoValidating the PCP packet length
Muhammad Usama [Tue, 29 Mar 2016 20:30:33 +0000 (01:30 +0500)]
Validating the PCP packet length

Without the validation check, a malformed PCP packet can crash the PCP child
and/or can run the server out of memory by sending the packet with a
very large data size.

9 years agoFix typo
Tatsuo Ishii [Mon, 28 Mar 2016 05:09:29 +0000 (14:09 +0900)]
Fix typo

9 years agoFix pgpool_setup to not confuse log output
Tatsuo Ishii [Sat, 26 Mar 2016 22:49:53 +0000 (07:49 +0900)]
Fix pgpool_setup to not confuse log output

Before it simply redirects the stdout and stderr of pgpool process to
a log file.  This could cause log contents being garbled or even
missed because of race condition caused by multiple process being
writing concurrently. I and Usama found this while investigating the
regression failure of 004.watchdog.

To fix this, pgpool_setup now generates startall script so that pgpool
now sends stdout/stderr to cat command and cat writes to the log file
(It seems the race condition does not occur when writing to a pipe).

9 years agoFix installation procedure.
Tatsuo Ishii [Sat, 19 Mar 2016 02:05:26 +0000 (11:05 +0900)]
Fix installation procedure.

With PostgreSQL 9.4 or later, installing pgpool_regclass is not
needed.

9 years agoChange description of backend_flag.
Tatsuo Ishii [Wed, 16 Mar 2016 00:28:38 +0000 (09:28 +0900)]
Change description of backend_flag.

It is pointed out that restarting pgpool-II is not
necessary. [pgpool-general-jp: 1394].

9 years agoFix typo in configure
Tatsuo Ishii [Mon, 14 Mar 2016 23:12:17 +0000 (08:12 +0900)]
Fix typo in configure

Patch provided by Thomas Munro.

9 years agoYet another reset query stuck problem fix. [pgpool-general: 4265]
Muhammad Usama [Mon, 22 Feb 2016 12:23:46 +0000 (17:23 +0500)]
Yet another reset query stuck problem fix. [pgpool-general: 4265]

The solution is to return  POOL_END_WITH_FRONTEND_ERROR instead of
POOL_END when pool_flush on front-end socket fails

9 years agoFix previous bronken commit
Yugo Nagata [Wed, 17 Feb 2016 08:24:54 +0000 (17:24 +0900)]
Fix previous bronken commit

The following commit was broken and regress test 001 failed.
- Fix memorry leak reported by Coverity (CID 1350095)

9 years agoFixing pgpool-recovery module compilation issue with PostgreSQL 9.6
Muhammad Usama [Fri, 12 Feb 2016 12:30:10 +0000 (17:30 +0500)]
Fixing pgpool-recovery module compilation issue with PostgreSQL 9.6

Incorporating the change of function signature for GetConfigOption..()
functions in PostgreSQL 9.6

9 years agoFix memorry leak reported by Coverity (CID 1350095)
Yugo Nagata [Fri, 12 Feb 2016 06:41:39 +0000 (15:41 +0900)]
Fix memorry leak reported by Coverity (CID 1350095)

9 years agoFix test/regression/clean.sh to remove binary files of 010.rewrite_timestamp test
Yugo Nagata [Wed, 10 Feb 2016 08:46:05 +0000 (17:46 +0900)]
Fix test/regression/clean.sh to remove binary files of 010.rewrite_timestamp test

9 years agoPrepare 3.3.8 V3_3_8
Yugo Nagata [Fri, 5 Feb 2016 07:00:09 +0000 (16:00 +0900)]
Prepare 3.3.8

9 years agoPrepare 3.3.8
Yugo Nagata [Fri, 5 Feb 2016 06:26:31 +0000 (15:26 +0900)]
Prepare 3.3.8

9 years agoAllow timeout value to be specified by the command option
Yugo Nagata [Tue, 2 Feb 2016 01:36:06 +0000 (10:36 +0900)]
Allow timeout value to be specified by the command option

9 years agoFix regression test to check timeout of each test
Yugo Nagata [Mon, 1 Feb 2016 08:58:12 +0000 (17:58 +0900)]
Fix regression test to check timeout of each test

9 years agoAdd some warning messages for wd_authkey hash calculation failure
Yugo Nagata [Mon, 1 Feb 2016 06:51:12 +0000 (15:51 +0900)]
Add some warning messages for wd_authkey hash calculation failure

Sometimes wd_authkey calculation fails for some reason other than
authkey mismatch. The additional messages make these distingushable
for each other.

9 years agoAdd test of white/black_memqcache_table_list to regress #006
Yugo Nagata [Thu, 21 Jan 2016 02:16:28 +0000 (11:16 +0900)]
Add test of white/black_memqcache_table_list to regress #006

9 years agoFix bug#156: problem with reloading.
Tatsuo Ishii [Sun, 17 Jan 2016 12:54:20 +0000 (21:54 +0900)]
Fix bug#156: problem with reloading.

While reloading pgpool.conf, the number of DB nodes is tentatively set
to 0, then counted up until reaching to the actual number of backends
by the pgpool main process. Unfortunately the variable is on the
shared memory and it confuses pgpool child process if they are using
the variable. To solve the problem, a local variable is used to count
up the number of backend. After finishing the counting, the value of
the local variable is assigned to the variable on the shared memory.

I will explain why we don't need interlocking:

1) If the number of backend has not changed before/after the loop,
   it's obviously fine.

2) If the number of backend has increased after the loop, the new
   backend is recognized as "CON_UNUSED" because all the status for
   each backend is set to "CON_UNUSED" beforehand.

3) If the number of backend has decreased after the loop, failover
   should have happened and child process should have restarted.

However, we should be careful so that the assignment of the variable
should happen in an atomic manner. For this purpose I change the data
type of the variable from int to sig_atomic_t.
/*
 * $Header$
 *
 * pgpool: a language independent connection pool server for PostgreSQL
 * written by Tatsuo Ishii
 *
 * Copyright (c) 2003-2016 PgPool Global Development Group
 *
 * Permission to use, copy, modify, and distribute this software and
 * its documentation for any purpose and without fee is hereby
 * granted, provided that the above copyright notice appear in all
 * copies and that both that copyright notice and this permission
 * notice appear in supporting documentation, and that the name of the
 * author not be used in advertising or publicity pertaining to
 * distribution of the software without specific, written prior
 * permission. The author makes no representations about the
 * suitability of this software for any purpose.  It is provided "as
 * is" without express or implied warranty.
 *
 *
 * libpcpcp_ext.h -
 *   This file contains definitions for structures and
 *   externs for functions used by frontend libpcp applications.
 */

/*
 * startup packet definitions (v2) stolen from PostgreSQL
 */

typedef enum {
CON_UNUSED, /* unused slot */
    CON_CONNECT_WAIT, /* waiting for connection starting */
CON_UP, /* up and running */
CON_DOWN /* down, disconnected */
} BACKEND_STATUS;

/*
 * PostgreSQL backend descriptor. Placed on shared memory area.
 */
typedef struct {
char backend_hostname[MAX_DB_HOST_NAMELEN]; /* backend host name */
int backend_port; /* backend port numbers */
BACKEND_STATUS backend_status; /* backend status */
double backend_weight; /* normalized backend load balance ratio */
double unnormalized_weight; /* descripted parameter */
char backend_data_directory[MAX_PATH_LENGTH];
unsigned short flag; /* various flags */
unsigned long long int standby_delay; /* The replication delay against the primary */
} BackendInfo;

typedef struct {
sig_atomic_t num_backends; /* Number of used PostgreSQL backends.
 * This needs to be a sig_atomic_t type
 * since it is replaced by a local
 * variable while reloading pgpool.conf.
 */

BackendInfo backend_info[MAX_NUM_BACKENDS];
} BackendDesc;
/*
 * Connection pool information. Placed on shared memory area.
 */
typedef struct {
int backend_id; /* backend id */
char database[SM_DATABASE]; /* Database name */
char user[SM_USER]; /* User name */
int major; /* protocol major version */
int minor; /* protocol minor version */
int pid; /* backend process id */
int key; /* cancel key */
int counter; /* used counter */
time_t  create_time; /* connection creation time */
int load_balancing_node; /* load balancing node */
char connected; /* True if frontend connected. Please note
 * that we use "char" instead of "bool".
 * Since 3.1, we need to export this
 * structure so that PostgreSQL C
 * functions can use. Problem is,
 * PostgreSQL defines bool itself, and if
 * we use bool, the size of the structure
 * might be out of control of
 * pgpool-II. So we use "char" here.
 */
} ConnectionInfo;

/*
 * process information
 * This object put on shared memory.
 */
typedef struct {
pid_t pid; /* OS's process id */
time_t start_time; /* fork() time */
ConnectionInfo *connection_info; /* head of the connection info for this process */
char need_to_restart; /* If non 0, exit this child process
 * as soon as current session ends.
 * Typical case this flag being set is
 * failback a node in streaming
 * replication mode.
 */
} ProcessInfo;

/*
 * reporting types
 */
/* some length definitions */

/* config report struct*/
typedef struct {
char name[POOLCONFIG_MAXNAMELEN+1];
char value[POOLCONFIG_MAXVALLEN+1];
char desc[POOLCONFIG_MAXDESCLEN+1];
} POOL_REPORT_CONFIG;

/* nodes report struct */
typedef struct {
char node_id[POOLCONFIG_MAXIDLEN+1];
char hostname[POOLCONFIG_MAXIDENTLEN+1];
char port[POOLCONFIG_MAXPORTLEN+1];
char status[POOLCONFIG_MAXSTATLEN+1];
char lb_weight[POOLCONFIG_MAXWEIGHTLEN+1];
char role[POOLCONFIG_MAXWEIGHTLEN+1];
char select[POOLCONFIG_MAXWEIGHTLEN+1];
} POOL_REPORT_NODES;

/* processes report struct */
typedef struct {
char pool_pid[POOLCONFIG_MAXCOUNTLEN+1];
char start_time[POOLCONFIG_MAXDATELEN+1];
char database[POOLCONFIG_MAXIDENTLEN+1];
char username[POOLCONFIG_MAXIDENTLEN+1];
char create_time[POOLCONFIG_MAXDATELEN+1];
char pool_counter[POOLCONFIG_MAXCOUNTLEN+1];
} POOL_REPORT_PROCESSES;

/* pools reporting struct */
typedef struct {
int pool_pid;
time_t start_time;
int pool_id;
int backend_id;
char database[POOLCONFIG_MAXIDENTLEN+1];
char username[POOLCONFIG_MAXIDENTLEN+1];
time_t create_time;
int pool_majorversion;
int pool_minorversion;
int pool_counter;
int pool_backendpid;
int pool_connected;
} POOL_REPORT_POOLS;

/* version struct */
typedef struct {
char version[POOLCONFIG_MAXVALLEN+1];
} POOL_REPORT_VERSION;

typedef enum {
PCP_CONNECTION_OK,
PCP_CONNECTION_CONNECTED,
PCP_CONNECTION_NOT_CONNECTED,
PCP_CONNECTION_BAD,
PCP_CONNECTION_AUTH_ERROR
}ConnStateType;

typedef enum {
PCP_RES_COMMAND_OK,
PCP_RES_BAD_RESPONSE,
PCP_RES_BACKEND_ERROR,
PCP_RES_INCOMPLETE,
PCP_RES_ERROR
}ResultStateType;

struct PCPConnInfo;

typedef struct {
int isint; /* 1 if data in slot is integer, 0 otherwise */
int datalen; /* Length of binary data*/
union
{
int* ptr;
int integer;
}data;
void (*free_func)(struct PCPConnInfo*,void*); /* custom free function deep free of data */
}PCPResultSlot;

typedef struct {
ResultStateType resultStatus;
int resultSlots; /* Total number of slots contained in this result */
int nextFillSlot; /* internal to keep track of last filled slot */
PCPResultSlot resultSlot[1]; /* variable length slots */
}PCPResultInfo;

typedef struct PCPConnInfo{
void *pcpConn;
char     *errMsg; /* error message, or NULL if no error */
ConnStateType connState;
PCPResultInfo   *pcpResInfo;
FILE *Pfdebug; /* File pointer to output debug infor */
}PCPConnInfo;

struct WdInfo;

extern PCPConnInfo* pcp_connect(char *hostname, int port, char *username, char *password, FILE *Pfdebug);
extern void pcp_disconnect(PCPConnInfo* pcpConn);

extern PCPResultInfo *pcp_terminate_pgpool(PCPConnInfo* pcpCon,char mode);
extern PCPResultInfo *pcp_node_count(PCPConnInfo* pcpCon);
extern PCPResultInfo *pcp_node_info(PCPConnInfo* pcpCon, int nid);

extern PCPResultInfo *pcp_process_count(PCPConnInfo* pcpConn);
extern PCPResultInfo *pcp_process_info(PCPConnInfo* pcpConn, int pid);

extern PCPResultInfo *pcp_detach_node(PCPConnInfo* pcpConn,int nid);
extern PCPResultInfo *pcp_detach_node_gracefully(PCPConnInfo* pcpConn,int nid);
extern PCPResultInfo *pcp_attach_node(PCPConnInfo* pcpConn, int nid);
extern PCPResultInfo *pcp_pool_status(PCPConnInfo *pcpConn);
extern PCPResultInfo *pcp_recovery_node(PCPConnInfo* pcpConn, int nid);
extern PCPResultInfo *pcp_promote_node(PCPConnInfo* pcpConn, int nid);
extern PCPResultInfo *pcp_promote_node_gracefully(PCPConnInfo* pcpConn,int nid);
extern PCPResultInfo *pcp_watchdog_info(PCPConnInfo* pcpConn, int nid);
extern PCPResultInfo *pcp_set_backend_parameter(PCPConnInfo* pcpConn,char* parameter_name, char* value);

extern ResultStateType PCPResultStatus(const PCPResultInfo *res);
extern ConnStateType PCPConnectionStatus(const PCPConnInfo *conn);
extern void* pcp_get_binary_data(const PCPResultInfo *res, unsigned int slotno);
extern int pcp_get_int_data(const PCPResultInfo *res, unsigned int slotno);
extern int pcp_get_data_length(const PCPResultInfo *res, unsigned int slotno);
extern void pcp_free_result(PCPConnInfo* pcpConn);
extern void pcp_free_connection(PCPConnInfo* pcpConn);
extern int pcp_result_slot_count(PCPResultInfo* res);
extern char *pcp_get_last_error(PCPConnInfo* pcpConn);

extern int pcp_result_is_empty(PCPResultInfo* res);
/* ------------------------------
 * pcp_error.c
 * ------------------------------
 */

9 years agoFix white/black_memqcache_table_list not require quotaion
Yugo Nagata [Thu, 14 Jan 2016 04:33:14 +0000 (13:33 +0900)]
Fix white/black_memqcache_table_list not require quotaion

The tables and schemas name specified in *_memqcache_table_list
were needed to be quoted by double quotation since commit
43ff7d3de9db4c8a1143258f4ffff98682dab560. This is fixed
by stripping quote from table name before pattern matching.

Patch contributed by Dang Minh Huong.
Per [pgpool-hackers: 1323]

9 years agoFix port numbers in expected result of show pool_nodes
Yugo Nagata [Wed, 6 Jan 2016 04:26:46 +0000 (13:26 +0900)]
Fix port numbers in expected result of show pool_nodes

9 years agoFix regression test 003.failover for rhel7 postgresql rpm
Yugo Nagata [Wed, 6 Jan 2016 04:13:01 +0000 (13:13 +0900)]
Fix regression test 003.failover for rhel7 postgresql rpm

The expected result of 'show pool_nodes' is fixed to use
PGSOCKET_DIR in hostname column.

9 years agoAdd missing \n in help messages
Yugo Nagata [Tue, 5 Jan 2016 08:42:02 +0000 (17:42 +0900)]
Add missing \n in help messages

9 years agoFix to use timeout command to handle time out of regress test 062
Yugo Nagata [Fri, 25 Dec 2015 05:46:46 +0000 (14:46 +0900)]
Fix to use timeout command to handle time out of regress test 062

9 years agodoc: Add restriction about starting multiple pgpool simultaneously
Yugo Nagata [Mon, 28 Dec 2015 02:18:08 +0000 (11:18 +0900)]
doc: Add restriction about starting multiple pgpool simultaneously

9 years agoFix bug with "SET TRANSACTION READ ONLY".
Tatsuo Ishii [Wed, 2 Dec 2015 10:37:14 +0000 (19:37 +0900)]
Fix bug with "SET TRANSACTION READ ONLY".

Pgpool-II remembers that non read only queries (including SET) were
executed in an explicit transaction and adds a "writing transaction"
mark to the transaction. The mark affects the query routing behavior
of pgpool-II while running in streaming replication mode. Pgpool-II
starts sending queries to the primary after the mark is set. Because
the effect of writing queries may appear on standbys after some delay
in streaming replication mode, it is safer to route read queries to
the primary after the mark is set.

However there's oversight here. "SET TRANSACTION READ ONLY" does no
data modification and should be treated as an exception.

Per bug #157.

9 years agoFixing [pgpool-II 0000139]: broken arping_cmd
Muhammad Usama [Wed, 18 Nov 2015 13:58:49 +0000 (18:58 +0500)]
Fixing [pgpool-II 0000139]: broken arping_cmd

wd_chk_setuid() function was bailing out with the error message as soon as it
finds the setuid bit is not set on any configured network command and was
ignoring the rest of configurations.

9 years agoFix previous commit for regression test 055
Yugo Nagata [Wed, 11 Nov 2015 07:00:36 +0000 (16:00 +0900)]
Fix previous commit for regression test 055

9 years agoFix previous commit for regression test 055
Yugo Nagata [Wed, 11 Nov 2015 07:00:36 +0000 (16:00 +0900)]
Fix previous commit for regression test 055

9 years agoFix regression test 055 for rhel7 rpm
Yugo Nagata [Tue, 10 Nov 2015 12:32:14 +0000 (21:32 +0900)]
Fix regression test 055 for rhel7 rpm

9 years agoFix a bug of regress.sh option handling
Yugo Nagata [Mon, 9 Nov 2015 10:32:40 +0000 (19:32 +0900)]
Fix a bug of regress.sh option handling

9 years agoAdd missing descriptions about default values to documents
Yugo Nagata [Mon, 9 Nov 2015 05:20:50 +0000 (14:20 +0900)]
Add missing descriptions about default values to documents

9 years agoFix the previous commit's echo missing redirect to conf file
Yugo Nagata [Thu, 5 Nov 2015 17:29:28 +0000 (02:29 +0900)]
Fix the previous commit's echo missing redirect to conf file

9 years agoAdd option to regress.sh and pgpool_setup for unix domain socket directory
Yugo Nagata [Wed, 4 Nov 2015 09:30:20 +0000 (18:30 +0900)]
Add option to regress.sh and pgpool_setup for unix domain socket directory

The new option of regress.sh is -s to specivy unix domain socket
directory. Default is /tmp. And environment variable PGSOCKET_DIR
is added for pgpool_setup

9 years agoFix pgpool_setup to use DEFAULT_PGSOCKET_DIR in pg_config_manual.h
Yugo Nagata [Wed, 4 Nov 2015 07:28:23 +0000 (16:28 +0900)]
Fix pgpool_setup to use DEFAULT_PGSOCKET_DIR in pg_config_manual.h

Some Postgresql rpms define DEFAULT_PGSOCKET_DIR as /tmp, others as
/var/run/postgresql. This affects not only PostgreSQL server but
also libpq and psql.

This is a workaround for regression test. We might have to fix
pgpool-II code to control default value of backend_hostname*.

9 years agoForce pgpool_setup to set unix_socket_directories to '/tmp'
Yugo Nagata [Wed, 4 Nov 2015 04:56:27 +0000 (13:56 +0900)]
Force pgpool_setup to set unix_socket_directories to '/tmp'

This is a workaround for PostgreSQL RHEL7 RPM, which sets
it to '/var/run/postgresql'.

9 years agoUnbreak "make dist".
Tatsuo Ishii [Sat, 31 Oct 2015 00:35:30 +0000 (09:35 +0900)]
Unbreak "make dist".

While removing some directories under src/test, Makefile.am was left
unchaged and "make dist" has been broken since then.

9 years agoIgnore close statement/portal request if they do not exist.
Tatsuo Ishii [Fri, 30 Oct 2015 06:08:42 +0000 (15:08 +0900)]
Ignore close statement/portal request if they do not exist.

In this case just returns a close complete message to client.
This is a back port of commit:

1a37e1c35bd8b6f10f524693bbcb7b51f73b4bf0

which should have been back ported earlier.

9 years agoFix regression test 065.
Tatsuo Ishii [Thu, 29 Oct 2015 04:26:44 +0000 (13:26 +0900)]
Fix regression test 065.

The path to JDBC driver was explicitly defined. This is wrong. This
should be inherited from JDBC_DRIVER environment variable.

9 years agoFix in memory query cache bug reported in bug#152.
Tatsuo Ishii [Mon, 19 Oct 2015 04:20:05 +0000 (13:20 +0900)]
Fix in memory query cache bug reported in bug#152.

If extended query protocol is used and a bind/execute message arrives
which uses a statement created by prior parse message, the temp_cache
is not initialized by a parse messages. Thus messages are added to pre
existing temp cache buffer which causes the trouble (when the cached
result returns, Data Row message and Command Complete message appeared
*twice*).

Also new regression test is added to check the bug.
t-ishii@localhost:

9 years agoUpdate copyright year.
Tatsuo Ishii [Fri, 16 Oct 2015 05:32:24 +0000 (14:32 +0900)]
Update copyright year.

9 years agoFix bugs with data modifying WITH clause reported in bug#153.
Tatsuo Ishii [Wed, 14 Oct 2015 03:09:42 +0000 (12:09 +0900)]
Fix bugs with data modifying WITH clause reported in bug#153.

pgpool-II does not recognize the data modifying WITH clause despite
pgpool-II 3.3 or after has SQL parser which recognizes it. The bug has
been fixed in pgpool-II 3.5 (having PostgreSQL 9.5 parser).

Data modifying WITH clause was introduced in PostgreSQL 9.1. Since
pgpool-II 3.3 has 9.2 parser and pgpool-II 3.4 has 9.4 parser, the fix
is back ported to pgpool-II 3.3 and 3.4.

10 years agoFix wrong description in documents about log_standby_delay
Yugo Nagata [Fri, 4 Sep 2015 05:10:39 +0000 (14:10 +0900)]
Fix wrong description in documents about log_standby_delay

10 years agoFix ancient bug of pool_push() and friends.
Tatsuo Ishii [Thu, 3 Sep 2015 01:28:29 +0000 (10:28 +0900)]
Fix ancient bug of pool_push() and friends.

It allocates buffer using realloc and uses the pointer
returned. However it does the pointer calculation *before* realloc
gets called. So the calculation uses the old pointer value, which
causes various problems including segfault later. It is surprising
that this bug was not found earlier because the bug was there since
the function was added. This is probably due to the fact that actual
pointer moving does not happen until certain amount of memory.

Also there were other problems with it. The buffer pointer and buffer
size variable is not initialized. The buffer is not freed by
pool_close. Typo in debugging message (3.4 or later only). They are
fixed as well.

10 years agoFix regression test driver.
Tatsuo Ishii [Thu, 27 Aug 2015 04:07:35 +0000 (13:07 +0900)]
Fix regression test driver.

In pgpool-II 3.5, libpcp.a is not compatible with previous ones. This
results in segfault when pcp_recovery_node gets executed if the
command links to older version of the library. Solution is, set
${PGPOOL_INSTALL_DIR}/lib to LD_LIBRARY_PATH so that the command links
proper version of library.

10 years agoFix compiler warning.
Tatsuo Ishii [Mon, 24 Aug 2015 02:54:17 +0000 (11:54 +0900)]
Fix compiler warning.

Since memqcache_total_size is 64bit integer, the format string should
be %ld, rather than %d.

10 years agoRemove rpm_installer directory
Yugo Nagata [Fri, 21 Aug 2015 06:38:09 +0000 (15:38 +0900)]
Remove rpm_installer directory

Codes of RPM building and installer are maintained by GitHub.

10 years agoMove 006 memory leak test to test/regression from src/test/regression
Yugo Nagata [Fri, 21 Aug 2015 06:34:03 +0000 (15:34 +0900)]
Move 006 memory leak test to test/regression from src/test/regression

It seem to be git-cherry-pick mistake.

10 years agoRemove tests directory which are incorporated into regression test
Yugo Nagata [Fri, 21 Aug 2015 06:33:17 +0000 (15:33 +0900)]
Remove tests directory which are incorporated into regression test

10 years agoAdd timestamp-rewrite unit test to regression test suite
Yugo Nagata [Thu, 20 Aug 2015 04:06:25 +0000 (13:06 +0900)]
Add timestamp-rewrite unit test to regression test suite

10 years agoFix typo in Document
Yugo Nagata [Fri, 21 Aug 2015 04:35:35 +0000 (13:35 +0900)]
Fix typo in Document

10 years agoFix complication error and segfault of timestamp rewrite test
Yugo Nagata [Wed, 19 Aug 2015 09:53:59 +0000 (18:53 +0900)]
Fix complication error and segfault of timestamp rewrite test

10 years agoFix inconsistency of sequence values in replication mode
Yugo Nagata [Wed, 19 Aug 2015 08:07:15 +0000 (17:07 +0900)]
Fix inconsistency of sequence values in replication mode

Due to the following commit, table names were always quoted
in queries to check needs for insert lock, whether this is
view, wheter this has default value of timestamp etc. However,
when schema name was provided, table name was quoted wrongly as
like "public.tbl" instead of "public"."tbl". So, pool_regclass
and to_regclass couldn't find right talbe oid and insert lock
was never executed. This caused inconsistency between DB nodes.

In previous codes, quotation marks "" are once remove from
table name returnd by nodeToString, and re-quoted in issued
query. Instead, fixed codes don't remove and use directy in
pgpool_regclass or to_regclass. make_table_from_rangevar()
are also fixed to return table name including quotation marks.
However, when neither pgool_regclass or to_regclass is available,
quotation marks and schema name are removed from table name,
because pg_class.relname is used in this case.

In addition, fix to use to_regclass in insert lock functions
if available.

10 years agoFix regress test to sleep after pgpool_reload
Yugo Nagata [Wed, 19 Aug 2015 07:49:24 +0000 (16:49 +0900)]
Fix regress test to sleep after pgpool_reload

Some regression tests test behaviors after pgpool-II configuration
is modified and reloaded. However, sometimes these modification
were not applied to pgpool just after reloading.

It was observed after the following commit.

 commit ba24a708ed61d6a5fa296451b194c4b448ed5966
 Author: Tatsuo Ishii <ishii@postgresql.org>
 Date:   Thu Aug 6 13:02:42 2015 +0900

 Issue fsync() when writing pgpool_status.

 This ensures that pgpool_status is saved to permanent storage and
 allow to survive after system crash.

It seem to be because fsync() takes a time before SIGHUP is sent
to child processes in reload_config().

Fix is to add sleep to wait for applying modification after
pgpool_reload.

In addition, some messages are added to test for debugging.

10 years agoFix broken regression test for native replication
Yugo Nagata [Tue, 18 Aug 2015 10:31:03 +0000 (19:31 +0900)]
Fix broken regression test for native replication

Test for insert lock didn't work.

10 years agoFix false alert of regression tset 062
Yugo Nagata [Tue, 18 Aug 2015 10:25:30 +0000 (19:25 +0900)]
Fix false alert of regression tset 062

Sleep before timedout was too short.

10 years agoIssue fsync() when writing pgpool_status.
Tatsuo Ishii [Thu, 6 Aug 2015 06:15:24 +0000 (15:15 +0900)]
Issue fsync() when writing pgpool_status.

This ensures that pgpool_status is saved to permanent storage and
allow to survive after system crash.

10 years agoFix misinformation regarding load balancing in docs.
Tatsuo Ishii [Wed, 5 Aug 2015 06:19:44 +0000 (15:19 +0900)]
Fix misinformation regarding load balancing in docs.

In streaming replication mode, DECLARE, FETCH, CLOSE and SHOW are sent
to primary node only. Pointed out in [pgpool-general-jp: 1378].

10 years agoPrepare 3.3.7 V3_3_7 V3_3_7_RPM1
Yugo Nagata [Fri, 24 Jul 2015 05:33:41 +0000 (14:33 +0900)]
Prepare 3.3.7

10 years agoDo not send a query for checking insert lock in non replication mode with extended...
Tatsuo Ishii [Sun, 21 Jun 2015 09:51:34 +0000 (18:51 +0900)]
Do not send a query for checking insert lock in non replication mode with extended query

This unnecessary code was there since day 0.

10 years agoAllow to use in memory query cache size > 4GB
Tatsuo Ishii [Sat, 20 Jun 2015 10:03:22 +0000 (19:03 +0900)]
Allow to use in memory query cache size > 4GB

This should have been allowed since in memory query cache was born.

10 years agoAdd a test case for previous commit.
Tatsuo Ishii [Fri, 19 Jun 2015 17:14:41 +0000 (02:14 +0900)]
Add a test case for previous commit.

10 years agoFix the case when user table includes spaces.
Tatsuo Ishii [Fri, 19 Jun 2015 16:39:44 +0000 (01:39 +0900)]
Fix the case when user table includes spaces.

For example if table names including space are used (of course using
delimited identifier), pgpool-II cannot be handled correctly by the
internal functions which access system catalogs and it results in SQL
errors. Solution is, to always use delimited identifier. Per bug#136.
Also see [pgpool-general: 3818].

10 years agoFix "select() system call interrupted" error.
Tatsuo Ishii [Fri, 29 May 2015 00:27:41 +0000 (09:27 +0900)]
Fix "select() system call interrupted" error.

The health check process complains above then

ERROR:  failed to make persistent db connection
DETAIL:  connection to host:"x.x.x.x:5432 failed

But the healthchek does not trigger fail over nor retrying (if the
retry parameter is configured). So except the annoying message above
everything goes well.

I guess this is caused by SIGCHLD interrupt while select(2) waiting
for completion of connect(2) call. It is likely that pgpool child dies
because of child_life_time. The directive is triggered if child is
idle for specified period. Since this happens independently among each
child process, if num_init_children is big (in the reported case, it
is 2000). So the case could occur more easily if 1) num_init_children
is big and 2) pgpool children go into idle state (no query arrived
from client for child_life_time seconds).

We suppose a system call interruption could occur by SIGALRM which is
set by pgpool to detect time of the connect(2) call if
health_check_timeout is non 0. However we did not think about the case
above.

The fix is, if select(2) is interrupted by a system call, check
health_check_timeout variable and it is not set, we can assume that
the interruption is caused by other than SIGALRM and retries the
select(2).

Original bug report is [pgpool-general: 3756] Connection Interrupted.
Patch created by me. Enhancement from Usama.

Also I got similar report (but on 3.3) from another user. So I will
make similar commit to 3.3 stable tree as well.

10 years agoFix outdated limitation description about load balancing using JDBC driver.
Tatsuo Ishii [Wed, 13 May 2015 01:29:14 +0000 (10:29 +0900)]
Fix outdated limitation description about load balancing using JDBC driver.

Even if autocommit is false, load balancing is possible in certain conditions.

10 years agoClarify description of pcp_promote_node.
Tatsuo Ishii [Mon, 11 May 2015 06:48:26 +0000 (15:48 +0900)]
Clarify description of pcp_promote_node.

It does not actually promote PostgreSQL standby.

10 years agoClarify load balancing condition.
Tatsuo Ishii [Mon, 11 May 2015 06:33:15 +0000 (15:33 +0900)]
Clarify load balancing condition.

10 years agoPassing empty string parameters in failover command when pgpool-II does not have...
Muhammad Usama [Wed, 29 Apr 2015 14:13:58 +0000 (19:13 +0500)]
Passing empty string parameters in failover command when pgpool-II does not have a value for any particular parameter

Instead of omitting the values for the parameters when pgpool-II does not have
any value for a particular parameter, It now passes an empty string instead to
the failover command, This makes sure that failover script will always receive
the exact number of expected parameters.

10 years agoFixing "cannot find xlog functions" error in pgpool-recovery
Muhammad Usama [Thu, 9 Apr 2015 17:38:59 +0000 (22:38 +0500)]
Fixing "cannot find xlog functions" error in pgpool-recovery
The argument data type of PG's pg_xlogfile_name() function has been changed from
text to pg_lsn since PostgreSQL 9.4. And pgpool-recovery was still trying to
locate the function by old signature.

10 years agoPrepare 3.3.6 V3_3_6
Yugo Nagata [Wed, 8 Apr 2015 07:27:46 +0000 (16:27 +0900)]
Prepare 3.3.6

10 years agoFixing a problem with pcp_detach_node, When graceful node detach is requested
Muhammad Usama [Tue, 7 Apr 2015 14:54:20 +0000 (19:54 +0500)]
Fixing a problem with pcp_detach_node, When graceful node detach is requested

gracefully detaching a node by pcp_detach_node should check if it is allowed to
process detach_node command on the particular node before blocking the incoming
connections and closing the existing connections.

10 years agoUpdate table and flowchart of where a query should be sent
Yugo Nagata [Tue, 7 Apr 2015 08:02:45 +0000 (17:02 +0900)]
Update table and flowchart of where a query should be sent

10 years agoAdd a regression test for SELECT error hangs bug
Yugo Nagata [Mon, 30 Mar 2015 07:10:29 +0000 (16:10 +0900)]
Add a regression test for SELECT error hangs bug

The fix commit is:

commit 41ee68c0696bb484d0a68bbc72677b80a15d4410
Author: Yugo Nagata <nagata@sraoss.co.jp>
Date:   Mon Mar 30 15:23:32 2015 +0900

    Fix a hang when an error occurs in a transaction block with replication mode

10 years agoFix a hang when an error occurs in a transaction block with replication mode
Yugo Nagata [Mon, 30 Mar 2015 06:23:32 +0000 (15:23 +0900)]
Fix a hang when an error occurs in a transaction block with replication mode

When an error occurs at a backend node in a transaction block with
replication mode, pgpool-II sends an invalid query to other
backends to sync transaction states. However, previously, this was
not sent to master node, and pgpool-II was waiting for master's
response forever.

This bug is caused to a specification change since 3.3.0 that load
balance is allowed in a transaction block with replication mode.

To fix this, pgpool sends the invalid query to all backends,
including master, except the node which the original query was sent.

10 years agoUse to_regclass if available in time stamp rewriting in replication mode.
Tatsuo Ishii [Sat, 21 Mar 2015 00:54:08 +0000 (09:54 +0900)]
Use to_regclass if available in time stamp rewriting in replication mode.

Newer pgpool-II supposed to use to reg_class, but this was
accidentally left.

10 years agoSupport SSL certificate chains in the certificate file for incoming frontend connections.
Muhammad Usama [Wed, 18 Mar 2015 10:21:31 +0000 (15:21 +0500)]
Support SSL certificate chains in the certificate file for incoming frontend connections.

10 years agoUpdate document of condition for load balancig
Yugo Nagata [Fri, 6 Mar 2015 08:47:05 +0000 (17:47 +0900)]
Update document of condition for load balancig

Load balancing is possible in an explicit transaction block
even in replication mode since 3.3.0.

10 years agoEnlarge POOLCONFIG_MAXDESCLEN to 80.
Tatsuo Ishii [Thu, 19 Feb 2015 01:33:57 +0000 (10:33 +0900)]
Enlarge POOLCONFIG_MAXDESCLEN to 80.

This is used in show pool_status command and limits the length of
parameter description.  Unfortunately recovery_timeout description is
64 chars, which is 1 byte longer than former definition of the macro
because we need on more byte for null termination.

10 years agoUpdate release number V3_3_5_RPM3
Yugo Nagata [Fri, 20 Feb 2015 08:01:58 +0000 (17:01 +0900)]
Update release number

10 years agoRemove an unnecessary include directive
Yugo Nagata [Fri, 20 Feb 2015 07:31:09 +0000 (16:31 +0900)]
Remove an unnecessary include directive

10 years agoFix to set SIGCHLD to SIG_DFL instead of SIG_IGN in watchdog processes
Yugo Nagata [Fri, 20 Feb 2015 07:21:18 +0000 (16:21 +0900)]
Fix to set SIGCHLD to SIG_DFL instead of SIG_IGN in watchdog processes

When using waitpid, it isn't necessary to set SIGCHLD SIG_IGN. Rather,
waitpid returns ECHLD and WIFEXITED could be zero even when the child
process exit successfully. Due to this, it was recognized that ping
exited abnormally in error.

In addition, signal functions are replaced to pool_singal.

10 years agoFix to use void * for receiving return value of thread function
Yugo Nagata [Fri, 20 Feb 2015 05:27:41 +0000 (14:27 +0900)]
Fix to use void * for receiving return value of thread function

Previously int was used and this could occur stack buffer overflow.
This caused an infinity loop of ping error at bringing up or down
VIP, since a loop variable in a for loop was overwritten to zero.

10 years agoFix %tmpfiles_create to not be executed in RHEL/CentOS 6 V3_3_5_RPM2
Nozomi Anzai [Tue, 10 Feb 2015 07:43:23 +0000 (16:43 +0900)]
Fix %tmpfiles_create to not be executed in RHEL/CentOS 6

10 years agoMerge branch 'V3_3_STABLE' of ssh://git.postgresql.org/pgpool2 into V3_3_STABLE V3_3_5_RPM1
Nozomi Anzai [Fri, 6 Feb 2015 07:08:39 +0000 (16:08 +0900)]
Merge branch 'V3_3_STABLE' of ssh://git.postgresql.org/pgpool2 into V3_3_STABLE

10 years agopgpool.service is required only in RHEL/CentOS 7
Nozomi Anzai [Fri, 6 Feb 2015 07:08:00 +0000 (16:08 +0900)]
pgpool.service is required only in RHEL/CentOS 7

10 years agoPrepare 3.3.5 V3_3_5
Yugo Nagata [Thu, 5 Feb 2015 10:13:47 +0000 (19:13 +0900)]
Prepare 3.3.5

10 years agoAdd pgpool.service for systemd in RHEL/CentOS 7
Nozomi Anzai [Thu, 29 Jan 2015 09:43:02 +0000 (18:43 +0900)]
Add pgpool.service for systemd in RHEL/CentOS 7

10 years agoChange to use systemd if it is available and adopt to PostgreSQL 9.4
Nozomi Anzai [Thu, 29 Jan 2015 05:06:53 +0000 (14:06 +0900)]
Change to use systemd if it is available and adopt to PostgreSQL 9.4

10 years agoFix a mistake in the previous commit
Yugo Nagata [Wed, 7 Jan 2015 08:00:27 +0000 (17:00 +0900)]
Fix a mistake in the previous commit

Restore SIGCHLD handler to its original after executing if_up/down_cmd V3_3_STABLE
commit b9e532b9ab50b1cf1d090a187016a1d155ebc4fd

10 years agoRestore SIGCHLD handler to its original after executing if_up/down_cmd
Yugo Nagata [Wed, 7 Jan 2015 06:54:22 +0000 (15:54 +0900)]
Restore SIGCHLD handler to its original after executing if_up/down_cmd

Previously SIGCHLD was set to SIGIGN always after if_up/down_cmd.
This led to a incorrect error handling of ping or other commands
execution, and warning messages were output to log even when the
command exited successfully.

10 years agoFix occasional failure in regression test '004.watchdog'
Yugo Nagata [Mon, 5 Jan 2015 05:27:23 +0000 (14:27 +0900)]
Fix occasional failure in regression test '004.watchdog'

Switchover between pgpools sometimes fails, since the active
pgpool is stopped before the standby pgpool's watchdog is ready.
To avoid this, take a sleep before stopping the active.

The patch provided by uerhara in bug #127.

10 years agoFix for [pgpool-general: 3374] show pool_nodes V3_3_4_RPM4
Muhammad Usama [Tue, 23 Dec 2014 18:04:20 +0000 (23:04 +0500)]
Fix for [pgpool-general: 3374] show pool_nodes

The size of string for holding the node id in POOL_REPORT_NODES was too small
for ids having more than one digits. Also adjusting the port string size in
same structure which was lot more than what is actually required.

10 years agoFix bogus date and raise rpm version number.
Tatsuo Ishii [Sun, 21 Dec 2014 00:38:49 +0000 (09:38 +0900)]
Fix bogus date and raise rpm version number.

10 years agoCopy m4/* files.
Tatsuo Ishii [Sat, 20 Dec 2014 15:54:00 +0000 (00:54 +0900)]
Copy m4/* files.

Use autoreconf -i