fix encode problem in tsdb sync
This commit is contained in:
parent
514e6ca49f
commit
4639796815
|
@ -57,6 +57,8 @@ void tsdbInitMFile(SMFile* pMFile, SDiskID did, int vid, uint32_t ver);
|
||||||
void tsdbInitMFileEx(SMFile* pMFile, SMFile* pOMFile);
|
void tsdbInitMFileEx(SMFile* pMFile, SMFile* pOMFile);
|
||||||
int tsdbEncodeSMFile(void** buf, SMFile* pMFile);
|
int tsdbEncodeSMFile(void** buf, SMFile* pMFile);
|
||||||
void* tsdbDecodeSMFile(void* buf, SMFile* pMFile);
|
void* tsdbDecodeSMFile(void* buf, SMFile* pMFile);
|
||||||
|
int tsdbEncodeSMFileEx(void** buf, SMFile* pMFile);
|
||||||
|
void* tsdbDecodeSMFileEx(void* buf, SMFile* pMFile);
|
||||||
int tsdbApplyMFileChange(SMFile* from, SMFile* to);
|
int tsdbApplyMFileChange(SMFile* from, SMFile* to);
|
||||||
int tsdbCreateMFile(SMFile* pMFile, bool updateHeader);
|
int tsdbCreateMFile(SMFile* pMFile, bool updateHeader);
|
||||||
int tsdbUpdateMFileHeader(SMFile* pMFile);
|
int tsdbUpdateMFileHeader(SMFile* pMFile);
|
||||||
|
@ -301,6 +303,8 @@ void tsdbInitDFileSet(SDFileSet* pSet, SDiskID did, int vid, int fid, uint32_t
|
||||||
void tsdbInitDFileSetEx(SDFileSet* pSet, SDFileSet* pOSet);
|
void tsdbInitDFileSetEx(SDFileSet* pSet, SDFileSet* pOSet);
|
||||||
int tsdbEncodeDFileSet(void** buf, SDFileSet* pSet);
|
int tsdbEncodeDFileSet(void** buf, SDFileSet* pSet);
|
||||||
void* tsdbDecodeDFileSet(void* buf, SDFileSet* pSet);
|
void* tsdbDecodeDFileSet(void* buf, SDFileSet* pSet);
|
||||||
|
int tsdbEncodeDFileSetEx(void** buf, SDFileSet* pSet);
|
||||||
|
void* tsdbDecodeDFileSetEx(void* buf, SDFileSet* pSet);
|
||||||
int tsdbApplyDFileSetChange(SDFileSet* from, SDFileSet* to);
|
int tsdbApplyDFileSetChange(SDFileSet* from, SDFileSet* to);
|
||||||
int tsdbCreateDFileSet(SDFileSet* pSet, bool updateHeader);
|
int tsdbCreateDFileSet(SDFileSet* pSet, bool updateHeader);
|
||||||
int tsdbUpdateDFileSetHeader(SDFileSet* pSet);
|
int tsdbUpdateDFileSetHeader(SDFileSet* pSet);
|
||||||
|
|
|
@ -64,6 +64,27 @@ void *tsdbDecodeSMFile(void *buf, SMFile *pMFile) {
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int tsdbEncodeSMFileEx(void **buf, SMFile *pMFile) {
|
||||||
|
int tlen = 0;
|
||||||
|
|
||||||
|
tlen += tsdbEncodeMFInfo(buf, &(pMFile->info));
|
||||||
|
tlen += taosEncodeString(buf, TSDB_FILE_FULL_NAME(pMFile));
|
||||||
|
|
||||||
|
return tlen;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *tsdbDecodeSMFileEx(void *buf, SMFile *pMFile) {
|
||||||
|
char *aname;
|
||||||
|
buf = tsdbDecodeMFInfo(buf, &(pMFile->info));
|
||||||
|
buf = taosDecodeString(buf, &aname);
|
||||||
|
strncpy(TSDB_FILE_FULL_NAME(pMFile), aname, TSDB_FILENAME_LEN);
|
||||||
|
TSDB_FILE_SET_CLOSED(pMFile);
|
||||||
|
|
||||||
|
tfree(aname);
|
||||||
|
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
int tsdbApplyMFileChange(SMFile *from, SMFile *to) {
|
int tsdbApplyMFileChange(SMFile *from, SMFile *to) {
|
||||||
ASSERT(from != NULL || to != NULL);
|
ASSERT(from != NULL || to != NULL);
|
||||||
|
|
||||||
|
@ -262,6 +283,27 @@ void *tsdbDecodeSDFile(void *buf, SDFile *pDFile) {
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int tsdbEncodeSDFileEx(void **buf, SDFile *pDFile) {
|
||||||
|
int tlen = 0;
|
||||||
|
|
||||||
|
tlen += tsdbEncodeDFInfo(buf, &(pDFile->info));
|
||||||
|
tlen += taosEncodeString(buf, TSDB_FILE_FULL_NAME(pDFile));
|
||||||
|
|
||||||
|
return tlen;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void *tsdbDecodeSDFileEx(void *buf, SDFile *pDFile) {
|
||||||
|
char *aname;
|
||||||
|
|
||||||
|
buf = tsdbDecodeDFInfo(buf, &(pDFile->info));
|
||||||
|
buf = taosDecodeString(buf, &aname);
|
||||||
|
strncpy(TSDB_FILE_FULL_NAME(pDFile), aname, TSDB_FILENAME_LEN);
|
||||||
|
TSDB_FILE_SET_CLOSED(pDFile);
|
||||||
|
tfree(aname);
|
||||||
|
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
int tsdbCreateDFile(SDFile *pDFile, bool updateHeader) {
|
int tsdbCreateDFile(SDFile *pDFile, bool updateHeader) {
|
||||||
ASSERT(pDFile->info.size == 0 && pDFile->info.magic == TSDB_FILE_INIT_MAGIC);
|
ASSERT(pDFile->info.size == 0 && pDFile->info.magic == TSDB_FILE_INIT_MAGIC);
|
||||||
|
|
||||||
|
@ -451,6 +493,28 @@ void *tsdbDecodeDFileSet(void *buf, SDFileSet *pSet) {
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int tsdbEncodeDFileSetEx(void **buf, SDFileSet *pSet) {
|
||||||
|
int tlen = 0;
|
||||||
|
|
||||||
|
tlen += taosEncodeFixedI32(buf, pSet->fid);
|
||||||
|
for (TSDB_FILE_T ftype = 0; ftype < TSDB_FILE_MAX; ftype++) {
|
||||||
|
tlen += tsdbEncodeSDFileEx(buf, TSDB_DFILE_IN_SET(pSet, ftype));
|
||||||
|
}
|
||||||
|
|
||||||
|
return tlen;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *tsdbDecodeDFileSetEx(void *buf, SDFileSet *pSet) {
|
||||||
|
int32_t fid;
|
||||||
|
|
||||||
|
buf = taosDecodeFixedI32(buf, &(fid));
|
||||||
|
pSet->fid = fid;
|
||||||
|
for (TSDB_FILE_T ftype = 0; ftype < TSDB_FILE_MAX; ftype++) {
|
||||||
|
buf = tsdbDecodeSDFileEx(buf, TSDB_DFILE_IN_SET(pSet, ftype));
|
||||||
|
}
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
int tsdbApplyDFileSetChange(SDFileSet *from, SDFileSet *to) {
|
int tsdbApplyDFileSetChange(SDFileSet *from, SDFileSet *to) {
|
||||||
for (TSDB_FILE_T ftype = 0; ftype < TSDB_FILE_MAX; ftype++) {
|
for (TSDB_FILE_T ftype = 0; ftype < TSDB_FILE_MAX; ftype++) {
|
||||||
SDFile *pDFileFrom = (from) ? TSDB_DFILE_IN_SET(from, ftype) : NULL;
|
SDFile *pDFileFrom = (from) ? TSDB_DFILE_IN_SET(from, ftype) : NULL;
|
||||||
|
|
|
@ -205,7 +205,7 @@ static int tsdbSendMetaInfo(SSyncH *pSynch) {
|
||||||
SMFile * pMFile = pRepo->fs->cstatus->pmf;
|
SMFile * pMFile = pRepo->fs->cstatus->pmf;
|
||||||
|
|
||||||
if (pMFile) {
|
if (pMFile) {
|
||||||
tlen = tlen + tsdbEncodeSMFile(NULL, pMFile) + sizeof(TSCKSUM);
|
tlen = tlen + tsdbEncodeSMFileEx(NULL, pMFile) + sizeof(TSCKSUM);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tsdbMakeRoom((void **)(&SYNC_BUFFER(pSynch)), tlen) < 0) {
|
if (tsdbMakeRoom((void **)(&SYNC_BUFFER(pSynch)), tlen) < 0) {
|
||||||
|
@ -216,7 +216,7 @@ static int tsdbSendMetaInfo(SSyncH *pSynch) {
|
||||||
taosEncodeFixedU32(&ptr, tlen);
|
taosEncodeFixedU32(&ptr, tlen);
|
||||||
void *tptr = ptr;
|
void *tptr = ptr;
|
||||||
if (pMFile) {
|
if (pMFile) {
|
||||||
tsdbEncodeSMFile(&ptr, pMFile);
|
tsdbEncodeSMFileEx(&ptr, pMFile);
|
||||||
taosCalcChecksumAppend(0, (uint8_t *)tptr, tlen);
|
taosCalcChecksumAppend(0, (uint8_t *)tptr, tlen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,7 +263,7 @@ static int tsdbRecvMetaInfo(SSyncH *pSynch) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pSynch->pmf = &(pSynch->mf);
|
pSynch->pmf = &(pSynch->mf);
|
||||||
tsdbDecodeSMFile(SYNC_BUFFER(pSynch), pSynch->pmf);
|
tsdbDecodeSMFileEx(SYNC_BUFFER(pSynch), pSynch->pmf);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -496,7 +496,7 @@ static int tsdbSendDFileSetInfo(SSyncH *pSynch, SDFileSet *pSet) {
|
||||||
uint32_t tlen = 0;
|
uint32_t tlen = 0;
|
||||||
|
|
||||||
if (pSet) {
|
if (pSet) {
|
||||||
tlen = tsdbEncodeDFileSet(NULL, pSet) + sizeof(TSCKSUM);
|
tlen = tsdbEncodeDFileSetEx(NULL, pSet) + sizeof(TSCKSUM);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tsdbMakeRoom((void **)(&SYNC_BUFFER(pSynch)), tlen + sizeof(tlen)) < 0) {
|
if (tsdbMakeRoom((void **)(&SYNC_BUFFER(pSynch)), tlen + sizeof(tlen)) < 0) {
|
||||||
|
@ -507,7 +507,7 @@ static int tsdbSendDFileSetInfo(SSyncH *pSynch, SDFileSet *pSet) {
|
||||||
taosEncodeFixedU32(&ptr, tlen);
|
taosEncodeFixedU32(&ptr, tlen);
|
||||||
void *tptr = ptr;
|
void *tptr = ptr;
|
||||||
if (pSet) {
|
if (pSet) {
|
||||||
tsdbEncodeDFileSet(&ptr, pSet);
|
tsdbEncodeDFileSetEx(&ptr, pSet);
|
||||||
taosCalcChecksumAppend(0, (uint8_t *)tptr, tlen);
|
taosCalcChecksumAppend(0, (uint8_t *)tptr, tlen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -551,7 +551,7 @@ static int tsdbRecvDFileSetInfo(SSyncH *pSynch) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pSynch->pdf = &(pSynch->df);
|
pSynch->pdf = &(pSynch->df);
|
||||||
tsdbDecodeDFileSet(SYNC_BUFFER(pSynch), pSynch->pdf);
|
tsdbDecodeDFileSetEx(SYNC_BUFFER(pSynch), pSynch->pdf);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
Loading…
Reference in New Issue