Merge pull request #26200 from taosdata/fix/TD-30634-3.0

Fix/TD-30634-3.0
This commit is contained in:
Hongze Cheng 2024-06-20 15:46:52 +08:00 committed by GitHub
commit 002917fd4a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 63 additions and 9 deletions

View File

@ -1766,7 +1766,7 @@ static int32_t mndUpdateSuperTableColumnCompress(SMnode *pMnode, const SStbObj *
uint32_t dst = 0;
updated = tUpdateCompress(pCmpr->alg, p->bytes, TSDB_COLVAL_COMPRESS_DISABLED, TSDB_COLVAL_LEVEL_DISABLED,
TSDB_COLVAL_LEVEL_MEDIUM, &dst);
if (updated) pCmpr->alg = dst;
if (updated > 0) pCmpr->alg = dst;
break;
}
}
@ -1774,7 +1774,11 @@ static int32_t mndUpdateSuperTableColumnCompress(SMnode *pMnode, const SStbObj *
if (updated == 0) {
terrno = TSDB_CODE_MND_COLUMN_COMPRESS_ALREADY_EXIST;
return -1;
} else if (updated == -1) {
terrno = TSDB_CODE_TSC_COMPRESS_LEVEL_ERROR;
return -1;
}
pNew->colVer++;
return 0;

View File

@ -2240,7 +2240,7 @@ int32_t metaUpdateTableColCompress(SMeta *pMeta, int64_t version, SVAlterTbReq *
uint32_t dst = 0;
updated = tUpdateCompress(p->alg, pReq->compress, TSDB_COLVAL_COMPRESS_DISABLED, TSDB_COLVAL_LEVEL_DISABLED,
TSDB_COLVAL_LEVEL_MEDIUM, &dst);
if (updated) {
if (updated > 0) {
p->alg = dst;
}
}
@ -2250,6 +2250,11 @@ int32_t metaUpdateTableColCompress(SMeta *pMeta, int64_t version, SVAlterTbReq *
tDecoderClear(&dc);
terrno = TSDB_CODE_VND_COLUMN_COMPRESS_ALREADY_EXIST;
goto _err;
} else if (updated < 0) {
tdbFree(pVal);
tDecoderClear(&dc);
terrno = TSDB_CODE_TSC_COMPRESS_LEVEL_ERROR;
goto _err;
}
tbEntry.version = version;

View File

@ -2916,8 +2916,11 @@ int32_t tcompressDebug(uint32_t cmprAlg, uint8_t *l1Alg, uint8_t *l2Alg, uint8_t
*level = lvl;
return 0;
}
int8_t tUpdateCompress(uint32_t oldCmpr, uint32_t newCmpr, uint8_t l2Disabled, uint8_t lvlDiabled, uint8_t lvlDefault,
uint32_t *dst) {
int8_t update = 0;
uint8_t ol1 = COMPRESS_L1_TYPE_U32(oldCmpr);
uint8_t ol2 = COMPRESS_L2_TYPE_U32(oldCmpr);
uint8_t olvl = COMPRESS_L2_TYPE_LEVEL_U32(oldCmpr);
@ -2925,10 +2928,17 @@ int8_t tUpdateCompress(uint32_t oldCmpr, uint32_t newCmpr, uint8_t l2Disabled, u
uint8_t nl1 = COMPRESS_L1_TYPE_U32(newCmpr);
uint8_t nl2 = COMPRESS_L2_TYPE_U32(newCmpr);
uint8_t nlvl = COMPRESS_L2_TYPE_LEVEL_U32(newCmpr);
// nl1 == 0, not update encode
// nl2 == 0, not update compress
// nl3 == 0, not update level
if (nl1 != 0 && ol1 != nl1) {
SET_COMPRESS(nl1, ol2, olvl, *dst);
return 1;
} else if (nl2 != 0 && ol2 != nl2) {
update = 1;
ol1 = nl1;
}
if (nl2 != 0 && ol2 != nl2) {
if (nl2 == l2Disabled) {
SET_COMPRESS(ol1, nl2, lvlDiabled, *dst);
} else {
@ -2938,10 +2948,20 @@ int8_t tUpdateCompress(uint32_t oldCmpr, uint32_t newCmpr, uint8_t l2Disabled, u
SET_COMPRESS(ol1, nl2, olvl, *dst);
}
}
return 1;
} else if (nlvl != 0 && olvl != nlvl) {
SET_COMPRESS(ol1, ol2, nlvl, *dst);
return 1;
update = 1;
ol2 = nl2;
}
return 0;
if (nlvl != 0 && olvl != nlvl) {
if (update == 0) {
if (ol2 == L2_DISABLED) {
update = -1;
return update;
}
}
SET_COMPRESS(ol1, ol2, nlvl, *dst);
update = 1;
}
return update;
}

View File

@ -163,6 +163,31 @@ sql alter table $stb modify column f compress 'zlib'
sql desc $stb
sql alter table $stb modify column f compress 'zstd'
sql alter table $stb modify column f compress 'zstd' level 'h'
sql_error alter table $stb modify column f compress 'zstd' level 'h'
sql alter table $stb modify column f compress 'lz4' level 'h'
sql_error alter table $stb modify column f compress 'lz4' level 'h'
sql alter table $stb modify column f level 'low'
sql_error alter table $stb modify column f compress 'lz4'
sql_error alter table $stb modify column f compress 'lz4' level 'low'
sql alter table $stb modify column f compress 'zstd' level 'h'
sql_error alter table $stb modify column f compress 'zstd'
sql_error alter table $stb modify column f level 'h'
sql alter table $stb modify column f compress 'lz4'
sql_error alter table $stb modify column d compress 'lz4' # same with init
sql alter table $stb modify column d compress 'disabled'
sql desc $stb