Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
46 changes: 46 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,52 @@ jobs:
limit-access-to-actor: true
limit-access-to-users: hashdata-build
wait-timeout-minutes: 60
ic-singlenode-test:
needs: build
runs-on: [ self-hosted, example ]
env:
MAKE_TEST_COMMAND: "-C src/test installcheck-singlenode"
NUM_PRIMARY_MIRROR_PAIRS: "0"
TEST_OS: "centos"
DUMP_DB: "true"
steps:
- uses: actions/checkout@v3
with:
path: "gpdb_src"
- uses: actions/download-artifact@v3
with:
name: cbdb-variables
path: /opt/
- uses: actions/download-artifact@v3
with:
name: cbdb-package
path: /opt/
- name: Run icw-test script
run: |
mkdir /code
cp -a gpdb_src/ /code
cd /code
echo $GITHUB_RUN_ID > gpdb_src/BUILD_NUMBER
gpdb_src/hd-ci/icw_cbdb.bash $FTS_MODE
- uses: actions/upload-artifact@v3
if: failure()
with:
name: cbdb-ic-singlenode-test-log
path: |
/code/gpdb_src/src/test/singlenode_regress/regression.out
/code/gpdb_src/src/test/singlenode_regress/regression.diffs
/code/gpdb_src/src/test/singlenode_regress/results/
/code/gpdb_src/src/test/singlenode_regress/expected/
/code/gpdb_src/src/test/singlenode_isolation2/regression.out
/code/gpdb_src/src/test/singlenode_isolation2/regression.diffs
/code/gpdb_src/src/test/singlenode_isolation2/results/
/code/gpdb_src/src/test/singlenode_isolation2/expected/
/code/gpdb_src/src/test/isolation/regression.out
/code/gpdb_src/src/test/isolation/regression.diffs
/code/gpdb_src/src/test/isolation/output_iso/results/
/code/gpdb_src/src/test/isolation/expected/
/code/gpdb_src/gpAux/gpdemo/datadirs/standby/log/
/code/gpdb_src/gpAux/gpdemo/datadirs/singlenodedir/demoDataDir-1/log/
icw-orca-test:
needs: build
runs-on: [self-hosted, example]
Expand Down
4 changes: 4 additions & 0 deletions GNUmakefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ distclean maintainer-clean:
installcheck-resgroup:
$(MAKE) -C src/test/isolation2 $@

# Create a demo singlenode deployment.
create-demo-singlenode:
$(MAKE) -C gpAux/gpdemo create-demo-cluster NUM_PRIMARY_MIRROR_PAIRS=0

# Create or destroy a demo cluster.
create-demo-cluster:
$(MAKE) -C gpAux/gpdemo create-demo-cluster
Expand Down
24 changes: 16 additions & 8 deletions gpAux/gpdemo/demo_cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ SEG_PREFIX=demoDataDir
STANDBYDIR=$DATADIRS/standby
EXTERNAL_FTS_ENABLED="false"

SINGLENODE_OPTS=""
SINGLENODE_MODE=""
if [ "${NUM_PRIMARY_MIRROR_PAIRS}" -eq "0" ]; then
SINGLENODE_MODE="true"
SINGLENODE_OPTS="--singlenodeMode=true"
QDDIR=$DATADIRS/singlenodedir
fi

