Check if metabase file exists before read shard ID #1178

Merged
fyrchik merged 1 commit from dstepanov-yadro/frostfs-node:fix/update_shard_id into master 2024-06-17 07:44:57 +00:00

On the first run (when metabase doesn't exist) shard ID update fails with error:

2024-06-17T09:47:09.646+0300	warn	engine/shards.go:142	failed to update shard id	{"shard_id": "6HqevV9p5Pnzjt3x9VjJf8", "metabase_path": "/home/dstepanov/src/frostfs-node/.cache/storage/s1/meta0", "error": "failed to read shard id from metabase: failed to open metabase: can't open boltDB database: write /home/dstepanov/src/frostfs-node/.cache/storage/s1/meta0: bad file descriptor"}
2024-06-17T09:47:09.647+0300	info	frostfs-node/config.go:1058	shard attached to engine	{"id": "6HqevV9p5Pnzjt3x9VjJf8"}
2024-06-17T09:47:13.089+0300	warn	engine/shards.go:142	failed to update shard id	{"shard_id": "DfqPyvi9czLrauU6qk9zxC", "metabase_path": "/home/dstepanov/src/frostfs-node/.cache/storage/s1/meta1", "error": "failed to read shard id from metabase: failed to open metabase: can't open boltDB database: write /home/dstepanov/src/frostfs-node/.cache/storage/s1/meta1: bad file descriptor"}

This is because frostfs-node tries to create metabase in read-only mode.

On the first run (when metabase doesn't exist) shard ID update fails with error: ``` 2024-06-17T09:47:09.646+0300 warn engine/shards.go:142 failed to update shard id {"shard_id": "6HqevV9p5Pnzjt3x9VjJf8", "metabase_path": "/home/dstepanov/src/frostfs-node/.cache/storage/s1/meta0", "error": "failed to read shard id from metabase: failed to open metabase: can't open boltDB database: write /home/dstepanov/src/frostfs-node/.cache/storage/s1/meta0: bad file descriptor"} 2024-06-17T09:47:09.647+0300 info frostfs-node/config.go:1058 shard attached to engine {"id": "6HqevV9p5Pnzjt3x9VjJf8"} 2024-06-17T09:47:13.089+0300 warn engine/shards.go:142 failed to update shard id {"shard_id": "DfqPyvi9czLrauU6qk9zxC", "metabase_path": "/home/dstepanov/src/frostfs-node/.cache/storage/s1/meta1", "error": "failed to read shard id from metabase: failed to open metabase: can't open boltDB database: write /home/dstepanov/src/frostfs-node/.cache/storage/s1/meta1: bad file descriptor"} ``` This is because frostfs-node tries to create metabase in read-only mode.
dstepanov-yadro force-pushed fix/update_shard_id from b83eb0e01f to 76cf7a051b 2024-06-17 06:59:40 +00:00 Compare
acid-ant approved these changes 2024-06-17 07:17:51 +00:00
fyrchik reviewed 2024-06-17 07:24:46 +00:00
@ -25,6 +26,10 @@ func (db *DB) GetShardID(mode metamode.Mode) ([]byte, error) {
defer db.modeMtx.Unlock()
db.mode = mode
if _, err := os.Stat(db.info.Path); errors.Is(err, os.ErrNotExist) {
Owner

The error happens on shard ID update, but we change ReadShardID, which should function in RO mode. Why so?

The error happens on shard ID update, but we change `ReadShardID`, which should function in RO mode. Why so?
Author
Member

See next line: db.openDB(mode) creates DB file if DB doesn't exist.

See next line: `db.openDB(mode)` creates DB file if DB doesn't exist.
fyrchik approved these changes 2024-06-17 07:44:42 +00:00
fyrchik merged commit 76cf7a051b into master 2024-06-17 07:44:57 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: TrueCloudLab/frostfs-node#1178
No description provided.