1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-12-26 05:02:18 +00:00

Update to recent snapshot.

This commit is contained in:
Jun Kuriyama 2004-04-17 16:02:32 +00:00
parent d20e512a24
commit c030d50aaf
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=107364
13 changed files with 311 additions and 589 deletions

View File

@ -5,17 +5,16 @@
# $FreeBSD$
PORTNAME= pgcluster
PORTVERSION= 1.0.6b
PORTREVISION= 3
PORTVERSION= 1.0.6c.a13
CATEGORIES= databases
MASTER_SITES= ${MASTER_SITE_PGSQL}
MASTER_SITE_SUBDIR= v${BASEPGSQL}
DISTNAME= postgresql-base-${BASEPGSQL}
DIST_SUBDIR= postgresql
PATCH_SITES= http://hiroshima.sraw.co.jp/people/mitani/jpug/pgcluster/current/
PATCH_SITES= http://dist.bsdlab.org/
PATCHFILES= pgcluster-${PORTVERSION}-patch.tar.gz
PATCH_DIST_STRIP= -p1
PATCH_DIST_STRIP= -p0
MAINTAINER= kuriyama@FreeBSD.org
COMMENT=The multi-master and synchronous replication system for PostgreSQL
@ -25,6 +24,7 @@ RUN_DEPENDS= rsync:${PORTSDIR}/net/rsync
WRKSRC?= ${WRKDIR}/postgresql-${BASEPGSQL}
USE_GMAKE= yes
GNU_CONFIGURE= yes
USE_AUTOCONF_VER= 257
MAKE_FLAGS= # empty
MAKEFILE= # empty
CONFLICTS= postgresql-*
@ -79,12 +79,12 @@ post-patch:
post-build:
.if !defined(WITHOUT_PGCLUSTER_REPLICATION)
${MAKE} WRKSRC=${WRKSRC}/src/pgcluster/pgrp do-configure
${MAKE} WRKSRC=${WRKSRC}/src/pgcluster/pgrp do-build
${MAKE} WRKSRC=${WRKSRC}/src/pgcluster/pgrp run-autotools do-configure
${MAKE} WRKSRC=${WRKSRC}/src/pgcluster/pgrp AUTOCONF=autoconf257 do-build
.endif
.if !defined(WITHOUT_PGCLUSTER_LOADBALANCER)
${MAKE} WRKSRC=${WRKSRC}/src/pgcluster/pglb do-configure
${MAKE} WRKSRC=${WRKSRC}/src/pgcluster/pglb do-build
${MAKE} WRKSRC=${WRKSRC}/src/pgcluster/pglb run-autotools do-configure
${MAKE} WRKSRC=${WRKSRC}/src/pgcluster/pglb AUTOCONF=autconf257 do-build
.endif
pre-install:

View File

@ -1,4 +1,4 @@
MD5 (postgresql/postgresql-base-7.3.4.tar.gz) = 2b8600cc0f0c2d80271b533c394c886b
SIZE (postgresql/postgresql-base-7.3.4.tar.gz) = 7137288
MD5 (postgresql/pgcluster-1.0.6b-patch.tar.gz) = 405ea2a5f61a05c31ef16e3791be3ec4
SIZE (postgresql/pgcluster-1.0.6b-patch.tar.gz) = 181877
MD5 (postgresql/pgcluster-1.0.6c.a13-patch.tar.gz) = 298e8510ecf293b7f3d7c91da46705a4
SIZE (postgresql/pgcluster-1.0.6c.a13-patch.tar.gz) = 197987

View File

@ -2,7 +2,7 @@
#
# Copyright (c) 2004 IMG SRC, Inc. All rights reserved.
#
# $Id: check_pgcluster.pl,v 1.2 2004/02/25 06:09:25 kuriyama Exp $
# $Id: check_pgcluster.pl,v 1.4 2004/03/03 11:51:06 kuriyama Exp $
#
# Plugin for nagios.
#
@ -29,7 +29,7 @@ use strict;
use Getopt::Std;
use DBI;
my %O;
my ($ret, %O, @r) = (0);
getopts('H:p:U:P:w:', \%O);
$O{p} ||= 5432;
@ -37,25 +37,29 @@ $O{U} ||= "";
$O{P} ||= "";
usage() if (not $O{H} or not $O{w});
my $dbh = DBI->connect("dbi:Pg:dbname=template1;host=$O{H};port=$O{p}", $O{U}, $O{P});
my $dbh = DBI->connect("dbi:Pg:dbname=template1;host=$O{H};port=$O{p}",
$O{U}, $O{P}, { PrintError => 0 });
die if (not $dbh);
if ($dbh) {
my $sth = $dbh->prepare("select pgr_current_replicator()") or die;
$sth->execute or die;
@r = $sth->fetchrow_array;
$sth->finish;
my $sth = $dbh->prepare("select pgr_current_replicator()") or die;
$sth->execute or die;
my @r = $sth->fetchrow_array;
$sth->finish;
$dbh->disconnect;
$dbh->disconnect;
if (not defined $r[0] or length($r[0]) < 1) {
$ret = 2;
} elsif ($r[0] ne $O{w}) {
$ret = 1;
}
my $ret = 0;
if ($r[0] ne $O{w}) {
$ret = 1;
$ret = 2 if (length($r[0]) < 1);
} else {
$ret = 2;
}
my %STATUS = (2 => "CRITICAL", 1 => "WARNING", 0 => "OK");
printf "PGCLUSTER %s: %s\n", $STATUS{$ret}, $r[0];
printf "PGCLUSTER %s: %s\n", $STATUS{$ret}, $r[0] || "";
exit $ret;
# ============================================================

View File

@ -2,7 +2,7 @@
#
# Copyright (c) 2004 IMG SRC, Inc. All rights reserved.
#
# $Id: check_pgreplicate.pl,v 1.1 2004/02/23 06:06:13 kuriyama Exp $
# $Id: check_pgreplicate.pl,v 1.2 2004/04/16 12:10:53 kuriyama Exp $
#
# Plugin for nagios.
#
@ -39,9 +39,24 @@ my $HOSTNAME_MAX_LENGTH = 128;
my $DBNAME_MAX_LENGTH = 128;
my $USERNAME_MAX_LENGTH = 128;
# typedef struct ReplicateHeaderType
# {
# char cmdSys;
# char cmdSts;
# char cmdType;
# char dummy;
# char port[INT_LENGTH];
# char pid[INT_LENGTH];
# char query_size[INT_LENGTH];
# char except_host[HOSTNAME_MAX_LENGTH];
# char from_host[HOSTNAME_MAX_LENGTH];
# char dbName[DBNAME_MAX_LENGTH];
# char userName[USERNAME_MAX_LENGTH];
# struct timeval tv;
# } ReplicateHeader;
my $query = "dummy";
my $packet = pack "CCCCllla128a128a128a128ll", 0, 0, 0, ord("o"),
0, 0, 5, "except host", "from host", "db name", "user name",
my $packet = pack "CCCCa12a12a12a128a128a128a128ll", 0, 0, ord("o"), 0,
"0", "0", "5", "except host", "from host", "db name", "user name",
time, 0;
print $sock $packet;

View File

@ -1,23 +0,0 @@
--- src/backend/libpq/recovery.c.orig Fri Feb 20 11:38:39 2004
+++ src/backend/libpq/recovery.c Mon Feb 23 14:44:15 2004
@@ -756,14 +756,14 @@
if (Debug_pretty_print)
{
- elog(DEBUG1,"no = %d\n",packet->packet_no);
- elog(DEBUG1,"max_connect = %d\n",packet->max_connect);
- elog(DEBUG1,"port = %d\n",packet->port);
- elog(DEBUG1,"recoveryPort = %d\n",packet->recoveryPort);
+ elog(DEBUG1,"no = %d",packet->packet_no);
+ elog(DEBUG1,"max_connect = %d",packet->max_connect);
+ elog(DEBUG1,"port = %d",packet->port);
+ elog(DEBUG1,"recoveryPort = %d",packet->recoveryPort);
if (packet->hostName != NULL)
- elog(DEBUG1,"hostName = %s\n",packet->hostName);
+ elog(DEBUG1,"hostName = %s",packet->hostName);
if (packet->pg_data != NULL)
- elog(DEBUG1,"pg_data = %s\n",packet->pg_data);
+ elog(DEBUG1,"pg_data = %s",packet->pg_data);
}
}

