This is an automated email from the ASF dual-hosted git repository.

tuhaihe pushed a commit to branch add-behave-test-ci
in repository https://gitbox.apache.org/repos/asf/cloudberry.git

commit 249f31ee4b16c21448388fec33e9cd4af597f63e
Author: Dianjin Wang <[email protected]>
AuthorDate: Fri Sep 11 12:24:00 2026 +0800

    gpinitsystem: set the mirror's own port after pg_basebackup
    
    CREATE_QES_MIRROR seeds the mirror with pg_basebackup, which copies the
    primary's postgresql.conf verbatim -- including the primary's port. The
    mirror was then started with START_QE before that port was corrected, so
    on a single host it either bound the wrong port or collided with its own
    primary. Rewrite postgresql.conf before starting the segment.
    
    Greenplum has the same SED_PG_CONF call but places it after START_QE,
    which leaves the same window open there.
    
    Also emit explicit 127.0.0.1/32 and ::1/128 trust entries in the
    coordinator's pg_hba.conf. The hostname-based entry alone is not enough
    when the loopback address the client picks depends on the host's IPv4
    and IPv6 resolution order.
---
 gpMgmt/bin/lib/gp_bash_functions.sh |  5 +++++
 gpMgmt/bin/lib/gpcreateseg.sh       | 14 ++++++++++++++
 2 files changed, 19 insertions(+)

diff --git a/gpMgmt/bin/lib/gp_bash_functions.sh 
b/gpMgmt/bin/lib/gp_bash_functions.sh
index de76620da2b..e42b993470a 100755
--- a/gpMgmt/bin/lib/gp_bash_functions.sh
+++ b/gpMgmt/bin/lib/gp_bash_functions.sh
@@ -783,6 +783,11 @@ BUILD_COORDINATOR_PG_HBA_FILE () {
         else
             $ECHO "host     all         $USER_NAME         localhost    trust" 
>> ${GP_DIR}/$PG_HBA
             $ECHO "host     all         $USER_NAME         
$COORDINATOR_HOSTNAME       trust" >> ${GP_DIR}/$PG_HBA
+            # Also add explicit IPv4 and IPv6 loopback entries so that
+            # connections via 127.0.0.1 and ::1 are always accepted
+            # regardless of hostname resolution order.
+            $ECHO "host     all         $USER_NAME         127.0.0.1/32    
trust" >> ${GP_DIR}/$PG_HBA
+            $ECHO "host     all         $USER_NAME         ::1/128         
trust" >> ${GP_DIR}/$PG_HBA
         fi
 
 
diff --git a/gpMgmt/bin/lib/gpcreateseg.sh b/gpMgmt/bin/lib/gpcreateseg.sh
index 5dd0f5b0006..78883f9463d 100755
--- a/gpMgmt/bin/lib/gpcreateseg.sh
+++ b/gpMgmt/bin/lib/gpcreateseg.sh
@@ -224,6 +224,20 @@ CREATE_QES_MIRROR () {
     fi
     RUN_COMMAND_REMOTE ${PRIMARY_HOSTADDRESS} "${EXPORT_GPHOME}; . 
${GPHOME}/cloudberry-env.sh; cat - >> ${PRIMARY_DIR}/pg_hba.conf; pg_ctl -D 
${PRIMARY_DIR} reload" <<< "${PG_HBA_ENTRIES}"
     RUN_COMMAND_REMOTE ${GP_HOSTADDRESS} "${EXPORT_GPHOME}; . 
${GPHOME}/cloudberry-env.sh; rm -rf ${GP_DIR}; ${GPHOME}/bin/pg_basebackup 
--wal-method=stream --create-slot --slot='internal_wal_replication_slot' -R -c 
fast -E ./db_dumps -D ${GP_DIR} -h ${PRIMARY_HOSTADDRESS} -p ${PRIMARY_PORT} 
--target-gp-dbid ${GP_DBID};"
+    # pg_basebackup copies the primary's postgresql.conf verbatim, so the
+    # mirror would otherwise start on the primary's port. Append the right
+    # one before starting; the last setting in the file wins.
+    #
+    # $PORT_TXT ("#port") finds nothing in the copied file -- the port line is
+    # already active there -- so SED_PG_CONF takes its append path. That is
+    # what we want: its replace path runs an unanchored
+    # "s/<search>/<sub> #<search>/", which with a search string of "port"
+    # would also rewrite every "support", "report" and "transport" in the
+    # file's comments.
+    LOG_MSG "[INFO][$INST_COUNT]:-Configuring segment $PG_CONF"
+    SED_PG_CONF ${GP_DIR}/$PG_CONF "$PORT_TXT" port=$GP_PORT 0 $GP_HOSTADDRESS
+    RETVAL=$?
+    PARA_EXIT $RETVAL "Update port number to $GP_PORT"
     START_QE "-w"
     RETVAL=$?
     PARA_EXIT $RETVAL "pg_basebackup of segment data directory from 
${PRIMARY_HOSTADDRESS} to ${GP_HOSTADDRESS}"


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to