Skip to content
Closed
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
  •  
  •  
  •  
7 changes: 7 additions & 0 deletions GNUmakefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,13 @@ distclean maintainer-clean:
installcheck-resgroup:
$(MAKE) -C src/test/isolation2 $@

# Create or destroy a demo single node.
create-demo-singlenode:
$(MAKE) -C gpAux/gpdemo create-demo-cluster NUM_PRIMARY_MIRROR_PAIRS=0 SINGLENODE_MODE=true

destroy-demo-singlenode:
$(MAKE) -C gpAux/gpdemo destroy-demo-cluster SINGLENODE_MODE=true

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

SINGLENODE_OPTS=""
if [ "${SINGLENODE_MODE}" == "true" ]; then
SINGLENODE_MODE="true"
SINGLENODE_OPTS="--singlenodeMode=true"
fi

# ======================================================================
# Database Ports
# ======================================================================
Expand Down Expand Up @@ -391,33 +397,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
63 changes: 42 additions & 21 deletions gpMgmt/bin/gpinitsystem
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,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 +335,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 +412,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 +470,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 +1030,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 @@ -1368,7 +1369,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 @@ -1517,7 +1520,11 @@ STOP_QD_PRODUCTION () {
if [ -f $GPSTOP ]; then
GPSTOP_OPTS=$(OUTPUT_LEVEL_OPTS)
export COORDINATOR_DATA_DIRECTORY=${COORDINATOR_DIRECTORY}/${SEG_PREFIX}-1
$GPSTOP -a -l $LOG_DIR -m -d $COORDINATOR_DATA_DIRECTORY $GPSTOP_OPTS
if [ "$SINGLENODE_MODE" == "false" ]; then
$GPSTOP -a -l $LOG_DIR -m -d $COORDINATOR_DATA_DIRECTORY $GPSTOP_OPTS
else
$GPSTOP -a -c -l $LOG_DIR -m -d $COORDINATOR_DATA_DIRECTORY $GPSTOP_OPTS
fi
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
LOG_MSG "[INFO]:-Successfully shutdown the new Cloudberry instance"
Expand Down Expand Up @@ -1571,7 +1578,13 @@ START_QD_PRODUCTION () {
if [ -f $GPSTART ]; then
GPSTART_OPTS=$(OUTPUT_LEVEL_OPTS)
export COORDINATOR_DATA_DIRECTORY=${COORDINATOR_DIRECTORY}/${SEG_PREFIX}-1
$GPSTART -a -l $LOG_DIR -d $COORDINATOR_DATA_DIRECTORY $GPSTART_OPTS
if [ "$SINGLENODE_MODE" == "false" ]; then
$GPSTART -a -l $LOG_DIR -d $COORDINATOR_DATA_DIRECTORY $GPSTART_OPTS
else
# In single node mode, we should gpstart with "--singlenodeMode".
# We can't get enough info from stopped cluster.
$GPSTART -a --singlenodeMode -l $LOG_DIR -d $COORDINATOR_DATA_DIRECTORY $GPSTART_OPTS
fi

if [ $? -eq 0 ];then
LOG_MSG "[INFO]:-Successfully started new Cloudberry instance"
Expand Down Expand Up @@ -2128,6 +2141,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 +2213,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 +2243,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
23 changes: 16 additions & 7 deletions gpMgmt/bin/gppylib/commands/gp.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@ def set_special(self, special):
if opt: self.append(opt)
return self

def set_singlenode(self):
self.append("-c gp_role=singlenode")
return self

def set_utility(self):
self.append("-c gp_role=utility")
return self
Expand Down Expand Up @@ -295,18 +299,21 @@ def __init__(self, datadir, mode, wait, timeout):
class CoordinatorStart(Command):
def __init__(self, name, dataDir, port, era,
wrapper, wrapper_args, specialMode=None, restrictedMode=False, timeout=SEGMENT_TIMEOUT_DEFAULT,
max_connections=1, utilityMode=False, ctxt=LOCAL, remoteHost=None,
max_connections=1, utilityMode=False, singlenodeMode=False, ctxt=LOCAL, remoteHost=None,
wait=True
):
self.dataDir=dataDir
self.port=port
self.utilityMode=utilityMode
self.singlenodeMode=singlenodeMode
self.wrapper=wrapper
self.wrapper_args=wrapper_args

# build backend options
b = PgCtlBackendOptions(port)
if utilityMode:
if singlenodeMode:
b.set_singlenode()
elif utilityMode:
b.set_utility()
else:
b.set_coordinator()
Expand All @@ -323,10 +330,10 @@ def __init__(self, name, dataDir, port, era,
@staticmethod
def local(name, dataDir, port, era,
wrapper, wrapper_args, specialMode=None, restrictedMode=False, timeout=SEGMENT_TIMEOUT_DEFAULT,
max_connections=1, utilityMode=False):
max_connections=1, utilityMode=False, singlenodeMode=False):
cmd=CoordinatorStart(name, dataDir, port, era,
wrapper, wrapper_args, specialMode, restrictedMode, timeout,
max_connections, utilityMode)
max_connections, utilityMode, singlenodeMode)
cmd.run(validateAfter=True)

#-----------------------------------------------
Expand Down Expand Up @@ -729,7 +736,7 @@ def local(name,coordinatorOnly=False,restricted=False):

#-----------------------------------------------
class NewGpStart(Command):
def __init__(self, name, coordinatorOnly=False, restricted=False, verbose=False,nostandby=False,ctxt=LOCAL, remoteHost=None, coordinatorDirectory=None):
def __init__(self, name, coordinatorOnly=False, singlenodeMode=False, restricted=False, verbose=False,nostandby=False,ctxt=LOCAL, remoteHost=None, coordinatorDirectory=None):
self.cmdStr="$GPHOME/bin/gpstart -a"
if coordinatorOnly:
self.cmdStr += " -c"
Expand All @@ -742,13 +749,15 @@ def __init__(self, name, coordinatorOnly=False, restricted=False, verbose=False,
self.cmdStr += " -y"
if coordinatorDirectory:
self.cmdStr += " -d " + coordinatorDirectory
if singlenodeMode:
self.cmdStr += " --singlenodeMode "

Command.__init__(self,name,self.cmdStr,ctxt,remoteHost)

@staticmethod
def local(name,coordinatorOnly=False,restricted=False,verbose=False,nostandby=False,
def local(name,coordinatorOnly=False,singlenodeMode=False,restricted=False,verbose=False,nostandby=False,
coordinatorDirectory=None):
cmd=NewGpStart(name,coordinatorOnly,restricted,verbose,nostandby,
cmd=NewGpStart(name,coordinatorOnly,singlenodeMode,restricted,verbose,nostandby,
coordinatorDirectory=coordinatorDirectory)
cmd.run(validateAfter=True)

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
16 changes: 12 additions & 4 deletions gpMgmt/bin/gpstart
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ class GpStart:
skip_heap_checksum_validation=False,
fts_hosts=None,
etcd_hosts=None,
is_external_fts=False
is_external_fts=False,
singlenodeMode=False
):
assert (specialMode in [None, 'maintenance'])
self.specialMode = specialMode
Expand All @@ -77,6 +78,7 @@ class GpStart:
self.fts_hosts = fts_hosts
self.etcd_hosts = etcd_hosts
self.is_external_fts = is_external_fts
self.singlenodeMode = singlenodeMode

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

if self.singlenodeMode:
standby_was_started = self._start_standby()
return 0

if self.coordinatoronly:
if self.is_external_fts:
self._start_all_fts()
Expand Down Expand Up @@ -489,7 +495,7 @@ class GpStart:
self.coordinator_datadir, self.port, self.era, wrapper=self.wrapper,
wrapper_args=self.wrapper_args, specialMode=self.specialMode,
restrictedMode=self.restricted, timeout=self.timeout, utilityMode=True,
max_connections=self.max_connections)
max_connections=self.max_connections, singlenodeMode=self.singlenodeMode)
cmd.run()

if cmd.get_results().rc != 0:
Expand Down Expand Up @@ -857,6 +863,7 @@ class GpStart:
help='time to wait for segment startup (in seconds)')
addTo.add_option('', '--wrapper', dest="wrapper", default=None, type='string')
addTo.add_option('', '--wrapper-args', dest="wrapper_args", default=None, type='string')
addTo.add_option('', '--singlenodeMode', dest="singlenodeMode", action='store_true', default=False)
addTo.add_option('-S', '--skip_standby_check', dest="skip_standby_check", action='store_true', default=False)
addTo.add_option('--skip-heap-checksum-validation', dest='skip_heap_checksum_validation',
action='store_true', default=False, help='Skip the validation of data_checksums GUC. '
Expand Down Expand Up @@ -905,7 +912,7 @@ class GpStart:
coordinator_datadir=options.coordinatorDataDirectory,
parallel=options.parallel,
quiet=options.quiet,
coordinatoronly=options.coordinator_only,
coordinatoronly=(options.coordinator_only or options.singlenodeMode),
interactive=options.interactive,
timeout=options.timeout,
wrapper=options.wrapper,
Expand All @@ -915,7 +922,8 @@ class GpStart:
skip_heap_checksum_validation=options.skip_heap_checksum_validation,
fts_hosts=options.fts_hosts,
etcd_hosts=options.etcd_hosts,
is_external_fts=external_fts
is_external_fts=external_fts,
singlenodeMode=options.singlenodeMode
)


Expand Down
Loading