feat: database auto compact

This commit is contained in:
kailixu 2024-12-05 13:06:53 +08:00
parent 615f7f395f
commit a6e86619b0
2 changed files with 9 additions and 0 deletions

View File

@ -954,6 +954,14 @@ static int32_t mndCompactDispatch(SRpcMsg *pReq) {
continue;
}
// daysToKeep2 would change after compactEndTime is set
if (pDb->cfg.compactEndTime && (pDb->cfg.compactEndTime <= -pDb->cfg.daysToKeep2)) {
mWarn("db:%p,%s, compact end time:%dm <= -keep2:%dm , skip", pDb, pDb->name, pDb->cfg.compactEndTime,
-pDb->cfg.daysToKeep2);
sdbRelease(pSdb, pDb);
continue;
}
int64_t compactStartTime = pDb->cfg.compactStartTime ? pDb->cfg.compactStartTime : -pDb->cfg.daysToKeep2;
int64_t compactEndTime = pDb->cfg.compactEndTime ? pDb->cfg.compactEndTime : -pDb->cfg.daysPerFile;

View File

@ -334,6 +334,7 @@ alter_db_option(A) ::= COMPACT_INTERVAL NK_VARIABLE(B).
alter_db_option(A) ::= COMPACT_TIME_RANGE signed_integer_list(B). { A.type = DB_OPTION_COMPACT_TIME_RANGE; A.pList = B; }
alter_db_option(A) ::= COMPACT_TIME_RANGE signed_variable_list(B). { A.type = DB_OPTION_COMPACT_TIME_RANGE; A.pList = B; }
alter_db_option(A) ::= COMPACT_TIME_OFFSET NK_INTEGER(B). { A.type = DB_OPTION_COMPACT_TIME_OFFSET; A.val = B; }
alter_db_option(A) ::= COMPACT_TIME_OFFSET NK_VARIABLE(B). { A.type = DB_OPTION_COMPACT_TIME_OFFSET; A.val = B; }
%type integer_list { SNodeList* }
%destructor integer_list { nodesDestroyList($$); }