Check if metabase file exists before read shard ID #1178
1 changed files with 5 additions and 0 deletions
|
@ -4,6 +4,7 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/metaerr"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/metaerr"
|
||||||
metamode "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard/mode"
|
metamode "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard/mode"
|
||||||
|
@ -25,6 +26,10 @@ func (db *DB) GetShardID(mode metamode.Mode) ([]byte, error) {
|
||||||
defer db.modeMtx.Unlock()
|
defer db.modeMtx.Unlock()
|
||||||
db.mode = mode
|
db.mode = mode
|
||||||
|
|
||||||
|
if _, err := os.Stat(db.info.Path); errors.Is(err, os.ErrNotExist) {
|
||||||
|
|||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
if err := db.openDB(mode); err != nil {
|
if err := db.openDB(mode); err != nil {
|
||||||
return nil, fmt.Errorf("failed to open metabase: %w", err)
|
return nil, fmt.Errorf("failed to open metabase: %w", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue
The error happens on shard ID update, but we change
ReadShardID
, which should function in RO mode. Why so?See next line:
db.openDB(mode)
creates DB file if DB doesn't exist.