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

Commit1bdae16

Browse files
committed
walreceiver: tweak pg_stat_wal_receiver behavior
There are two problems in the original coding: one is that if onewalreceiver process exits, the ready_to_display flag remains set inshared memory, exposing the conninfo of the next walreceiver beforeobfuscating. Fix by having WalRcvDie reset the flag.Second, the sleep-and-retry behavior that waited until walreceiver hadset ready_to_display wasn't liked; the preference is to have it returnno data instead, so let's do that.Bugs in9ed551e reported by Fujii Masao and Michël Paquier.Author: Michaël Paquier
1 parent9e70398 commit1bdae16

File tree

1 file changed

+6
-16
lines changed

1 file changed

+6
-16
lines changed

‎src/backend/replication/walreceiver.c

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ WalReceiverMain(void)
246246
walrcv->walRcvState=WALRCV_STREAMING;
247247

248248
/* Fetch information required to start streaming */
249+
walrcv->ready_to_display= false;
249250
strlcpy(conninfo, (char*)walrcv->conninfo,MAXCONNINFO);
250251
strlcpy(slotname, (char*)walrcv->slotname,NAMEDATALEN);
251252
startpoint=walrcv->receiveStart;
@@ -770,6 +771,7 @@ WalRcvDie(int code, Datum arg)
770771
Assert(walrcv->pid==MyProcPid);
771772
walrcv->walRcvState=WALRCV_STOPPED;
772773
walrcv->pid=0;
774+
walrcv->ready_to_display= false;
773775
SpinLockRelease(&walrcv->mutex);
774776

775777
/* Terminate the connection gracefully. */
@@ -1343,24 +1345,12 @@ pg_stat_get_wal_receiver(PG_FUNCTION_ARGS)
13431345
char*slotname;
13441346
char*conninfo;
13451347

1346-
/* No WAL receiver, just return a tuple with NULL values */
1347-
if (walrcv->pid==0)
1348-
PG_RETURN_NULL();
1349-
13501348
/*
1351-
*Users attempting to read this data mustn't be shown security sensitive
1352-
*data, so sleep until everything has been properly obfuscated.
1349+
*No WAL receiver (or not ready yet), just return a tuple with NULL
1350+
*values
13531351
*/
1354-
retry:
1355-
SpinLockAcquire(&walrcv->mutex);
1356-
if (!walrcv->ready_to_display)
1357-
{
1358-
SpinLockRelease(&walrcv->mutex);
1359-
CHECK_FOR_INTERRUPTS();
1360-
pg_usleep(1000);
1361-
gotoretry;
1362-
}
1363-
SpinLockRelease(&walrcv->mutex);
1352+
if (walrcv->pid==0|| !walrcv->ready_to_display)
1353+
PG_RETURN_NULL();
13641354

13651355
/* determine result type */
13661356
if (get_call_result_type(fcinfo,NULL,&tupdesc)!=TYPEFUNC_COMPOSITE)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp