From 126854af5e6d8295ef8e8bee3040dd8380ae72e8 Mon Sep 17 00:00:00 2001 From: Qian Bin Date: Thu, 21 Jul 2022 11:02:15 +0800 Subject: [PATCH] leveldb: fix table file leaks when manifest is rotated (#409) --- leveldb/session.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/leveldb/session.go b/leveldb/session.go index d2d04802..036570e0 100644 --- a/leveldb/session.go +++ b/leveldb/session.go @@ -223,9 +223,12 @@ func (s *session) commit(r *sessionRecord, trivial bool) (err error) { } }() - if s.manifest == nil || s.manifest.Size() >= s.o.GetMaxManifestFileSize() { + if s.manifest == nil { // manifest journal writer not yet created, create one err = s.newManifest(r, nv) + } else if s.manifest.Size() >= s.o.GetMaxManifestFileSize() { + // pass nil sessionRecord to avoid over-reference table file + err = s.newManifest(nil, nv) } else { err = s.flushManifest(r) }