Merge pull request #26796 from taosdata/fix/TS-5221

fix: subtable schemaExt
This commit is contained in:
dapan1121 2024-07-26 16:08:29 +08:00 committed by GitHub
commit 99db448f18
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 44 additions and 3 deletions

View File

@ -3546,15 +3546,23 @@ int32_t ctgGetTbMetasFromCache(SCatalog *pCtg, SRequestConnInfo *pConn, SCtgTbMe
continue;
}
int32_t schemaExtSize = 0;
if (stbMeta->schemaExt != NULL) {
schemaExtSize = stbMeta->tableInfo.numOfColumns * sizeof(SSchemaExt);
}
metaSize = CTG_META_SIZE(stbMeta);
pTableMeta = taosMemoryRealloc(pTableMeta, metaSize);
pTableMeta = taosMemoryRealloc(pTableMeta, metaSize + schemaExtSize);
if (NULL == pTableMeta) {
ctgReleaseTbMetaToCache(pCtg, dbCache, pCache);
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
}
TAOS_MEMCPY(&pTableMeta->sversion, &stbMeta->sversion, metaSize - sizeof(SCTableMeta));
pTableMeta->schemaExt = NULL;
TAOS_MEMCPY(&pTableMeta->sversion, &stbMeta->sversion, metaSize + schemaExtSize - sizeof(SCTableMeta));
if (stbMeta->schemaExt != NULL) {
pTableMeta->schemaExt = (SSchemaExt *)((char *)pTableMeta + metaSize);
} else {
pTableMeta->schemaExt = NULL;
}
CTG_UNLOCK(CTG_READ, &pCache->metaLock);
taosHashRelease(dbCache->tbCache, pCache);

View File

@ -2,10 +2,12 @@ import taos
import sys
import datetime
import inspect
import threading
from util.log import *
from util.sql import *
from util.cases import *
from util.common import tdCom
import random
@ -60,6 +62,33 @@ class TDTestCase:
tdSql.query("show dnode 1 variables like '____debugFlag'")
tdSql.checkRows(2)
def threadTest(self, threadID):
print(f"Thread {threadID} starting...")
tdsqln = tdCom.newTdSql()
for i in range(100):
tdsqln.query(f"desc db1.stb_1")
tdsqln.checkRows(3)
print(f"Thread {threadID} finished.")
def case3(self):
tdSql.execute("create database db1")
tdSql.execute("create table db1.stb (ts timestamp, c1 varchar(100)) tags(t1 int)")
tdSql.execute("create table db1.stb_1 using db1.stb tags(1)")
threads = []
for i in range(10):
t = threading.Thread(target=self.threadTest, args=(i,))
threads.append(t)
t.start()
for thread in threads:
print(f"Thread waitting for finish...")
thread.join()
print(f"Mutithread test finished.")
def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring
tdSql.prepare(replica = self.replicaVar)
@ -70,6 +99,10 @@ class TDTestCase:
tdLog.printNoPrefix("==========start case2 run ...............")
self.case2()
tdLog.printNoPrefix("==========end case2 run ...............")
tdLog.printNoPrefix("==========start case3 run ...............")
self.case3()
tdLog.printNoPrefix("==========end case3 run ...............")
def stop(self):
tdSql.close()