# ======================================================================
# Database Ports
# ======================================================================
Expand Down Expand Up @@ -391,33 +399,33 @@ if [ -f "${CLUSTER_CONFIG_POSTGRES_ADDONS}" ]; then
if [ $EXTERNAL_FTS_ENABLED == "true" ]; then
echo "=========================================================================================="
echo "executing:"
echo " $GPPATH/gpinitsystem -a -c $CLUSTER_CONFIG -l $DATADIRS/gpAdminLogs -U 1 -p ${CLUSTER_CONFIG_POSTGRES_ADDONS} ${STANDBY_INIT_OPTS} \"$@\""
echo " $GPPATH/gpinitsystem -a -c $CLUSTER_CONFIG -l $DATADIRS/gpAdminLogs -U 1 -p ${CLUSTER_CONFIG_POSTGRES_ADDONS} ${STANDBY_INIT_OPTS} ${SINGLENODE_OPTS} \"$@\""
echo "=========================================================================================="
echo ""
$GPPATH/gpinitsystem -a -c $CLUSTER_CONFIG -l $DATADIRS/gpAdminLogs -U 1 -p ${CLUSTER_CONFIG_POSTGRES_ADDONS} ${STANDBY_INIT_OPTS} "$@"
$GPPATH/gpinitsystem -a -c $CLUSTER_CONFIG -l $DATADIRS/gpAdminLogs -U 1 -p ${CLUSTER_CONFIG_POSTGRES_ADDONS} ${STANDBY_INIT_OPTS} ${SINGLENODE_OPTS} "$@"
else
echo "=========================================================================================="
echo "executing:"
echo " $GPPATH/gpinitsystem -a -c $CLUSTER_CONFIG -l $DATADIRS/gpAdminLogs -p ${CLUSTER_CONFIG_POSTGRES_ADDONS} ${STANDBY_INIT_OPTS} \"$@\""
echo " $GPPATH/gpinitsystem -a -c $CLUSTER_CONFIG -l $DATADIRS/gpAdminLogs -p ${CLUSTER_CONFIG_POSTGRES_ADDONS} ${STANDBY_INIT_OPTS} ${SINGLENODE_OPTS} \"$@\""
echo "=========================================================================================="
echo ""
$GPPATH/gpinitsystem -a -c $CLUSTER_CONFIG -l $DATADIRS/gpAdminLogs -p ${CLUSTER_CONFIG_POSTGRES_ADDONS} ${STANDBY_INIT_OPTS} "$@"
$GPPATH/gpinitsystem -a -c $CLUSTER_CONFIG -l $DATADIRS/gpAdminLogs -p ${CLUSTER_CONFIG_POSTGRES_ADDONS} ${STANDBY_INIT_OPTS} ${SINGLENODE_OPTS} "$@"
fi
else
if [ $EXTERNAL_FTS_ENABLED == "true" ]; then
echo "=========================================================================================="
echo "executing:"
echo " $GPPATH/gpinitsystem -a -c $CLUSTER_CONFIG -U 1 -l $DATADIRS/gpAdminLogs ${STANDBY_INIT_OPTS} \"$@\""
echo " $GPPATH/gpinitsystem -a -c $CLUSTER_CONFIG -U 1 -l $DATADIRS/gpAdminLogs ${STANDBY_INIT_OPTS} ${SINGLENODE_OPTS} \"$@\""
echo "=========================================================================================="
echo ""
$GPPATH/gpinitsystem -a -c $CLUSTER_CONFIG -U 1 -l $DATADIRS/gpAdminLogs ${STANDBY_INIT_OPTS} "$@"
$GPPATH/gpinitsystem -a -c $CLUSTER_CONFIG -U 1 -l $DATADIRS/gpAdminLogs ${STANDBY_INIT_OPTS} ${SINGLENODE_OPTS} "$@"
else
echo "=========================================================================================="
echo "executing:"
echo " $GPPATH/gpinitsystem -a -c $CLUSTER_CONFIG -l $DATADIRS/gpAdminLogs ${STANDBY_INIT_OPTS} \"$@\""
echo " $GPPATH/gpinitsystem -a -c $CLUSTER_CONFIG -l $DATADIRS/gpAdminLogs ${STANDBY_INIT_OPTS} ${SINGLENODE_OPTS} \"$@\""
echo "=========================================================================================="
echo ""
$GPPATH/gpinitsystem -a -c $CLUSTER_CONFIG -l $DATADIRS/gpAdminLogs ${STANDBY_INIT_OPTS} "$@"
$GPPATH/gpinitsystem -a -c $CLUSTER_CONFIG -l $DATADIRS/gpAdminLogs ${STANDBY_INIT_OPTS} ${SINGLENODE_OPTS} "$@"
fi
fi
RETURN=$?
Expand Down
2 changes: 1 addition & 1 deletion gpMgmt/bin/gpconfig
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def get_gucs_from_database(gucname):


def _print_gucs(gucname, gucs, options):
collection = GucCollection()
collection = GucCollection(options)
collection.update_list(gucs)

