From 8d50032dd6a18b598c18da15d8d2e53a704ef8e9 Mon Sep 17 00:00:00 2001 From: crossoverJie 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 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/logstorage/storage.go b/lib/logstorage/storage.go index 0216be282..10bf7f42f 100644 --- a/lib/logstorage/storage.go +++ b/lib/logstorage/storage.go @@ -329,6 +329,9 @@ func (s *Storage) watchRetention() { logger.Infof("the partition %s is scheduled to be deleted because it is outside the -retentionPeriod=%dd", ptw.pt.path, durationToDays(s.retention)) atomic.StoreUint32(&ptw.mustBeDeleted, 1) ptw.decRef() + if s.ptwHot != nil && s.ptwHot.pt == ptw.pt { + s.ptwHot = nil + } } select { @@ -363,6 +366,7 @@ func (s *Storage) MustClose() { } } s.partitions = nil + s.ptwHot = nil // Save caches streamIDCachePath := filepath.Join(s.path, cacheDirname, streamIDCacheFilename) @@ -395,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()