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

Commit499c9b1

Browse files
committed
Improve some check logic in pg_receivewal
The following things are improved:- Fetch the system identifier from the source server before anyWAL streaming loop. This triggers extra checks to make sure thatpg_receivewal is still connected to a server with the same system IDwith a correct timeline.- Switch umask() (for file creation mode mask) and RetrieveWalSegSize()(to fetch the size of WAL segments) a bit later before the initialstream attempt. If the connection was done with a database,pg_receivewal would fail but those commands were still executed, whichwas a waste. The slot creation and drop are now done before retrievingthe segment size.Author: Bharath RupireddyReviewed-by: Ronan Dunklau, Michael PaquierDiscussion:https://postgr.es/m/CALj2ACX00YYeyBfoi55Cy=NrP-FcfMgiYYx1qRUEib3yjCVoaA@mail.gmail.com
1 parentd7897ab commit499c9b1

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

‎src/bin/pg_basebackup/pg_receivewal.c

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ StreamLog(void)
372372
XLogRecPtrserverpos;
373373
TimeLineIDservertli;
374374
StreamCtlstream;
375+
char*sysidentifier;
375376

376377
MemSet(&stream,0,sizeof(stream));
377378

@@ -399,7 +400,7 @@ StreamLog(void)
399400
* at the same time, necessary if not valid data can be found in the
400401
* existing output directory.
401402
*/
402-
if (!RunIdentifySystem(conn,NULL,&servertli,&serverpos,NULL))
403+
if (!RunIdentifySystem(conn,&sysidentifier,&servertli,&serverpos,NULL))
403404
exit(1);
404405

405406
/*
@@ -435,6 +436,7 @@ StreamLog(void)
435436
stream.do_sync);
436437
stream.partial_suffix=".partial";
437438
stream.replication_slot=replication_slot;
439+
stream.sysidentifier=sysidentifier;
438440

439441
ReceiveXlogStream(conn,&stream);
440442

@@ -449,6 +451,7 @@ StreamLog(void)
449451

450452
FreeWalDirectoryMethod();
451453
pg_free(stream.walmethod);
454+
pg_free(stream.sysidentifier);
452455
}
453456

454457
/*
@@ -687,20 +690,6 @@ main(int argc, char **argv)
687690
if (!RunIdentifySystem(conn,NULL,NULL,NULL,&db_name))
688691
exit(1);
689692

690-
/*
691-
* Set umask so that directories/files are created with the same
692-
* permissions as directories/files in the source data directory.
693-
*
694-
* pg_mode_mask is set to owner-only by default and then updated in
695-
* GetConnection() where we get the mode from the server-side with
696-
* RetrieveDataDirCreatePerm() and then call SetDataDirectoryCreatePerm().
697-
*/
698-
umask(pg_mode_mask);
699-
700-
/* determine remote server's xlog segment size */
701-
if (!RetrieveWalSegSize(conn))
702-
exit(1);
703-
704693
/*
705694
* Check that there is a database associated with connection, none should
706695
* be defined in this context.
@@ -712,6 +701,16 @@ main(int argc, char **argv)
712701
exit(1);
713702
}
714703

704+
/*
705+
* Set umask so that directories/files are created with the same
706+
* permissions as directories/files in the source data directory.
707+
*
708+
* pg_mode_mask is set to owner-only by default and then updated in
709+
* GetConnection() where we get the mode from the server-side with
710+
* RetrieveDataDirCreatePerm() and then call SetDataDirectoryCreatePerm().
711+
*/
712+
umask(pg_mode_mask);
713+
715714
/*
716715
* Drop a replication slot.
717716
*/
@@ -737,6 +736,10 @@ main(int argc, char **argv)
737736
exit(0);
738737
}
739738

739+
/* determine remote server's xlog segment size */
740+
if (!RetrieveWalSegSize(conn))
741+
exit(1);
742+
740743
/*
741744
* Don't close the connection here so that subsequent StreamLog() can
742745
* reuse it.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp