dmchen/delete-trans-tool
This commit is contained in:
parent
e42cf46cfc
commit
0da625bf55
|
@ -121,6 +121,8 @@ void mndGenerateMachineCode();
|
|||
|
||||
void mndDumpSdb();
|
||||
|
||||
void mndDeleteTrans();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -59,6 +59,7 @@ static struct {
|
|||
#endif
|
||||
bool dumpConfig;
|
||||
bool dumpSdb;
|
||||
bool deleteTrans;
|
||||
bool generateGrant;
|
||||
bool memDbg;
|
||||
bool checkS3;
|
||||
|
@ -187,6 +188,8 @@ static int32_t dmParseArgs(int32_t argc, char const *argv[]) {
|
|||
}
|
||||
} else if (strcmp(argv[i], "-s") == 0) {
|
||||
global.dumpSdb = true;
|
||||
} else if (strcmp(argv[i], "-dTxn") == 0) {
|
||||
global.deleteTrans = true;
|
||||
} else if (strcmp(argv[i], "-E") == 0) {
|
||||
if (i < argc - 1) {
|
||||
if (strlen(argv[++i]) >= PATH_MAX) {
|
||||
|
@ -436,6 +439,22 @@ int mainWindows(int argc, char **argv) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (global.deleteTrans) {
|
||||
TdFilePtr pFile;
|
||||
if ((code = dmCheckRunning(tsDataDir, &pFile)) != 0) {
|
||||
printf("failed to generate encrypt code since taosd is running, please stop it first, reason:%s",
|
||||
tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
||||
mndDeleteTrans();
|
||||
taosCleanupCfg();
|
||||
taosCloseLog();
|
||||
taosCleanupArgs();
|
||||
taosConvDestroy();
|
||||
return 0;
|
||||
}
|
||||
|
||||
osSetProcPath(argc, (char **)argv);
|
||||
taosCleanupArgs();
|
||||
|
||||
|
|
|
@ -630,4 +630,30 @@ void mndDumpSdb() {
|
|||
mInfo("dump sdb info success");
|
||||
}
|
||||
|
||||
void mndDeleteTrans() {
|
||||
mInfo("start to dump sdb info to sdb.json");
|
||||
|
||||
char path[PATH_MAX * 2] = {0};
|
||||
(void)snprintf(path, sizeof(path), "%s%smnode", tsDataDir, TD_DIRSEP);
|
||||
|
||||
SMsgCb msgCb = {0};
|
||||
msgCb.reportStartupFp = reportStartup;
|
||||
msgCb.sendReqFp = sendReq;
|
||||
msgCb.sendSyncReqFp = sendSyncReq;
|
||||
msgCb.sendRspFp = sendRsp;
|
||||
msgCb.mgmt = (SMgmtWrapper *)(&msgCb); // hack
|
||||
tmsgSetDefault(&msgCb);
|
||||
|
||||
(void)walInit(NULL);
|
||||
(void)syncInit();
|
||||
|
||||
SMnodeOpt opt = {.msgCb = msgCb};
|
||||
SMnode *pMnode = mndOpen(path, &opt);
|
||||
if (pMnode == NULL) return;
|
||||
|
||||
(void)sdbWriteFileForDump(pMnode->pSdb);
|
||||
|
||||
mInfo("dump sdb info success");
|
||||
}
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
|
|
@ -280,6 +280,7 @@ int32_t sdbReadFile(SSdb *pSdb);
|
|||
*/
|
||||
int32_t sdbWriteFile(SSdb *pSdb, int32_t delta);
|
||||
|
||||
int32_t sdbWriteFileForDump(SSdb *pSdb);
|
||||
/**
|
||||
* @brief Parse and write raw data to sdb, then free the pRaw object
|
||||
*
|
||||
|
|
|
@ -381,7 +381,7 @@ int32_t sdbReadFile(SSdb *pSdb) {
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t sdbWriteFileImp(SSdb *pSdb) {
|
||||
static int32_t sdbWriteFileImp(SSdb *pSdb, int32_t skip_type) {
|
||||
int32_t code = 0;
|
||||
|
||||
char tmpfile[PATH_MAX] = {0};
|
||||
|
@ -409,6 +409,7 @@ static int32_t sdbWriteFileImp(SSdb *pSdb) {
|
|||
}
|
||||
|
||||
for (int32_t i = SDB_MAX - 1; i >= 0; --i) {
|
||||
if (i == skip_type) continue;
|
||||
SdbEncodeFp encodeFp = pSdb->encodeFps[i];
|
||||
if (encodeFp == NULL) continue;
|
||||
|
||||
|
@ -550,7 +551,7 @@ int32_t sdbWriteFile(SSdb *pSdb, int32_t delta) {
|
|||
}
|
||||
}
|
||||
if (code == 0) {
|
||||
code = sdbWriteFileImp(pSdb);
|
||||
code = sdbWriteFileImp(pSdb, -1);
|
||||
}
|
||||
if (code == 0) {
|
||||
if (pSdb->pWal != NULL) {
|
||||
|
@ -566,6 +567,14 @@ int32_t sdbWriteFile(SSdb *pSdb, int32_t delta) {
|
|||
return code;
|
||||
}
|
||||
|
||||
int32_t sdbWriteFileForDump(SSdb *pSdb) {
|
||||
int32_t code = 0;
|
||||
|
||||
code = sdbWriteFileImp(pSdb, 0);
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t sdbDeploy(SSdb *pSdb) {
|
||||
int32_t code = 0;
|
||||
code = sdbDeployData(pSdb);
|
||||
|
|
Loading…
Reference in New Issue