From 6afb717be545073c739adcfd917138b664e81b89 Mon Sep 17 00:00:00 2001 From: rjl493456442 Date: Tue, 22 Mar 2022 17:19:04 +0800 Subject: [PATCH] core/rawdb: fix db commands (#24540) --- core/rawdb/freezer_table.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/core/rawdb/freezer_table.go b/core/rawdb/freezer_table.go index 4456937286..01867ee8c2 100644 --- a/core/rawdb/freezer_table.go +++ b/core/rawdb/freezer_table.go @@ -153,8 +153,15 @@ func newTable(path string, name string, readMeter metrics.Meter, writeMeter metr if err != nil { return nil, err } - // Will fail if the table is legacy(no metadata) - meta, err = openFreezerFileForReadOnly(filepath.Join(path, fmt.Sprintf("%s.meta", name))) + // 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))) if err != nil { return nil, err }