View File

@ -1,46 +1,18 @@
--- src/backend/libpq/replicate.c.orig.1 Fri Feb 20 11:38:39 2004
+++ src/backend/libpq/replicate.c Wed Feb 25 09:28:07 2004
@@ -645,6 +645,7 @@
--- src/backend/libpq/replicate.c 17 Apr 2004 14:41:22 -0000 1.1.1.11
+++ src/backend/libpq/replicate.c 17 Apr 2004 14:44:29 -0000 1.6
@@ -635,6 +635,7 @@
return NULL;
}
sock = get_replicate_server_socket( sp , socket_type);
+ elog(DEBUG1, "get_replicate_server_socket() returns %d", sock);
if (sock == -1)
if (sock < 0)
{
if (Debug_pretty_print)
@@ -668,7 +669,7 @@
while (send_replicate_packet(sock,&header,query_string) != STATUS_OK)
{
if (Debug_pretty_print)
- elog(DEBUG1,"replication server: %s may be down",sp->hostName);
+ elog(DEBUG1,"replication server: %s may be down (cnt=%d, sock=%d)", sp->hostName, cnt, sock);
close_replicate_server_socket ( sp , socket_type);
sp->useFlag = DATA_ERR;
sock = search_new_replication_server( sp,socket_type,&header);
@@ -760,6 +761,11 @@
fd_set wmask;
struct timeval timeout;
+ /* check parameter */
+ if ((sock <= 0) || (header == NULL) || (query_string == NULL))
+ {
+ return STATUS_ERROR;
+ }
/*header->query_size +=1;*/
header_size = sizeof(ReplicateHeader);
buf_size = header_size + header->query_size + 4;
@@ -776,6 +782,7 @@
/*
* Wait for something to happen.
*/
+ elog(DEBUG1, "send_replicate_packet(%d, %p, %s)", sock, header, query_string);
FD_ZERO(&wmask);
FD_SET(sock,&wmask);
rtn = select(sock+1, (fd_set *)NULL, &wmask, (fd_set *)NULL, &timeout);
@@ -1767,4 +1774,29 @@
return false;
@@ -2067,6 +2068,30 @@
return 1;
}
}
return 0;
+}
+
+extern Datum pgr_current_replicator(PG_FUNCTION_ARGS);
+PG_FUNCTION_INFO_V1(pgr_current_replicator);
@ -64,6 +36,6 @@
+ memcpy(VARDATA(result), buf, len);
+
+ PG_RETURN_TEXT_P(result);
+}
+
}
#endif /* USE_REPLICATION */

View File

