1.磁盘检测问题修复

2.thread_count问题修复
This commit is contained in:
yewk 2022-12-10 06:58:36 +00:00 committed by Gitee
parent 91ef6e7c26
commit e7dc532e16
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
5 changed files with 32 additions and 36 deletions

View File

@ -982,7 +982,7 @@ static void GetCandiCateOtherMsg(DnArbCtx *ctx, int32 memIdx)
static void GetCandiCateTermLsn(DnArbCtx *ctx, int32 memIdx)
{
cm_local_replconninfo *localRepl = &(ctx->dnReport[memIdx].local_status);
if (!ctx->cond.hasDynamicPrimary && ctx->dnReport[memIdx].sendFailoverTimes >= MAX_SEND_FAILOVER_TIMES) {
if (ctx->dyPrim.count == 0 && ctx->dnReport[memIdx].sendFailoverTimes >= MAX_SEND_FAILOVER_TIMES) {
return;
}
@ -991,7 +991,7 @@ static void GetCandiCateTermLsn(DnArbCtx *ctx, int32 memIdx)
ctx->cond.maxLsn = ctx->dnReport[memIdx].local_status.last_flush_lsn;
}
if (!ctx->cond.hasDynamicPrimary && localRepl->disconn_mode != PROHIBIT_CONNECTION) {
if (ctx->dyPrim.count == 0 && localRepl->disconn_mode != PROHIBIT_CONNECTION) {
return;
}

View File

@ -322,7 +322,7 @@ void GetCandiInfoBackup(DnArbCtx *ctx, int32 memIdx)
if (ctx->roleGroup->instanceMember[memIdx].role == INSTANCE_ROLE_PRIMARY) {
ctx->cond.staticPriIdx = memIdx;
}
if (!ctx->cond.hasDynamicPrimary && ctx->dnReport[memIdx].sendFailoverTimes >= MAX_SEND_FAILOVER_TIMES) {
if (ctx->dyPrim.count == 0 && ctx->dnReport[memIdx].sendFailoverTimes >= MAX_SEND_FAILOVER_TIMES) {
return;
}
if (XLByteWE_W_TERM(localRepl->term, localRepl->last_flush_lsn, ctx->cond.maxTerm, ctx->cond.maxLsn)) {

View File

@ -29,10 +29,6 @@
#include "cms_ddb_adapter.h"
#include "cms_common.h"
const int CM_LARGE_CLUSTER_NODE_NUM = 32;
const int CM_CTL_MORE_THREADS = 4;
const int CM_CTL_LESS_THREADS = 2;
void ExecSystemSsh(uint32 remoteNodeid, const char *cmd, int *result, const char *resultPath)
{
int rc;
@ -602,36 +598,13 @@ void clean_init_cluster_state()
void SendSignalToAgentThreads()
{
uint32 ctlThreadNum = (uint32)GetCtlThreadNum();
for (unsigned int i = 0; i < (gWorkThreads.count - ctlThreadNum); i++) {
if (pthread_kill(gWorkThreads.threads[i].tid, SIGUSR1) != 0) {
write_runlog(ERROR, "send SIGUSR1 to thread %lu failed.\n", gWorkThreads.threads[i].tid);
} else {
write_runlog(LOG, "send SIGUSR1 to thread %lu.\n", gWorkThreads.threads[i].tid);
}
if (pthread_kill(gIOThreads.threads[0].tid, SIGUSR1) != 0) {
write_runlog(ERROR, "send SIGUSR1 to thread %lu failed.\n", gIOThreads.threads[0].tid);
} else {
write_runlog(LOG, "send SIGUSR1 to thread %lu.\n", gIOThreads.threads[0].tid);
}
}
int GetCtlThreadNum()
{
/* Before cm version C20, thread_count range is [2 - 255],
If process cm_ctl thread num set to 4,
But user maybe configed thread_count to 2,
Then it will no thead process agent report msg.
so if user configed thread_count less than 4,
will only alloc one thread to process cm_ctl msg.
*/
if (g_node_num < CM_LARGE_CLUSTER_NODE_NUM) {
return CM_CTL_LESS_THREADS;
}
if (cm_thread_count <= CM_CTL_MORE_THREADS) {
return CM_CTL_LESS_THREADS;
}
return CM_CTL_MORE_THREADS;
}
void FreeNotifyMsg()
{
for (uint32 i = 0; i < g_dynamic_header->relationCount; i++) {

View File

@ -42,6 +42,7 @@ typedef enum {
} ReadOnlyFsmState;
typedef enum {
DISK_USAGE_INIT,
DISK_USAGE_NORMAL,
DISK_USAGE_EXCEEDS_THRESHOLD,
READ_ONLY_EVENT_MAX
@ -55,6 +56,7 @@ typedef enum {
SET_READ_ONLY_OFF,
RECORD_MANUALLY_SET_READ_ONLY,
SET_DDB_1_CONDITIONAL,
RECORD_DISK_USAGE_ABNORMAL,
READ_ONLY_ACT_MAX
} ReadOnlyFsmAct;
@ -212,7 +214,9 @@ static int InitNodeReadonlyInfo()
static ReadOnlyFsmEvent GetReadOnlyFsmEvent(const DataNodeReadOnlyInfo *instance)
{
if (instance->dataDiskUsage >= g_readOnlyThreshold) {
if (instance->dataDiskUsage == 0) {
return DISK_USAGE_INIT;
} else if (instance->dataDiskUsage >= g_readOnlyThreshold) {
g_allHealth = false;
return DISK_USAGE_EXCEEDS_THRESHOLD;
} else {
@ -234,11 +238,18 @@ static ReadOnlyFsmState GetReadOnlyFsmState(const DataNodeReadOnlyInfo *instance
}
static ReadOnlyFsmEntry g_readOnlyEntry[READ_ONLY_EVENT_MAX][READ_ONLY_STATE_MAX] = {
/* DISK_USAGE_INIT */
{
{RECORD_DISK_USAGE_ABNORMAL, ALM_AT_Resume}, /* NOT_READ_ONLY_AND_DDB_0 */
{RECORD_DISK_USAGE_ABNORMAL, ALM_AT_Resume}, /* NOT_READ_ONLY_AND_DDB_1 */
{RECORD_DISK_USAGE_ABNORMAL, ALM_AT_Resume}, /* READ_ONLY_AND_DDB_0 */
{RECORD_DISK_USAGE_ABNORMAL, ALM_AT_Resume}, /* READ_ONLY_AND_DDB_1 */
},
/* DISK_USAGE_NORMAL */
{
{DO_NOTING, ALM_AT_Resume}, /* NOT_READ_ONLY_AND_DDB_0 */
{SET_DDB_0, ALM_AT_Resume}, /* NOT_READ_ONLY_AND_DDB_1 */
{SET_DDB_1_CONDITIONAL, ALM_AT_Resume}, /* READ_ONLY_AND_DDB_0 */
{SET_DDB_1_CONDITIONAL, ALM_AT_Resume}, /* READ_ONLY_AND_DDB_0 */
{SET_READ_ONLY_OFF, ALM_AT_Resume}, /* READ_ONLY_AND_DDB_1 */
},
/* DISK_USAGE_EXCEEDS_THRESHOLD */
@ -483,6 +494,14 @@ bool ReadOnlyActSetDdbTo1Conditional(DataNodeReadOnlyInfo *instance)
return false;
}
bool ReadOnlyActRecordDiskUsageAbnormal(DataNodeReadOnlyInfo *instance)
{
write_runlog(WARNING, "[%s] instance %u disk usage abnormal, disk_usage:%u, read_only_threshold:%u\n",
__FUNCTION__, instance->instanceId, instance->dataDiskUsage, g_readOnlyThreshold);
instance->finalState = false;
return false;
}
static void InitReadOnlyFsmActFunc()
{
g_readOnlyActFunc[DO_NOTING] = ReadOnlyActDoNoting;
@ -492,6 +511,7 @@ static void InitReadOnlyFsmActFunc()
g_readOnlyActFunc[SET_READ_ONLY_OFF] = ReadOnlyActSetReadOnlyOff;
g_readOnlyActFunc[RECORD_MANUALLY_SET_READ_ONLY] = ReadOnlyActRecordManuallySetReadOnly;
g_readOnlyActFunc[SET_DDB_1_CONDITIONAL] = ReadOnlyActSetDdbTo1Conditional;
g_readOnlyActFunc[RECORD_DISK_USAGE_ABNORMAL] = ReadOnlyActRecordDiskUsageAbnormal;
}
void* StorageDetectMain(void* arg)

View File

@ -2635,6 +2635,9 @@ int main(int argc, char** argv)
if ((uint32)cm_thread_count > g_node_num * workerCountPerNode) {
totalWorker = g_node_num * workerCountPerNode;
}
if (totalWorker < workerCountPerNode) {
totalWorker = workerCountPerNode;
}
uint32 ioWorkerCount = totalWorker / 3;
uint32 cltWorkerCount = (totalWorker - ioWorkerCount) / 2;