fix 信号量逻辑
This commit is contained in:
parent
7f76e03f69
commit
197d10ed24
@ -530,10 +530,8 @@ class DefaultValue():
|
||||
SSH_KNOWN_HOSTS = os.path.expanduser("~/.ssh/known_hosts")
|
||||
|
||||
# os parameter
|
||||
MAX_REMAIN_SEM = 240000
|
||||
MIN_REMAIN_SEM = 10000
|
||||
NOFILE_LIMIT = 640000
|
||||
DEFAULT_SEM = 32000
|
||||
MAX_SEM = 6400000
|
||||
|
||||
@staticmethod
|
||||
def encodeParaline(cmd, keyword):
|
||||
@ -3372,42 +3370,18 @@ class DefaultValue():
|
||||
logger.logExit(str(e))
|
||||
|
||||
@staticmethod
|
||||
def get_remain_kernel_sem():
|
||||
def get_kernel_sem():
|
||||
"""
|
||||
get remain kernel sem
|
||||
get kernel sem
|
||||
"""
|
||||
# get total sem
|
||||
cmd = "cat /proc/sys/kernel/sem"
|
||||
(status, output) = subprocess.getstatusoutput(cmd)
|
||||
|
||||
if status != 0:
|
||||
if status != 0 or output == "":
|
||||
raise Exception(ErrorCode.GAUSS_501["GAUSS_50110"] % cmd)
|
||||
|
||||
if output == "":
|
||||
return None
|
||||
if len(output.split()) > 1:
|
||||
if int(output.split()[1]) > DefaultValue.DEFAULT_SEM:
|
||||
return None
|
||||
else:
|
||||
raise Exception("cat /proc/sys/kernel/sem failed")
|
||||
parts = output.split()
|
||||
semmns = int(parts[1])
|
||||
|
||||
# get used sem
|
||||
cmd = "ipcs -s"
|
||||
(status, output) = subprocess.getstatusoutput(cmd)
|
||||
if status:
|
||||
raise Exception(ErrorCode.GAUSS_501["GAUSS_50110"] % cmd)
|
||||
current_sems_lines = output.split('\n')
|
||||
# skip the first three lines and process the remaining lines
|
||||
current_sems = [int(line.split()[3]) for line in current_sems_lines[3:] if line.strip()]
|
||||
|
||||
# Calculate the number of semaphores currently in use
|
||||
used_sems = sum(current_sems)
|
||||
|
||||
# Calculate the number of remaining semaphores
|
||||
remaining_sems = semmns - used_sems
|
||||
return remaining_sems
|
||||
return int(output.split()[1])
|
||||
|
||||
class ClusterCommand():
|
||||
'''
|
||||
|
@ -439,11 +439,8 @@ class DN_OLAP(Kernel):
|
||||
dynamicDict = {}
|
||||
dynamicDict = DefaultValue.dynamicGuc("dn", tmpGucFile,
|
||||
gucXml)
|
||||
# get os remain sem
|
||||
remain_sem = DefaultValue.get_remain_kernel_sem()
|
||||
if remain_sem is not None:
|
||||
# calc max_connections for remain sem
|
||||
self.calc_max_connections_for_sems(remain_sem, dynamicDict)
|
||||
|
||||
self.set_max_connections(dynamicDict)
|
||||
if gucXml:
|
||||
dynamicDict["log_line_prefix"] = "'%s'" % \
|
||||
dynamicDict["log_line_prefix"]
|
||||
@ -484,17 +481,15 @@ class DN_OLAP(Kernel):
|
||||
|
||||
self.modifyDummpyStandbyConfigItem()
|
||||
|
||||
def calc_max_connections_for_sems(self, remaining_sems, guc_dict):
|
||||
def set_max_connections(self, guc_dict):
|
||||
"""
|
||||
calc max connetions for remain sem
|
||||
"""
|
||||
if int(remaining_sems) >= DefaultValue.MAX_REMAIN_SEM:
|
||||
total_sem = DefaultValue.get_kernel_sem()
|
||||
if int(total_sem) >= DefaultValue.MAX_SEM:
|
||||
return
|
||||
elif int(remaining_sems) < DefaultValue.MIN_REMAIN_SEM:
|
||||
raise Exception("Error: The remaining signal quantity of the current system is less than %s" % DefaultValue.MIN_REMAIN_SEM)
|
||||
else:
|
||||
# Number of connections with 1w semaphore=200
|
||||
guc_dict["max_connections"] = int(600 / 30000 * int(remaining_sems))
|
||||
guc_dict["max_connections"] = 1000
|
||||
|
||||
def setPghbaConfig(self, clusterAllIpList, try_reload=False, float_ips=None):
|
||||
"""
|
||||
|
Loading…
x
Reference in New Issue
Block a user