From da4b78f1bad71b606461c46066a759249ac50d28 Mon Sep 17 00:00:00 2001 From: lichuang Date: Wed, 26 May 2021 18:27:04 +0800 Subject: [PATCH] [TD-4034]when config changed,apply a commit msg then config will be applied --- src/tsdb/src/tsdbCommit.c | 3 +++ src/tsdb/src/tsdbMain.c | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/src/tsdb/src/tsdbCommit.c b/src/tsdb/src/tsdbCommit.c index 24f1c11628..c43b35492d 100644 --- a/src/tsdb/src/tsdbCommit.c +++ b/src/tsdb/src/tsdbCommit.c @@ -90,6 +90,9 @@ static int tsdbApplyRtn(STsdbRepo *pRepo); static int tsdbApplyRtnOnFSet(STsdbRepo *pRepo, SDFileSet *pSet, SRtn *pRtn); void *tsdbCommitData(STsdbRepo *pRepo) { + if (pRepo->imem == NULL) { + return NULL; + } tsdbStartCommit(pRepo); // Commit to update meta file diff --git a/src/tsdb/src/tsdbMain.c b/src/tsdb/src/tsdbMain.c index a8bbd0d69e..d4bc712275 100644 --- a/src/tsdb/src/tsdbMain.c +++ b/src/tsdb/src/tsdbMain.c @@ -268,6 +268,12 @@ int32_t tsdbConfigRepo(STsdbRepo *repo, STsdbCfg *pCfg) { repo->config_changed = true; pthread_mutex_unlock(&repo->save_mutex); + + // schedule a commit msg then the new config will be applyed immediatly + if (tsdbLockRepo(repo) < 0) return -1; + tsdbScheduleCommit(repo); + if (tsdbUnlockRepo(repo) < 0) return -1; + return 0; #if 0 STsdbRepo *pRepo = (STsdbRepo *)repo; -- GitLab