Merge pull request #29716 from taosdata/fix/TS-5984-main

fix(query)[TS-5984]. correct data block filtering logic in tsdbReader
This commit is contained in:
Shengliang Guan 2025-02-10 09:08:34 +08:00 committed by GitHub
commit 6d46046ade
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 44 additions and 0 deletions

View File

@ -978,6 +978,10 @@ static int32_t loadFileBlockBrinInfo(STsdbReader* pReader, SArray* pIndexList, S
if (pRecord->firstKey.key.ts > w.ekey || pRecord->lastKey.key.ts < w.skey) {
continue;
}
// The data block's time range must intersect with the query time range
if (pRecord->firstKey.key.ts > pReader->info.window.ekey || pRecord->lastKey.key.ts < pReader->info.window.skey) {
continue;
}
if (asc) {
if (pkCompEx(&pRecord->lastKey.key, &pScanInfo->lastProcKey) <= 0) {

View File

@ -170,6 +170,45 @@ class TDTestCase(TBase):
tdSql.checkData(0, 1, 2)
tdSql.checkData(2, 1, 1)
def FIX_TS_5984(self):
tdLog.info("check bug TS_5984 ...\n")
# prepare data
sqls = [
"drop database if exists ts_5984;",
"create database ts_5984 minrows 10;",
"use ts_5984;",
"create table t1 (ts timestamp, str varchar(10) primary key, c1 int);",
"""insert into t1 values
('2025-01-01 00:00:00', 'a', 1),
('2025-01-01 00:00:00', 'b', 2),
('2025-01-01 00:00:00', 'c', 3),
('2025-01-01 00:00:00', 'd', 4),
('2025-01-01 00:00:00', 'e', 5),
('2025-01-01 00:00:00', 'f', 6),
('2025-01-01 00:00:00', 'g', 7),
('2025-01-01 00:00:00', 'h', 8),
('2025-01-01 00:00:00', 'i', 9),
('2025-01-01 00:00:00', 'j', 10),
('2025-01-01 00:00:00', 'k', 11),
('2025-01-01 00:00:00', 'l', 12),
('2025-01-01 00:00:00', 'm', 13),
('2025-01-01 00:00:00', 'n', 14);"""
]
tdSql.executes(sqls)
# do flush and compact
tdSql.execute("flush database ts_5984;")
time.sleep(3)
tdSql.execute("compact database ts_5984;")
while True:
tdSql.query("show compacts;")
# break if no compact task
if tdSql.getRows() == 0:
break
time.sleep(3)
tdSql.query("select * from t1 where ts > '2025-01-01 00:00:00';")
tdSql.checkRows(0)
# run
def run(self):
tdLog.debug(f"start to excute {__file__}")
@ -182,6 +221,7 @@ class TDTestCase(TBase):
self.FIX_TS_5105()
self.FIX_TS_5143()
self.FIX_TS_5239()
self.FIX_TS_5984()
tdLog.success(f"{__file__} successfully executed")