Merge pull request #26796 from taosdata/fix/TS-5221
fix: subtable schemaExt
This commit is contained in:
commit
99db448f18
|
@ -3546,15 +3546,23 @@ int32_t ctgGetTbMetasFromCache(SCatalog *pCtg, SRequestConnInfo *pConn, SCtgTbMe
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t schemaExtSize = 0;
|
||||||
|
if (stbMeta->schemaExt != NULL) {
|
||||||
|
schemaExtSize = stbMeta->tableInfo.numOfColumns * sizeof(SSchemaExt);
|
||||||
|
}
|
||||||
metaSize = CTG_META_SIZE(stbMeta);
|
metaSize = CTG_META_SIZE(stbMeta);
|
||||||
pTableMeta = taosMemoryRealloc(pTableMeta, metaSize);
|
pTableMeta = taosMemoryRealloc(pTableMeta, metaSize + schemaExtSize);
|
||||||
if (NULL == pTableMeta) {
|
if (NULL == pTableMeta) {
|
||||||
ctgReleaseTbMetaToCache(pCtg, dbCache, pCache);
|
ctgReleaseTbMetaToCache(pCtg, dbCache, pCache);
|
||||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
TAOS_MEMCPY(&pTableMeta->sversion, &stbMeta->sversion, metaSize - sizeof(SCTableMeta));
|
TAOS_MEMCPY(&pTableMeta->sversion, &stbMeta->sversion, metaSize + schemaExtSize - sizeof(SCTableMeta));
|
||||||
pTableMeta->schemaExt = NULL;
|
if (stbMeta->schemaExt != NULL) {
|
||||||
|
pTableMeta->schemaExt = (SSchemaExt *)((char *)pTableMeta + metaSize);
|
||||||
|
} else {
|
||||||
|
pTableMeta->schemaExt = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
CTG_UNLOCK(CTG_READ, &pCache->metaLock);
|
CTG_UNLOCK(CTG_READ, &pCache->metaLock);
|
||||||
taosHashRelease(dbCache->tbCache, pCache);
|
taosHashRelease(dbCache->tbCache, pCache);
|
||||||
|
|
|
@ -2,10 +2,12 @@ import taos
|
||||||
import sys
|
import sys
|
||||||
import datetime
|
import datetime
|
||||||
import inspect
|
import inspect
|
||||||
|
import threading
|
||||||
|
|
||||||
from util.log import *
|
from util.log import *
|
||||||
from util.sql import *
|
from util.sql import *
|
||||||
from util.cases import *
|
from util.cases import *
|
||||||
|
from util.common import tdCom
|
||||||
import random
|
import random
|
||||||
|
|
||||||
|
|
||||||
|
@ -60,6 +62,33 @@ class TDTestCase:
|
||||||
tdSql.query("show dnode 1 variables like '____debugFlag'")
|
tdSql.query("show dnode 1 variables like '____debugFlag'")
|
||||||
tdSql.checkRows(2)
|
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
|
def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring
|
||||||
tdSql.prepare(replica = self.replicaVar)
|
tdSql.prepare(replica = self.replicaVar)
|
||||||
|
|
||||||
|
@ -70,6 +99,10 @@ class TDTestCase:
|
||||||
tdLog.printNoPrefix("==========start case2 run ...............")
|
tdLog.printNoPrefix("==========start case2 run ...............")
|
||||||
self.case2()
|
self.case2()
|
||||||
tdLog.printNoPrefix("==========end case2 run ...............")
|
tdLog.printNoPrefix("==========end case2 run ...............")
|
||||||
|
|
||||||
|
tdLog.printNoPrefix("==========start case3 run ...............")
|
||||||
|
self.case3()
|
||||||
|
tdLog.printNoPrefix("==========end case3 run ...............")
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
tdSql.close()
|
tdSql.close()
|
||||||
|
|
Loading…
Reference in New Issue