Skip to content

Commit cc7ac72

Browse files
committed
fix: disable empty vlog deletion on ReadOnly mode
1 parent dc2b719 commit cc7ac72

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

value.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,6 @@ func (vlog *valueLog) open(db *DB) error {
575575
lf, ok := vlog.filesMap[fid]
576576
y.AssertTrue(ok)
577577

578-
// Just open in RDWR mode. This should not create a new log file.
579578
lf.opt = vlog.opt
580579
flags := os.O_RDWR
581580
if vlog.opt.ReadOnly {
@@ -586,7 +585,7 @@ func (vlog *valueLog) open(db *DB) error {
586585
return y.Wrapf(err, "Open existing file: %q", lf.path)
587586
}
588587
// We shouldn't delete the maxFid file.
589-
if lf.size.Load() == vlogHeaderSize && fid != vlog.maxFid {
588+
if lf.size.Load() == vlogHeaderSize && fid != vlog.maxFid && !vlog.opt.ReadOnly {
590589
vlog.opt.Infof("Deleting empty file: %s", lf.path)
591590
if err := lf.Delete(); err != nil {
592591
return y.Wrapf(err, "while trying to delete empty file: %s", lf.path)

0 commit comments

Comments
 (0)