if _show_all_segment_values_always(options):
Expand Down
5 changes: 3 additions & 2 deletions gpMgmt/bin/gpconfig_modules/guc_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ class GucCollection:
"""
COORDINATOR_KEY = '-1'

def __init__(self):
def __init__(self, options):
self.gucs = {}
self.options = options

def update_list(self, guc_list):
for guc in guc_list:
Expand Down Expand Up @@ -51,7 +52,7 @@ def _check_consistency_within_single_segment(self):
return True

def validate(self):
if len(self.gucs) < 2 or self.COORDINATOR_KEY not in self.gucs:
if (len(self.gucs) < 2 and not self.options.coordinatoronly) or self.COORDINATOR_KEY not in self.gucs:
raise Exception("Collections must have at least a coordinator and segment value")

def values(self):
Expand Down
56 changes: 37 additions & 19 deletions gpMgmt/bin/gpinitsystem
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ LOG_STATEMENT_TXT="#log_statement ="
LISTEN_ADR_TXT="listen_addresses"
CONTENT_ID_TXT="gp_contentid"
DBID_TXT="gp_dbid"
SINGLENODE_MODE_TXT="gp_internal_is_singlenode"
INIT_STANDBY_PROG=$GPINITSTANDBY
QE_MIRROR_ARRAY=""
GP_PASSWD=gparray
Expand Down Expand Up @@ -89,6 +90,7 @@ declare -a FTS_HOST_MACHINE_LIST
USE_EXTERNAL_FTS=0
DEMO_CLUSTER_HOST="127.0.0.1"
ETCD_EXIST="false"
SINGLENODE_MODE="false"

#******************************************************************************
# DCA Specific Variables
Expand Down Expand Up @@ -334,7 +336,7 @@ CHK_PARAMS () {
if [ x"" = x"$SEG_PREFIX" ]; then
ERROR_EXIT "[FATAL]:-SEG_PREFIX not specified in $CLUSTER_CONFIG file, is this the correct instance configuration file."
fi
if [ x"" = x"$DATA_DIRECTORY" ]; then
if [ "$SINGLENODE_MODE" == "false" ] && [ x"" = x"$DATA_DIRECTORY" ]; then
ERROR_EXIT "[FATAL]:-DATA_DIRECTORY not specified in $CLUSTER_CONFIG file, is this the correct instance configuration file."
fi

Expand Down Expand Up @@ -411,7 +413,7 @@ CHK_PARAMS () {

# DATA_DIRECTORY
((QE_PRIMARY_COUNT=${#DATA_DIRECTORY[@]}))
if [ $QE_PRIMARY_COUNT -eq 0 ]; then
if [ "$SINGLENODE_MODE" == "false" ] && [ $QE_PRIMARY_COUNT -eq 0 ]; then
ERROR_EXIT "[FATAL]:-Number of primary directories 0 (zero)"
fi

Expand Down Expand Up @@ -469,7 +471,7 @@ CHK_PARAMS () {
fi
# Number of QE hosts in this configuration
((NUM_QES=${#MACHINE_LIST[*]}))
if [ $NUM_QES -eq 0 ]; then
if [ "$SINGLENODE_MODE" == "false" ] && [ $NUM_QES -eq 0 ]; then
ERROR_EXIT "[FATAL]:-Number of Segment instances's 0 (zero)"
else
LOG_MSG "[INFO]:-Number of segment instance hosts = $NUM_QES"
Expand Down Expand Up @@ -1029,7 +1031,7 @@ CREATE_QE_ARRAY () {
LAST_HOST=$QE_HOST
done
if [ $DEBUG_LEVEL -eq 0 ] && [ x"" != x"$VERBOSE" ];then $ECHO;fi
if [ $MIRRORING -eq 1 ] ;then
if [ $MIRRORING -eq 1 ] && [ "$SINGLENODE_MODE" == "false" ] ;then
((MIRROR_OFFSET=$MIRROR_PORT_BASE-$PORT_BASE))
if [ $MIRROR_TYPE -eq 1 ];then
CREATE_SPREAD_MIRROR_ARRAY
Expand Down Expand Up @@ -1330,6 +1332,12 @@ CREATE_QD_DB () {
SED_PG_CONF ${GP_DIR}/$PG_INTERNAL_CONF "$DBID_TXT" "gp_dbid=$GP_DBID" 0
ERROR_CHK $? "set gp_dbid=$GP_DBID in ${GP_DIR}/$PG_INTERNAL_CONF" 1

if [ "$SINGLENODE_MODE" == "true" ]; then
LOG_MSG "[INFO]:-Setting Coordinator singlenodeMode"
SED_PG_CONF ${GP_DIR}/$PG_CONF "$SINGLENODE_MODE_TXT" "gp_internal_is_singlenode=on" 0
ERROR_CHK $? "set gp_internal_is_singlenode=on in ${GP_DIR}/$PG_CONF" 1
fi

if [ x"" != x"$PG_CONF_ADD_FILE" ]; then
LOG_MSG "[INFO]:-Processing additional configuration parameters"
for NEW_PARAM in `$CAT $PG_CONF_ADD_FILE|$TR -s ' '|$TR -d ' '|$GREP -v "^#"`
Expand Down Expand Up @@ -1368,7 +1376,9 @@ CREATE_QD_DB () {
fi
UPDATE_GPCONFIG $GP_PORT $GP_DBID $GP_CONTENT $GP_HOSTNAME $GP_HOSTADDRESS $GP_PORT $GP_DIR p
SET_LOCALE_VARS_BASED_ON_COORDINATOR
LOAD_QE_SYSTEM_DATA $DEFAULTDB
if [ "$SINGLENODE_MODE" == "false" ]; then
LOAD_QE_SYSTEM_DATA $DEFAULTDB
fi
SET_VAR $QD_PRIMARY_ARRAY
LOG_MSG "[INFO]:-End Function $FUNCNAME"
}
Expand Down Expand Up @@ -2128,6 +2138,7 @@ while getopts ":vaqe:c:l:-:p:m:h:n:s:P:S:b:DB:I:O:E:F:M:U:T:C" opt
NAME=${OPTARG%%=*}
VAL=${OPTARG#*=}
case $NAME in
"singlenodeMode" ) SINGLENODE_MODE=$VAL ;;
"max_connections" ) COORDINATOR_MAX_CONNECT=$VAL ;;
"shared_buffers" ) NEW_BUFFERS=$VAL ;;
"su_password" ) GP_PASSWD=$VAL ;;
Expand Down Expand Up @@ -2199,15 +2210,20 @@ else
CHK_MULTI_HOME
CREATE_QE_ARRAY
CHK_QE_ARRAY_PORT_RANGES
CHK_QES

if [ "$SINGLENODE_MODE" == "false" ] ; then
CHK_QES
fi

if [ x"" != x"$OUTPUT_CONFIG" ] ; then
DUMP_OUTPUT_CONFIG
exit 0
fi

DISPLAY_CONFIG
ARRAY_REORDER
if [ "$SINGLENODE_MODE" == "false" ] ; then
ARRAY_REORDER
fi
fi

if [ $USE_EXTERNAL_FTS -ne 0 ];then
Expand All @@ -2224,19 +2240,21 @@ CREATE_QD_DB

CREATE_ARRAY_SORTED_ON_CONTENT_ID

CREATE_SEGMENT IS_PRIMARY
if [ $REPORT_FAIL -ne 0 ];then
LOG_MSG "[FATAL]:-Errors generated from parallel processes" 1
LOG_MSG "[INFO]:-Dumped contents of status file to the log file" 1
ERROR_EXIT "[FATAL]:-Failures detected, see log file $LOG_FILE for more detail"
else
LOG_MSG "[INFO]:-Removing back out file" 1
$RM -f $BACKOUT_FILE
LOG_MSG "[INFO]:-No errors generated from parallel processes" 1
fi
if [ "$SINGLENODE_MODE" == "false" ]; then
CREATE_SEGMENT IS_PRIMARY
if [ $REPORT_FAIL -ne 0 ];then
LOG_MSG "[FATAL]:-Errors generated from parallel processes" 1
LOG_MSG "[INFO]:-Dumped contents of status file to the log file" 1
ERROR_EXIT "[FATAL]:-Failures detected, see log file $LOG_FILE for more detail"
else
LOG_MSG "[INFO]:-Removing back out file" 1
$RM -f $BACKOUT_FILE
LOG_MSG "[INFO]:-No errors generated from parallel processes" 1
fi

if [ -f $DCA_VERSION_FILE ]; then
SET_DCA_CONFIG_SETTINGS
if [ -f $DCA_VERSION_FILE ]; then
SET_DCA_CONFIG_SETTINGS
fi
fi

if [ $USE_EXTERNAL_FTS -ne 0 ];then
Expand Down
4 changes: 4 additions & 0 deletions gpMgmt/bin/gppylib/gparray.py
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,9 @@ def initFromCatalog(dbURL, utility=False):
if not version.isVersionCurrentRelease():
raise Exception("Cannot connect to GPDB version %s from installed version %s"%(version.getVersionRelease(), MAIN_VERSION[0]))

# Get gp_internal_is_singlenode GUC
is_singlenode = dbconn.querySingleton(conn, "SHOW gp_internal_is_singlenode") == "on"

config_rows = dbconn.query(conn, '''
SELECT dbid, content, role, preferred_role, mode, status,
hostname, address, port, datadir
Expand Down Expand Up @@ -993,6 +996,7 @@ def initFromCatalog(dbURL, utility=False):

array = GpArray(segments, origSegments)
array.__version = version
array.is_singlenode = is_singlenode
array.recoveredSegmentDbids = recoveredSegmentDbids
array.hasMirrors = hasMirrors

Expand Down
2 changes: 1 addition & 1 deletion gpMgmt/bin/gppylib/programs/clsRecoverSegment.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def run(self):

gpArray = confProvider.loadSystemConfig(useUtilityMode=False)

if not gpArray.hasMirrors:
if not gpArray.hasMirrors and not gpArray.standbyCoordinator:
raise ExceptionNoStackTraceNeeded(
'GPDB Mirroring replication is not configured for this Cloudberry Database instance.')

Expand Down
7 changes: 7 additions & 0 deletions gpMgmt/bin/gpstart
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class GpStart:
self.fts_hosts = fts_hosts
self.etcd_hosts = etcd_hosts
self.is_external_fts = is_external_fts
self.singlenodemode = False

#
# Some variables that are set during execution
Expand Down Expand Up @@ -169,6 +170,12 @@ class GpStart:
self._startCoordinator()
logger.info("Coordinator Started...")

self.singlenodemode = self.gparray.is_singlenode
if self.singlenodemode:
logger.warning("SinglenodeMode has been enabled, no segment will be created.")
standby_was_started = self._start_standby()
return 0

if self.coordinatoronly:
if self.is_external_fts:
self._start_all_fts()
Expand Down
9 changes: 9 additions & 0 deletions gpMgmt/bin/gpstop
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,12 @@ class GpStop:
"""
self._prepare()

