lib/{mergeset,storage}: remove isInMerge flag from parts only when they werent removed yet from the list of active parts

This prevents from possible panic during access to pw.p when it is set to nil at partWrapper.decRef() called inside swapSrcWithDstParts()
This commit is contained in:
Aliaksandr Valialkin 2023-04-14 00:06:25 -07:00
parent 2fd9fdacce
commit 67df75484f
No known key found for this signature in database
GPG key ID: A72BEC6CD3D0DED1
2 changed files with 2 additions and 2 deletions

View file

@ -1072,7 +1072,6 @@ func (tb *Table) mergeParts(pws []*partWrapper, stopCh <-chan struct{}, isFinal
// Nothing to merge.
return errNothingToMerge
}
defer tb.releasePartsToMerge(pws)
startTime := time.Now()
@ -1132,6 +1131,7 @@ func (tb *Table) mergeParts(pws []*partWrapper, stopCh <-chan struct{}, isFinal
putBlockStreamWriter(bsw)
closeBlockStreamReaders()
if err != nil {
tb.releasePartsToMerge(pws)
return err
}
if mpNew != nil {

View file

@ -1250,7 +1250,6 @@ func (pt *partition) mergeParts(pws []*partWrapper, stopCh <-chan struct{}, isFi
// Nothing to merge.
return errNothingToMerge
}
defer pt.releasePartsToMerge(pws)
startTime := time.Now()
@ -1311,6 +1310,7 @@ func (pt *partition) mergeParts(pws []*partWrapper, stopCh <-chan struct{}, isFi
putBlockStreamWriter(bsw)
closeBlockStreamReaders()
if err != nil {
pt.releasePartsToMerge(pws)
return err
}
if mpNew != nil {