From dca720fc7d2cbf8005da92e7c985d21d46fcff11 Mon Sep 17 00:00:00 2001 From: Minglei Jin Date: Wed, 1 Feb 2023 15:09:21 +0800 Subject: [PATCH] fix(query): protect read snap with reader mutex when closing reader --- source/dnode/vnode/src/tsdb/tsdbRead.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/dnode/vnode/src/tsdb/tsdbRead.c b/source/dnode/vnode/src/tsdb/tsdbRead.c index a2212292a7..f9c2f0b3fa 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead.c @@ -4019,6 +4019,7 @@ void tsdbReaderClose(STsdbReader* pReader) { return; } + tsdbAcquireReader(pReader); { if (pReader->innerReader[0] != NULL || pReader->innerReader[1] != NULL) { STsdbReader* p = pReader->innerReader[0]; @@ -4076,10 +4077,12 @@ void tsdbReaderClose(STsdbReader* pReader) { pReader->pDelIdx = NULL; } - qTrace("tsdb/reader: %p, untake snapshot", pReader); + qTrace("tsdb/reader-close: %p, untake snapshot", pReader); tsdbUntakeReadSnap(pReader, pReader->pReadSnap, true); pReader->pReadSnap = NULL; + tsdbReleaseReader(pReader); + tsdbUninitReaderLock(pReader); taosMemoryFree(pReader->status.uidCheckInfo.tableUidList); -- GitLab