mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/logstorage: eliminate data race when clearing s.ptwHot after deleting the corresponding partition
The previous code could result in the following data race:
1. The s.ptwHot partition is marked to be deleted
2. ptw.decRef() is called on it
3. ptw.pt is set to nil
4. s.ptwHot.pt is accessed from concurrent goroutine, which leads to panic.
The change clears s.ptwHot under s.partitionsLock in order to prevent from the data race.
This is a follow-up for 8d50032dd6
Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4895
This commit is contained in:
parent
c4b10109d7
commit
1e1aa94ffb
1 changed files with 3 additions and 0 deletions
|
@ -317,6 +317,9 @@ func (s *Storage) watchRetention() {
|
|||
break
|
||||
}
|
||||
ptwsToDelete = append(ptwsToDelete, ptw)
|
||||
if ptw == s.ptwHot {
|
||||
s.ptwHot = nil
|
||||
}
|
||||
}
|
||||
for i := range ptwsToDelete {
|
||||
s.partitions[i] = nil
|
||||
|
|
Loading…
Reference in a new issue