Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit819f38b

Browse files
committed
Move sockhub background worker registering code from shmem hook (postgres warns about this).
1 parentd0adde3 commit819f38b

File tree

3 files changed

+21
-16
lines changed

3 files changed

+21
-16
lines changed

‎contrib/pg_dtm/libdtm.c‎

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ static DTMConn DtmConnect(char *host, int port)
3939
DTMConndtm;
4040
intsd;
4141

42-
if (strcmp(host,"localhost")==0)
42+
if (host==NULL)
4343
{
44+
// use a UNIX socket
4445
structsockaddrsock;
4546
intlen= offsetof(structsockaddr,sa_data)+snprintf(sock.sa_data,sizeof(sock.sa_data),"%s/p%u",dtm_unix_sock_dir,port);
4647
sock.sa_family=AF_UNIX;
@@ -62,6 +63,7 @@ static DTMConn DtmConnect(char *host, int port)
6263
}
6364
else
6465
{
66+
// use an IP socket
6567
structaddrinfo*addrs=NULL;
6668
structaddrinfohint;
6769
charportstr[6];
@@ -207,7 +209,9 @@ void DtmGlobalConfig(char *host, int port, char* sock_dir) {
207209
free(dtmhost);
208210
dtmhost=NULL;
209211
}
210-
dtmhost=strdup(host);
212+
if (host) {
213+
dtmhost=strdup(host);
214+
}
211215
dtmport=port;
212216
dtm_unix_sock_dir=sock_dir;
213217
}
@@ -217,14 +221,14 @@ static DTMConn GetConnection()
217221
staticDTMConndtm=NULL;
218222
if (dtm==NULL)
219223
{
220-
if (dtmhost) {
221-
dtm=DtmConnect(dtmhost,dtmport);
222-
if (dtm==NULL)
223-
{
224-
elog(ERROR,"Failed to connect to DTMD %s:%d",dtmhost,dtmport);
224+
dtm=DtmConnect(dtmhost,dtmport);
225+
if (dtm==NULL)
226+
{
227+
if (dtmhost) {
228+
elog(ERROR,"Failed to connect to DTMD at tcp %s:%d",dtmhost,dtmport);
229+
}else {
230+
elog(ERROR,"Failed to connect to DTMD at unix %d",dtmport);
225231
}
226-
}else {
227-
/* elog(ERROR, "DTMD address not specified"); */
228232
}
229233
}
230234
returndtm;

‎contrib/pg_dtm/pg_dtm.c‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -654,9 +654,6 @@ static void DtmInitialize()
654654
dtm->nReservedXids=0;
655655
dtm->minXid=InvalidTransactionId;
656656
RegisterXactCallback(DtmXactCallback,NULL);
657-
if (DtmBufferSize!=0) {
658-
RegisterBackgroundWorker(&DtmWorker);
659-
}
660657
}
661658
LWLockRelease(AddinShmemInitLock);
662659

@@ -793,7 +790,13 @@ _PG_init(void)
793790
NULL
794791
);
795792

796-
DtmGlobalConfig(DtmHost,DtmPort,Unix_socket_directories);
793+
794+
if (DtmBufferSize!=0) {
795+
DtmGlobalConfig(NULL,DtmPort,Unix_socket_directories);
796+
RegisterBackgroundWorker(&DtmWorker);
797+
}else {
798+
DtmGlobalConfig(DtmHost,DtmPort,Unix_socket_directories);
799+
}
797800

798801
/*
799802
* Install hooks.
@@ -899,9 +902,6 @@ void DtmBackgroundWorker(Datum arg)
899902
params.file=unix_sock_path;
900903
params.buffer_size=DtmBufferSize;
901904

902-
DtmGlobalConfig("localhost",DtmPort,Unix_socket_directories);
903-
904905
ShubInitialize(&shub,&params);
905-
906906
ShubLoop(&shub);
907907
}

‎contrib/pg_dtm/tests/daemons.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ func postgres(bin string, datadir string, port int, nodeid int, wg *sync.WaitGro
9191
bin,
9292
"-D",datadir,
9393
"-p",strconv.Itoa(port),
94+
"-c","dtm.buffer_size=65536",
9495
"-c","dtm.host=127.0.0.1",
9596
"-c","dtm.port="+strconv.Itoa(5431),
9697
"-c","autovacuum=off",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp