From 2e52a1056fa9d6ec3583aa7196794f197d0d011e Mon Sep 17 00:00:00 2001 From: Gary Rong Date: Wed, 19 Oct 2022 11:15:39 +0800 Subject: [PATCH] core/rawdb: open meta file in read only mode --- core/rawdb/freezer_table.go | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/core/rawdb/freezer_table.go b/core/rawdb/freezer_table.go index 3fe691cf6d2a..746f825e4038 100644 --- a/core/rawdb/freezer_table.go +++ b/core/rawdb/freezer_table.go @@ -148,20 +148,12 @@ func newTable(path string, name string, readMeter metrics.Meter, writeMeter metr meta *os.File ) if readonly { - // Will fail if table doesn't exist + // Will fail if table index file or meta file is not existent index, err = openFreezerFileForReadOnly(filepath.Join(path, idxName)) if err != nil { return nil, err } - // TODO(rjl493456442) change it to read-only mode. Open the metadata file - // in rw mode. It's a temporary solution for now and should be changed - // whenever the tail deletion is actually used. The reason for this hack is - // the additional meta file for each freezer table is added in order to support - // tail deletion, but for most legacy nodes this file is missing. This check - // will suddenly break lots of database relevant commands. So the metadata file - // is always opened for mutation and nothing else will be written except - // the initialization. - meta, err = openFreezerFileForAppend(filepath.Join(path, fmt.Sprintf("%s.meta", name))) + meta, err = openFreezerFileForReadOnly(filepath.Join(path, fmt.Sprintf("%s.meta", name))) if err != nil { return nil, err }