File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -419,7 +419,7 @@ impl AbstractTree for Tree {
419419 // Rotate does not modify the memtable, so it cannot break snapshots
420420 copy. seqno = super_version. seqno ;
421421
422- version_history_lock. append_version ( copy) ;
422+ version_history_lock. replace_latest_version ( copy) ;
423423
424424 log:: trace!( "cleared active memtable" ) ;
425425 }
@@ -485,7 +485,7 @@ impl AbstractTree for Tree {
485485 // Rotate does not modify the memtable so it cannot break snapshots
486486 copy. seqno = super_version. seqno ;
487487
488- version_history_lock. append_version ( copy) ;
488+ version_history_lock. replace_latest_version ( copy) ;
489489
490490 log:: trace!(
491491 "rotate: added memtable id={} to sealed memtables" ,
Original file line number Diff line number Diff line change @@ -66,11 +66,15 @@ impl SuperVersions {
6666 self . len ( ) . saturating_sub ( 1 )
6767 }
6868
69- pub ( crate ) fn maintenance ( & mut self , folder : & Path , gc_watermark : SeqNo ) -> crate :: Result < ( ) > {
69+ pub fn maintenance ( & mut self , folder : & Path , gc_watermark : SeqNo ) -> crate :: Result < ( ) > {
7070 if gc_watermark == 0 {
7171 return Ok ( ( ) ) ;
7272 }
7373
74+ if self . free_list_len ( ) < 1 {
75+ return Ok ( ( ) ) ;
76+ }
77+
7478 log:: trace!( "Running manifest GC with watermark={gc_watermark}" ) ;
7579
7680 if let Some ( hi_idx) = self . 0 . iter ( ) . rposition ( |x| x. seqno < gc_watermark) {
@@ -140,6 +144,12 @@ impl SuperVersions {
140144 self . 0 . push_back ( version) ;
141145 }
142146
147+ pub fn replace_latest_version ( & mut self , version : SuperVersion ) {
148+ if self . 0 . pop_back ( ) . is_some ( ) {
149+ self . 0 . push_back ( version) ;
150+ }
151+ }
152+
143153 pub fn latest_version ( & self ) -> SuperVersion {
144154 self . 0
145155 . iter ( )
You can’t perform that action at this time.
0 commit comments