From 64b27c9217f83c6b790526408c91e8839d371b6c Mon Sep 17 00:00:00 2001
From: crossoverJie <crossoverJie@gmail.com>
Date: Tue, 29 Aug 2023 17:01:19 +0800
Subject: [PATCH] lib/logstorage: Set ptwHot to nil when the partition pointed
 by ptwHot is dropped (#4902)

---
 lib/logstorage/storage.go | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/logstorage/storage.go b/lib/logstorage/storage.go
index a15fd76e76..9d840fb5bc 100644
--- a/lib/logstorage/storage.go
+++ b/lib/logstorage/storage.go
@@ -366,6 +366,7 @@ func (s *Storage) MustClose() {
 		}
 	}
 	s.partitions = nil
+	s.ptwHot = nil
 
 	// Save caches
 	streamIDCachePath := filepath.Join(s.path, cacheDirname, streamIDCacheFilename)
@@ -398,7 +399,7 @@ func (s *Storage) MustAddRows(lr *LogRows) {
 	}
 	s.partitionsLock.Unlock()
 
-	if ptwHot != nil && ptwHot.pt != nil {
+	if ptwHot != nil {
 		if ptwHot.canAddAllRows(lr) {
 			ptwHot.pt.mustAddRows(lr)
 			ptwHot.decRef()