if self.gparray.get_segment_count() == 0:
self.coordinatoronly = True

if self.coordinatoronly:
if self.sighup:
return self._sighup_cluster()
if self.interactive:
if not userinput.ask_yesno(None, "\nContinue with coordinator-only shutdown", 'N'):
raise UserAbortedException()
Expand All @@ -180,6 +185,10 @@ class GpStop:
self._clean_fts()
if self.etcd_hosts is not None:
self._clean_etcd()
if self.restart:
logger.info("Restarting System...")
gp.NewGpStart.local('restarting system', verbose=logging_is_verbose(), coordinatorOnly=self.coordinatoronly,
nostandby=not self.stopstandby, coordinatorDirectory=self.coordinator_datadir)
else:
if self.sighup:
return self._sighup_cluster()
Expand Down
8 changes: 8 additions & 0 deletions gpMgmt/doc/gpinitsystem_help
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ gpinitsystem -c <gpinitsystem_config>
[-p <postgresql_conf_param_file>]
[-s <standby_coordinator_host>
[-P <standby_coordinator_port>] [ {-S | --standby-datadir} <standby_coordinator_datadir>]
[--singlenodeMode={true|false}]
[-m number | --max_connections=<number>] [--shared_buffers=<size>]
[-n locale | --locale=<locale>] [--lc-collate=<locale>]
[--lc-ctype=<locale>] [--lc-messages=<locale>]
Expand Down Expand Up @@ -245,6 +246,13 @@ such as AES256, SM4.
change default passwords immediately after installation.


--singlenodeMode={true|false}

Optional. Starts a Cloudberry instance in singlenode mode. Only one coordinator
and one coordinator standby will be started in gp_role=utility. No segment will
be started. The default is false.


--mirror-mode={group|spread}

Uses the specified mirroring mode. The default is to group the set of mirror
Expand Down
8 changes: 7 additions & 1 deletion gpcontrib/gp_exttable_fdw/extaccess.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,13 @@ external_beginscan(Relation relation, uint32 scancounter,
uri = (char *) strVal(v);
}
}
else if (Gp_role == GP_ROLE_DISPATCH && isMasterOnly)
/*
* SINGLENODE_FIXME:
* In utility mode, it cannot pass "at least one entry and one segment database" check.
* In singlenode mode, we have one entry database. We might support it in utility mode
* in the future too.
*/
else if ((Gp_role == GP_ROLE_DISPATCH && isMasterOnly) || IS_SINGLENODE())
{
/* this is a ON COORDINATOR table. Only get uri if we are the master */
if (segindex == -1)
Expand Down
Loading