@ -1,12 +1,11 @@
--- src/include/catalog/pg_proc.h.orig Tue Feb 24 23:17:16 2004
+++ src/include/catalog/pg_proc.h Tue Feb 24 23:28:44 2004
@@ -3117,7 +3117,8 @@
--- src/include/catalog/pg_proc.h 27 Feb 2004 11:57:12 -0000 1.1.1.1
+++ src/include/catalog/pg_proc.h 6 Apr 2004 12:44:53 -0000 1.2
@@ -3117,6 +3117,8 @@
DATA(insert OID = 2307 ( opaque_out PGNSP PGUID 12 f f t f i 1 2275 "2282" opaque_out - _null_ ));
DESCR("(internal)");
-
+DATA(insert OID = 2400 ( pgr_current_replicator PGNSP PGUID 12 f f t f v 0 25 "" pgr_current_replicator - _null_ ));
+DESCR("Current replication server");
/*
* Symbolic values for provolatile column: these indicate whether the result
* of a function is dependent *only* on the values of its explicit arguments,

View File

@ -1,6 +1,6 @@
--- src/pgcluster/pgrp/main.c.orig Fri Feb 20 11:38:40 2004
+++ src/pgcluster/pgrp/main.c Mon Feb 23 12:45:51 2004
@@ -148,7 +148,7 @@
--- src/pgcluster/pgrp/main.c 16 Apr 2004 10:17:45 -0000 1.1.1.9
+++ src/pgcluster/pgrp/main.c 16 Apr 2004 10:21:06 -0000 1.6
@@ -156,7 +156,7 @@
char * query;
/* set function name */
@ -9,7 +9,7 @@
if (header == NULL)
{
@@ -171,7 +171,7 @@
@@ -179,7 +179,7 @@
}
if (r == 0)
{
@ -18,48 +18,49 @@
return NULL;
}
read_size += r;
@@ -258,18 +258,18 @@
@@ -311,18 +311,18 @@
/* set function name */
set_function("replicate_packet_send");
- show_debug("cmdSts=%c\n",header->cmdSts);
- show_debug("cmdType=%c\n",header->cmdType);
- show_debug("port=%d\n",header->port);
- show_debug("pid=%d\n",header->pid);
- show_debug("port=%d\n",ntohs(header->port));
- show_debug("pid=%d\n",ntohs(header->pid));
- show_debug("except_host=%s\n",header->except_host);
- show_debug("from_host=%s\n",header->from_host);
- show_debug("dbName=%s\n",header->dbName);
- show_debug("userName=%s\n",header->userName);
- show_debug("recieve sec=%u\n",header->tv.tv_sec);
- show_debug("recieve usec=%u\n",header->tv.tv_usec);
- show_debug("query_size=%d\n",header->query_size);
- show_debug("recieve sec=%u\n",ntohl(header->tv.tv_sec));
- show_debug("recieve usec=%u\n",ntohl(header->tv.tv_usec));
- show_debug("query_size=%d\n",ntohl(header->query_size));
- show_debug("query=%s\n",query);
+ show_debug("cmdSts=%c",header->cmdSts);
+ show_debug("cmdType=%c",header->cmdType);
+ show_debug("port=%d",header->port);
+ show_debug("pid=%d",header->pid);
+ show_debug("port=%d",ntohs(header->port));
+ show_debug("pid=%d",ntohs(header->pid));
+ show_debug("except_host=%s",header->except_host);
+ show_debug("from_host=%s",header->from_host);
+ show_debug("dbName=%s",header->dbName);
+ show_debug("userName=%s",header->userName);
+ show_debug("recieve sec=%u",header->tv.tv_sec);
+ show_debug("recieve usec=%u",header->tv.tv_usec);
+ show_debug("query_size=%d",header->query_size);
+ show_debug("recieve sec=%u",ntohl(header->tv.tv_sec));
+ show_debug("recieve usec=%u",ntohl(header->tv.tv_usec));
+ show_debug("query_size=%d",ntohl(header->query_size));
+ show_debug("query=%s",query);
/*
* loop while registrated cluster DB exist
@@ -277,7 +277,9 @@
ptr = Host_Tbl_Begin;
@@ -333,8 +333,10 @@
show_debug("useFlag[%d]",ptr->useFlag);
while(ptr->useFlag != DB_TBL_END)
{
+ set_function("replicate_packet_send");
same_host = false;
sem_num = ptr->hostNum;
+ show_debug("loop: cnt=%d, hostNum=%d, hostName=%s, port=%d, recoveryPort=%d, useFlag=%d", cnt, ptr->hostNum, ptr->hostName, ptr->port, ptr->recoveryPort, ptr->useFlag);
+ show_debug("loop: cnt=%d, hostNum=%d, hostName=%s, port=%d, recoveryPort=%d, useFlag=%d", loop_cnt++, ptr->hostNum, ptr->hostName, ptr->port, ptr->recoveryPort, ptr->useFlag);
/*
* check the status of the cluster DB
*/
@@ -291,7 +293,7 @@
@@ -348,7 +350,7 @@
*/
if (PGRis_master_in_recovery(ptr->hostName, ptr->port) == true)
{
@ -68,48 +69,47 @@
ptr ++;
continue;
}
@@ -368,6 +370,8 @@
if (sem_num > 0)
PGRsem_lock(SemID,sem_num);
rtn = replicate_packet_send_each_server( ptr, cnt,header, query, dest);
+ set_function("replicate_packet_send");
+ show_debug("replicate_packet_send_each_server returns %d (useFlag=%d", rtn, ptr->useFlag);
show_debug("sem_unlock[%d]",sem_num);
if (sem_num > 0)
PGRsem_unlock(SemID,sem_num);
@@ -382,7 +386,8 @@
cnt ++;
}
@@ -371,6 +373,8 @@
{
snprintf(PGR_Result,PGR_MESSAGE_BUFSIZE,"%d,%u,%u", PGR_SET_CURRENT_TIME_FUNC_NO,(unsigned int)ntohl(header->tv.tv_sec),(unsigned int)ntohl(header->tv.tv_usec));
}
+ set_function("replicate_packet_send");
+ show_debug("replicate_packet_send_each_server returns %d (useFlag=%d", rtn, ptr->useFlag);
show_debug("sem_lock[%d]",sem_num);
if (sem_num > 0)
PGRsem_lock(SemID,sem_num);
@@ -483,7 +487,7 @@
ptr ++;
PGR_Response_Inf->current_cluster ++;
- }
+ }
+ show_debug("replicate_packet_send() end");
return STATUS_OK;
}
@@ -412,10 +417,10 @@
show_debug("replicate_packet_send end");
if (status == STATUS_ABORTED)
{
@@ -525,10 +529,10 @@
set_function("replicate_packet_send_each_server");
host = ptr->hostName;
- show_debug("except:%d@%s host:%d@%s\n",
+ show_debug("except:%d@%s host:%d@%s",
header->port,header->except_host,
ntohs(header->port),header->except_host,
ptr->port,ptr->hostName);
- show_debug("send replicate to:%s\n",host);
+ show_debug("send replicate to:%s",host);
/*
* send query to cluster DB
*/
@@ -427,6 +432,8 @@
memset(PGR_Result,0,PGR_MESSAGE_BUFSIZE);
@@ -539,6 +543,8 @@
}
rtn = PGRsend_replicate_packet_to_server( ptr, header,query,PGR_Result);
+ set_function("replicate_packet_send_each_server");
+ show_debug("PGRsend_replicate_packet_to_server() returns %d", rtn);
/*
if ((header->cmdSts == CMD_STS_QUERY ) &&
((header->cmdType == CMD_TYPE_INSERT) ||
(header->cmdType == CMD_TYPE_UPDATE)))
@@ -476,7 +483,7 @@
@@ -597,7 +603,7 @@
}
send_ptr = PGR_Result;
buf_size = PGR_MESSAGE_BUFSIZE;
@ -118,7 +118,7 @@
if (buf_size < 1)
buf_size = 1;
@@ -491,7 +498,7 @@
@@ -612,7 +618,7 @@
rtn = select(dest+1, (fd_set *)NULL, &wmask, (fd_set *)NULL, &timeout);
if (rtn && FD_ISSET(dest, &wmask))
{
@ -127,25 +127,25 @@
for (;;)
{
s = send(dest,send_ptr + send_size,buf_size - send_size ,0);
@@ -513,7 +520,7 @@
@@ -634,7 +640,7 @@
send_size += s;
if (send_size == buf_size)
{
- show_debug("%d send",send_size);
+ show_debug("%d bytes sent", send_size);
+ show_debug("%d bytes sent",send_size);
status = STATUS_OK;
if (wait == PGR_WAIT_ANSWER)
{
@@ -560,7 +567,7 @@
@@ -682,7 +688,7 @@
rtn = select(dest+1, &rmask, (fd_set *)NULL, (fd_set *)NULL, &timeout);
if (rtn && FD_ISSET(dest, &rmask))
{
- show_debug("read_answer selected\n");
- show_debug("read_answer selected");
+ show_debug("read_answer selected (dest=%d)", dest);
answer = NULL;
answer = read_packet(dest,&header);
show_debug("answer[%s]",answer);
@@ -630,6 +637,43 @@
if (answer == NULL)
@@ -773,6 +779,43 @@
return NULL;
}
@ -189,7 +189,7 @@
/*--------------------------------------------------------------------
* SYMBOL
* replicate_loop()
@@ -665,11 +709,11 @@
@@ -811,11 +854,11 @@
}
if (pid == 0)
{
@ -206,7 +206,7 @@
setpgid(0,pgid);
/* child loop */
@@ -687,14 +731,21 @@
@@ -833,20 +876,27 @@
FD_ZERO(&rmask);
FD_SET(sock,&rmask);
rtn = select(sock+1, &rmask, (fd_set *)NULL, (fd_set *)NULL, &timeout);
@ -222,25 +222,31 @@
- if (query == NULL)
+ if (query == NULL && errno != 0)
{
- show_error("read_packet failed");
- show_error("session closed");
+ show_error("read_packet failed (errno=%d)", errno);
+ break;
+ }
+ if (header.cmdType == 'o') {
+ dump_status(sock);
if (PGR_Cascade == true)
{
PGRupper_session_closed();
}
break;
}
if (header.cmdSts == 0)
@@ -708,7 +759,7 @@
}
}
gettimeofday(&(header.tv),NULL);
+ if (header.cmdType == 'o') {
+ dump_status(sock);
+ break;
+ }
if (header.cmdSys == CMD_SYS_CASCADE )
{
PGR_Cascade = true;
@@ -869,7 +919,7 @@
gettimeofday(&tv,NULL);
header.tv.tv_sec = htonl(tv.tv_sec);
header.tv.tv_usec = htonl(tv.tv_usec);
- show_debug("query :: %s\n",query);
+ show_debug("query :: %s",query);
RecoveryStatus = PGRget_recovery_status();
PGRcheck_recovered_host();
@@ -781,7 +832,7 @@
@@ -965,7 +1015,7 @@
show_error("fopen failed: (%s)",strerror(errno));
return STATUS_ERROR;
}
@ -249,35 +255,25 @@
/*
* read configuration file
@@ -915,10 +966,10 @@
/* set load balance table */
for ( i = 0 ; i <= lb_cnt ; i ++)
{
+ memset((LoadBalanceTbl + i),0,sizeof(RecoveryTbl));
@@ -1130,7 +1180,7 @@
(LoadBalanceTbl + i)->port = -1;
(LoadBalanceTbl + i)->sock = -1;
}
- memset((LoadBalanceTbl + i),0,sizeof(RecoveryTbl));
+ memset((LoadBalanceTbl + i),0,sizeof(RecoveryTbl)); /* kuriyama: needed? */
PGR_Free_Conf_Data();
/* allocate result buffer of query */
@@ -954,13 +1005,13 @@
/* set function name */
set_function("replicate_main");
- show_debug("replicate mail %d port bind\n",Port_Number);
+ show_debug("replicate mail %d port bind",Port_Number);
status = PGR_Create_Socket_Bind(&fd, "", Port_Number);
if (status != STATUS_OK)
@@ -1219,7 +1269,7 @@
{
PGRreplicate_exit(0);
}
- show_debug("replicate mail %d port bind OK \n",Port_Number);
+ show_debug("replicate mail %d port bind OK",Port_Number);
- show_debug("replicate main %d port bind OK \n",Port_Number);
+ show_debug("replicate main %d port bind OK",Port_Number);
for (;;)
{
@@ -976,11 +1027,14 @@
start_up_replication_server();
@@ -1237,11 +1287,14 @@
*/
FD_ZERO(&rmask);
FD_SET(fd,&rmask);
@ -294,9 +290,9 @@
/*
* get recovery status.
*/
@@ -1315,12 +1369,12 @@
@@ -1597,12 +1650,12 @@
if (init_server_tbl(path) != STATUS_OK)
if (init_server_tbl(PGR_Data_Path) != STATUS_OK)
{
- show_debug("init_server_tbl error\n");
+ show_debug("init_server_tbl error");
@ -309,7 +305,7 @@
PGRreplicate_exit(0);
}
pgid = getpgid(0);
@@ -1332,10 +1386,10 @@
@@ -1614,10 +1667,10 @@
}
if (pid == 0)
{

View File

@ -1,5 +1,5 @@
--- src/pgcluster/pgrp/recovery.c.orig Fri Feb 20 11:38:40 2004
+++ src/pgcluster/pgrp/recovery.c Fri Feb 20 16:25:21 2004
--- src/pgcluster/pgrp/recovery.c 16 Apr 2004 10:17:45 -0000 1.1.1.4
+++ src/pgcluster/pgrp/recovery.c 16 Apr 2004 10:21:06 -0000 1.5
@@ -121,7 +121,7 @@
int packet_size = 0;
@ -37,8 +37,8 @@
}
count ++;
@@ -331,18 +331,18 @@
Target->port = packet->port;
Target->recoveryPort = packet->recoveryPort;
Target->port = ntohs(packet->port);
Target->recoveryPort = ntohs(packet->recoveryPort);
Target->sock = *sock;
- show_debug("1st setup target %s\n",Target->hostName);
- show_debug("1st setup port %d\n",Target->port);
@ -57,7 +57,7 @@
- show_debug(" already recovery job runing\n");
+ show_debug(" already recovery job runing");
memset(packet,0,sizeof(packet));
packet->packet_no = RECOVERY_ERROR_OCCUPIED ;
PGRset_recovery_packet_no(packet, RECOVERY_ERROR_OCCUPIED) ;
status = send_packet(Target,packet);
@@ -352,7 +352,7 @@
/*
@ -66,7 +66,7 @@
- show_debug("add recovery target to host table\n");
+ show_debug("add recovery target to host table (%s)", packet->hostName);
memcpy(host_tbl.hostName,packet->hostName,sizeof(host_tbl.hostName));
host_tbl.port = packet->port;
host_tbl.port = ntohs(packet->port);
PGRset_recovered_host(&host_tbl,DB_TBL_INIT);
@@ -365,7 +365,7 @@
/*
@ -75,18 +75,18 @@
- show_debug("set RECOVERY_PGDATA_REQ packet data\n");
+ show_debug("set RECOVERY_PGDATA_REQ packet data");
memset(packet,0,sizeof(RecoveryPacket));
packet->packet_no = RECOVERY_PGDATA_REQ ;
master = PGRget_master();
@@ -374,7 +374,7 @@
PGRset_recovery_packet_no(packet, RECOVERY_PGDATA_REQ );
@@ -376,7 +376,7 @@
/*
* connection error , master may be down
*/
- show_error("get master info error , master may be down\n");
+ show_error("get master info error , master may be down");
packet->packet_no = RECOVERY_ERROR_CONNECTION;
PGRset_recovery_packet_no(packet, RECOVERY_ERROR_CONNECTION);
status = send_packet(Target, packet);
reset_recovery_prepare();
@@ -385,14 +385,14 @@
@@ -387,14 +387,14 @@
Master->sock = -1;
Master->port = master->port;
Master->recoveryPort = master->recoveryPort;
@ -100,10 +100,19 @@
*/
- show_error("connection error , master may be down\n");
+ show_error("connection error , master may be down");
packet->packet_no = RECOVERY_ERROR_CONNECTION;
status = send_packet(Target, packet);
reset_recovery_prepare();
@@ -409,10 +409,10 @@
PGRset_host_status(master,DB_TBL_ERROR);
goto retry_connect_master ;
/*
@@ -405,7 +405,7 @@
return loop_end;
*/
}
-
+
/*
* start prepare of recovery
* set recovery status to "prepare start"
@@ -415,10 +415,10 @@
/*
* wait answer from master server
*/
@ -113,38 +122,42 @@
read_packet_from_master(Master, packet);
- show_debug("get answer from master\n");
+ show_debug("get answer from master");
if (packet->packet_no == RECOVERY_PGDATA_ANS)
if (ntohs(packet->packet_no) == RECOVERY_PGDATA_ANS)
{
/*
@@ -455,7 +455,7 @@
@@ -461,7 +461,7 @@
status = PGRwait_transaction_count_clear();
if (status != STATUS_OK)
{
- show_error("transaction is too busy, please try again after\n");
+ show_error("transaction is too busy, please try again after");
packet->packet_no = RECOVERY_ERROR_CONNECTION;
PGRset_recovery_packet_no(packet, RECOVERY_ERROR_CONNECTION);
status = send_packet(Target,packet);
status = send_packet(Master,packet);
@@ -473,7 +473,7 @@
@@ -479,7 +479,7 @@
/*
* connection error , master may be down
*/
- show_error("connection error , master may be down\n");
+ show_error("connection error , master may be down");
packet->packet_no = RECOVERY_ERROR_CONNECTION;
PGRset_recovery_packet_no(packet, RECOVERY_ERROR_CONNECTION);
status = send_packet(Target,packet);
status = send_packet(Master,packet);
@@ -502,7 +502,7 @@
@@ -508,7 +508,7 @@
}
else
{
- show_debug("failer answer returned\n");
+ show_debug("failer answer returned");
packet->packet_no = RECOVERY_ERROR_CONNECTION;
PGRset_recovery_packet_no(packet, RECOVERY_ERROR_CONNECTION);
status = send_packet(Target,packet);
status = send_packet(Master,packet);
@@ -534,20 +534,20 @@
show_error("there is no master ");
@@ -538,23 +538,23 @@
if (master == (RecoveryTbl *)NULL)
{
- show_error("there is no master ");
+ show_error("there is no master");
return STATUS_ERROR;
}
- show_debug("master %s - %d\n",master->hostName,master->port);
@ -168,16 +181,16 @@
return STATUS_ERROR;
}
}
@@ -590,7 +590,7 @@
free(msg_query);
@@ -621,7 +621,7 @@
{
free(msg_header);
}
free(msg_header);
- show_debug("send_queue return status %d\n",status);
+ show_debug("send_queue return status %d",status);
return status;
}
@@ -611,7 +611,7 @@
@@ -642,7 +642,7 @@
set_function("pgrecovery_loop");
count = 0;
@ -186,24 +199,16 @@
while ((status = PGR_Create_Acception(fd,&sock,"",Recovery_Port_Number)) != STATUS_OK)
{
show_error("PGR_Create_Acception failed");
@@ -651,7 +651,7 @@
@@ -682,7 +682,7 @@
continue;
}
- show_debug("receive packet no:%d\n",packet.packet_no);
+ show_debug("receive packet no:%d",packet.packet_no);
- show_debug("receive packet no:%d\n",ntohs(packet.packet_no));
+ show_debug("receive packet no:%d",ntohs(packet.packet_no));
switch (packet.packet_no)
switch (ntohs(packet.packet_no))
{
@@ -694,6 +694,7 @@
if (status == STATUS_OK)
{
show_debug("PGRsend_queue ok");
+ memset(&new_host, 0, sizeof(new_host));
memcpy(new_host.hostName,Target.hostName,sizeof(new_host.hostName));
new_host.port = Target.port;
new_host.recoveryPort = Target.recoveryPort;
@@ -708,7 +709,7 @@
@@ -739,7 +739,7 @@
status = send_packet(&Target,&packet);
}
/*
@ -212,7 +217,7 @@
*/
finish_recovery();
loop_end = true;
@@ -721,7 +722,7 @@
@@ -752,7 +752,7 @@
memset((char *)&MasterPacketData,0,sizeof(RecoveryPacket));
break;
case RECOVERY_ERROR_ANS :
@ -220,8 +225,8 @@
+ show_debug("recovery error accept. top queueing and initialise recovery status");
status = PGRsend_queue(&Master,NULL);
memset(&packet,0,sizeof(RecoveryPacket));
packet.packet_no = RECOVERY_ERROR_ANS ;
@@ -776,7 +777,7 @@
PGRset_recovery_packet_no(&packet, RECOVERY_ERROR_ANS);
@@ -807,7 +807,7 @@
*/
FD_ZERO(&rmask);
FD_SET(fd,&rmask);

View File

@ -0,0 +1,124 @@
--- src/pgcluster/pgrp/replicate.c 16 Apr 2004 10:17:45 -0000 1.1.1.9
+++ src/pgcluster/pgrp/replicate.c 16 Apr 2004 10:21:06 -0000 1.5
@@ -141,7 +141,7 @@
ptr = Dbserver_Tbl_Begin;
while (ptr != NULL)
{
- show_debug("search host(%d):port(%d):db(%s)",ptr->hostIP,ptr->port,ptr->dbName);
+ show_debug("search host(%08x):port(%d):db(%s)",ptr->hostIP,ptr->port,ptr->dbName);
if ((ptr->useFlag == DB_TBL_USE) &&
(ptr->hostIP == host) &&
(ptr->port == host_ptr->port) &&
@@ -393,6 +393,7 @@
show_error("insertTransactionTbl failed");
return (TransactionTbl *)NULL;
}
+ show_debug("setTransactionTbl return %p (hostIP=%08x, port=%d, srcHostIP=%08x", ptr, work.hostIP, work.port, work.srcHostIP);
return ptr;
}
@@ -581,8 +582,10 @@
set_function("PGRadd_HostTbl");
ptr = PGRget_HostTbl(conf_data->hostName, conf_data->port);
+ set_function("PGRadd_HostTbl");
if (ptr != (HostTbl*)NULL)
{
+ show_debug("found ptr");
PGRset_host_status(ptr,useFlag);
return ptr;
}
@@ -606,6 +609,7 @@
{
(ptr + 1) -> useFlag = DB_TBL_END;
}
+ show_debug("not found, allocate new one");
ptr->hostNum = cnt;
memcpy(ptr->hostName,conf_data->hostName,sizeof(ptr->hostName));
ptr->port = conf_data->port;
@@ -624,19 +628,22 @@
set_function("PGRget_master");
host_tbl = Host_Tbl_Begin;
+ show_debug("start get_master loop");
while(host_tbl->useFlag != DB_TBL_END)
{
- show_debug("name %s flg %d port %d recoveryPort %d ",
+ show_debug(" %s:%d flg %d recoveryPort %d",
host_tbl->hostName,
- host_tbl->useFlag,
host_tbl->port,
+ host_tbl->useFlag,
host_tbl->recoveryPort);
if (host_tbl->useFlag == DB_TBL_USE)
{
+ show_debug("found master");
return host_tbl;
}
host_tbl ++;
}
+ show_debug("not found master");
return (HostTbl *)NULL;
}
@@ -651,6 +658,9 @@
PGRsem_lock(SemID,SEM_NUM_OF_RECOVERY);
if (Recovery_Status_Inf != (RecoveryStatusInf *)NULL)
{
+ if (Recovery_Status_Inf->recovery_status != status) {
+ show_debug("status change %d -> %d", Recovery_Status_Inf->recovery_status, status);
+ }
Recovery_Status_Inf->recovery_status = status;
}
PGRsem_unlock(SemID,SEM_NUM_OF_RECOVERY);
@@ -799,7 +809,7 @@
{
if (Recovery_Status_Inf->useFlag != DB_TBL_FREE)
{
- show_debug("check recovered host %d",Recovery_Status_Inf->useFlag);
+ show_debug("check recovered host (useFlag=%d)",Recovery_Status_Inf->useFlag);
ptr = PGRadd_HostTbl((HostTbl *)&(Recovery_Status_Inf->target_host),Recovery_Status_Inf->useFlag);
if (ptr == (HostTbl *) NULL)
{
@@ -830,6 +840,8 @@
if (target != (HostTbl*)NULL)
{
memcpy((HostTbl *)&(Recovery_Status_Inf->target_host),target,sizeof(HostTbl));
+ set_function("PGRset_recovered_host");
+ show_debug("status=%d", useFlag);
PGRset_host_status(target,useFlag);
}
@@ -1027,6 +1039,7 @@
{
return STATUS_ERROR;
}
+ show_debug("hostName=%s, port=%d, recoveryPort=%d, hostNum=%d, useFlag=%d", host_ptr->hostName, host_ptr->port, host_ptr->recoveryPort, host_ptr->hostNum, host_ptr->useFlag);
if (host_ptr->useFlag != status)
{
host_ptr->useFlag = status;
@@ -1251,6 +1264,7 @@
show_debug("send_replicate_packet_to_server query=%s",query);
}
+ set_function("PGRsend_replicate_packet_to_server");
if (conn == NULL)
{
show_error("[%d@%s] may be down",host_ptr->port,host_ptr->hostName);
@@ -1311,7 +1325,7 @@
if (res == NULL)
{
- show_error("PQexec error ");
+ show_error("PQexec error");
if ( header->cmdSts != CMD_STS_NOTICE )
{
PGRset_host_status(host_ptr,DB_TBL_ERROR);
@@ -1501,6 +1515,7 @@
len = strlen(hostName);
ptr = Host_Tbl_Begin;
+ show_debug("hostName=%s, port=%d", hostName, port);
if (len > sizeof(ptr->hostName))
{
len = sizeof(ptr->hostName);

View File

@ -1,58 +0,0 @@
--- src/pgcluster/pglb/pool_process_query.c.orig.orig Wed Feb 4 23:35:56 2004
+++ src/pgcluster/pglb/pool_process_query.c Wed Feb 4 23:37:29 2004
@@ -459,20 +459,31 @@
pool_write(frontend, &size, sizeof(int));
size = htonl(size) - 4;
- buf = malloc(size);
- if (buf == NULL)
+
+ /* read and send actual data only when size > 0 */
+ if (size > 0)
{
- show_error("AsciiRow: out of memory");
- return POOL_END;
+ buf = malloc(size);
+ if (buf == NULL)
+ {
+ show_error("AsciiRow: out of memory");
+ return POOL_END;
+ }
+ /* actual data */
+ if (pool_read(backend, buf, size) < 0)
+ {
+ free(buf);
+ return POOL_END;
+ }
+ pool_write(frontend, buf, size);
+ snprintf(msgbuf, Min(sizeof(msgbuf), size), "%s", buf);
+ free(buf);
+ }
+ else
+ {
+ *msgbuf = '\0';
}
- /* actual data */
- if (pool_read(backend, buf, size) < 0)
- return POOL_END;
-
- pool_write(frontend, buf, size);
- snprintf(msgbuf, Min(sizeof(msgbuf), size), "%s", buf);
show_debug("AsciiRow: len:%d data: %s", size, msgbuf);
- free(buf);
}
mask >>= 1;
}
@@ -728,10 +739,11 @@
static POOL_STATUS EmptyQueryResponse(POOL_CONNECTION *frontend,
POOL_CONNECTION *backend)
{
+ char c;
+
/* set function name */
set_function("EmptyQueryResponse");
- char c;
if (pool_read(backend, &c, sizeof(c)) < 0)
return POOL_END;

View File

@ -1,19 +0,0 @@
--- src/backend/postmaster/postmaster.c.orig.1 Mon Feb 23 15:33:29 2004
+++ src/backend/postmaster/postmaster.c Mon Feb 23 15:34:53 2004
@@ -610,7 +610,7 @@
*/
checkDataDir(potential_DataDir); /* issues error messages */
SetDataDir(potential_DataDir);
-
+ ProcessConfigFile(PGC_POSTMASTER);
#ifdef USE_REPLICATION
PGR_Get_Conf_Data( potential_DataDir, CLUSTER_CONF_FILE );
PGR_Init_Replicate_Server_Data();
@@ -627,7 +627,6 @@
}
}
#endif /* USE_REPLICATION */
- ProcessConfigFile(PGC_POSTMASTER);
/*
* Check for invalid combinations of GUC settings.

View File

@ -1,293 +0,0 @@
--- src/pgcluster/pgrp/replicate.c.orig Fri Feb 20 11:38:40 2004
+++ src/pgcluster/pgrp/replicate.c Sat Feb 21 20:50:01 2004
@@ -133,7 +133,7 @@
ptr = Dbserver_Tbl_Begin;
while (ptr != NULL)
{
-show_debug("search host(%d):port(%d):db(%s)",ptr->hostIP,ptr->port,ptr->dbName);
+show_debug("search host(%08x):port(%d):db(%s)",ptr->hostIP,ptr->port,ptr->dbName);
if ((ptr->useFlag == DB_TBL_USE) &&
(ptr->hostIP == host) &&
(ptr->port == host_ptr->port) &&
@@ -165,7 +165,7 @@
hostName = host_ptr->hostName;
- show_debug("host:%s dbName:%s\n",hostName,dbName);
+ show_debug("host:%s dbName:%s",hostName,dbName);
if ((hostName == NULL ) || (dbName == NULL))
{
show_error("hostName or dbName is NULL");
@@ -215,7 +215,7 @@
if ((host_ptr == (HostTbl *)NULL) || (datap == (DBServerTbl*)NULL))
{
- show_error("insertDBServerTbl datap error\n");
+ show_error("insertDBServerTbl datap error");
return (DBServerTbl *)NULL;
}
workp = Dbserver_Tbl_End;
@@ -258,7 +258,7 @@
if ((host1[0] == '\0' ) || (host2[0] == '\0') ||
(port1 <= 0) || (port2 <= 0))
{
- show_debug("not same host:\n");
+ show_debug("not same host:");
return false;
}
ip1 = get_ip_by_name( host1);
@@ -266,10 +266,10 @@
if ((ip1 == ip2) && (port1 == port2))
{
- show_debug("same host:%d@%x - %d@%x\n",port1,ip1,port2,ip2);
+ show_debug("same host:%d@%x - %d@%x",port1,ip1,port2,ip2);
return true;
}
- show_debug("not same host:%d@%x - %d@%x\n",port1,ip1,port2,ip2);
+ show_debug("not same host:%d@%x - %d@%x",port1,ip1,port2,ip2);
return false;
}
@@ -326,7 +326,7 @@
}
cnt ++;
}
- show_debug("PQsetdbLogin ok!!\n");
+ show_debug("PQsetdbLogin ok!!");
return conn;
}
@@ -379,6 +379,7 @@
show_error("insertTransactionTbl failed");
return (TransactionTbl *)NULL;
}
+ show_debug("setTransactionTbl return %p (hostIP=%08x, port=%d, srcHostIP=%08x", ptr, work.hostIP, work.port, work.srcHostIP);
return ptr;
}
@@ -451,12 +452,12 @@
(!memcmp(ptr->dbName,header->dbName,strlen(ptr->dbName))) &&
(ptr->pid == header->pid))
{
- show_debug("hit !! transaction tbl host %s db:%s pid:%d\n",host_ptr->hostName,ptr->dbName,ptr->pid);
+ show_debug("hit !! transaction tbl host %s db:%s pid:%d",host_ptr->hostName,ptr->dbName,ptr->pid);
return ptr;
}
ptr = (TransactionTbl*)ptr->next;
}
- show_debug("not found in transaction tbl host %s db:%s pid:%d\n",header->from_host,header->dbName,header->pid);
+ show_debug("not found in transaction tbl host %s db:%s pid:%d",header->from_host,header->dbName,header->pid);
return (TransactionTbl * )NULL;
}
@@ -561,8 +562,10 @@
set_function("PGRadd_HostTbl");
ptr = PGRget_HostTbl(conf_data->hostName, conf_data->port);
+ set_function("PGRadd_HostTbl");
if (ptr != (HostTbl*)NULL)
{
+ show_debug("found ptr");
PGRset_host_status(ptr,useFlag);
return ptr;
}
@@ -586,6 +589,7 @@
{
(ptr + 1) -> useFlag = DB_TBL_END;
}
+ show_debug("not found, allocate new one");
ptr->hostNum = cnt;
memcpy(ptr->hostName,conf_data->hostName,sizeof(ptr->hostName));
ptr->port = conf_data->port;
@@ -604,19 +608,22 @@
set_function("PGRget_master");
host_tbl = Host_Tbl_Begin;
+ show_debug("start get_master loop");
while(host_tbl->useFlag != DB_TBL_END)
{
- show_debug("name %s flg %d port %d recoveryPort %d \n",
+ show_debug(" %s:%d flg %d recoveryPort %d",
host_tbl->hostName,
- host_tbl->useFlag,
host_tbl->port,
+ host_tbl->useFlag,
host_tbl->recoveryPort);
if (host_tbl->useFlag == DB_TBL_USE)
{
+ show_debug("found master");
return host_tbl;
}
host_tbl ++;
}
+ show_debug("not found master");
return (HostTbl *)NULL;
}
@@ -629,6 +636,9 @@
PGRsem_lock(SemID,SEM_NUM_OF_RECOVERY);
if (Recovery_Status_Inf != (RecoveryStatusInf *)NULL)
{
+ if (Recovery_Status_Inf->recovery_status != status) {
+ show_debug("status change %d -> %d", Recovery_Status_Inf->recovery_status, status);
+ }
Recovery_Status_Inf->recovery_status = status;
}
PGRsem_unlock(SemID,SEM_NUM_OF_RECOVERY);
@@ -763,7 +773,7 @@
{
if (Recovery_Status_Inf->useFlag != DB_TBL_FREE)
{
- show_debug("check recovered host %d\n",Recovery_Status_Inf->useFlag);
+ show_debug("check recovered host (useFlag=%d)",Recovery_Status_Inf->useFlag);
ptr = PGRadd_HostTbl((HostTbl *)&(Recovery_Status_Inf->target_host),Recovery_Status_Inf->useFlag);
if (ptr == (HostTbl *) NULL)
{
@@ -792,6 +802,8 @@
if (target != (HostTbl*)NULL)
{
memcpy((HostTbl *)&(Recovery_Status_Inf->target_host),target,sizeof(HostTbl));
+ set_function("PGRset_recovered_host");
+ show_debug("status=%d", useFlag);
PGRset_host_status(target,useFlag);
}
@@ -961,6 +973,7 @@
return STATUS_ERROR;
}
host_ptr->useFlag = status;
+ show_debug("hostName=%s, port=%d, recoveryPort=%d, hostNum=%d, useFlag=%d", host_ptr->hostName, host_ptr->port, host_ptr->recoveryPort, host_ptr->hostNum, host_ptr->useFlag);
switch( host_ptr->useFlag)
{
case DB_TBL_FREE:
@@ -990,7 +1003,6 @@
host_ptr->hostName);
break;
}
-
return STATUS_OK;
}
@@ -1144,7 +1156,7 @@
/*
* re-use the connection data
*/
- show_debug("find conn in db_server_tbl %d\n",db_server_tbl->conn);
+ show_debug("find conn in db_server_tbl %d",db_server_tbl->conn);
if ((db_server_tbl->conn != (PGconn *)NULL) &&
(db_server_tbl->conn->sock <= 0) )
{
@@ -1153,17 +1165,18 @@
}
}
conn = db_server_tbl->conn;
- show_debug("send_replicate_packet_to_server query=%s\n",query);
+ show_debug("send_replicate_packet_to_server query=%s",query);
}
+ set_function("PGRsend_replicate_packet_to_server");
if (conn == NULL)
{
- show_error("conn is null\n");
+ show_error("conn is null");
PGRset_host_status(host_ptr,DB_TBL_ERROR);
return STATUS_ERROR;
}
- show_debug("db:%s port:%s user:%s host:%s query:%s\n",
+ show_debug("db:%s port:%s user:%s host:%s query:%s",
database,port,userName,host,query);
/*
* execute query
@@ -1184,7 +1197,7 @@
(header->cmdType == CMD_TYPE_COPY_DATA_END))
{
/* copy data replication */
- show_debug("query(%s) size(%d)\n",query,header->query_size);
+ show_debug("query(%s) size(%d)",query,header->query_size);
rtn =PQputnbytes(conn, query,header->query_size);
if (header->cmdType == CMD_TYPE_COPY_DATA_END)
{
@@ -1201,11 +1214,11 @@
if (res == NULL)
{
- show_error("PQexec error \n");
+ show_error("PQexec error");
PGRset_host_status(host_ptr,DB_TBL_ERROR);
return STATUS_ERROR;
}
- show_debug("PQexec send :%s\n",query);
+ show_debug("PQexec send :%s",query);
str = PQcmdStatus(res);
if ((str == NULL) || (*str == '\0'))
@@ -1258,7 +1271,7 @@
}
}
}
- show_debug("PQexec end\n");
+ show_debug("PQexec end");
if ((! strcmp(database,"template1")) ||
(! strcmp(database,"template0")))
{
@@ -1337,12 +1350,12 @@
* send header data to queue
*/
rtn = msgsnd(RecoveryMsgid, msg_header, sizeof(ReplicateHeader), IPC_NOWAIT);
- show_debug("msgsnd header rtn:%d\n",rtn);
+ show_debug("msgsnd header rtn:%d",rtn);
/*
* send query data to queue
*/
rtn = msgsnd(RecoveryMsgid, msg_query, header->query_size, IPC_NOWAIT);
- show_debug("msgsnd query rtn:%d\n",rtn);
+ show_debug("msgsnd query rtn:%d",rtn);
/*
* release memory
@@ -1364,6 +1377,7 @@
len = strlen(hostName);
ptr = Host_Tbl_Begin;
+ show_debug("hostName=%s, port=%d", hostName, port);
if (len > sizeof(ptr->hostName))
{
len = sizeof(ptr->hostName);
@@ -1379,10 +1393,12 @@
}
if (ptr->useFlag != DB_TBL_END)
{
+ show_debug("found: %s:%d", ptr->hostName, ptr->port);
return ptr;
}
else
{
+ show_debug("not found");
return (HostTbl*)NULL;
}
}
@@ -1392,7 +1408,6 @@
{
char buf[256];
char log[288];
- int len1;
char * p;
va_list ap;
time_t t;
@@ -1410,13 +1425,12 @@
{
*p = ' ';
}
- len1 = strlen(log);
va_start(ap,fmt);
vsnprintf(buf,sizeof(buf),fmt,ap);
va_end(ap);
strcat(log,buf);
strcat(log,"\n");
- if (fputs(log,LogFp) > 0)
+ if (fputs(log,LogFp) >= 0)
{
fflush(LogFp);
}