Check if metabase file exists before read shard ID #1178

Merged
fyrchik merged 1 commits 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 added 1 commit 2024-06-17 06:58:58 +00:00
Build / Build Components (1.21) (pull_request) Successful in 3m6s Details
DCO action / DCO (pull_request) Successful in 3m13s Details
Build / Build Components (1.22) (pull_request) Successful in 4m9s Details
Vulncheck / Vulncheck (pull_request) Successful in 3m56s Details
Tests and linters / gopls check (pull_request) Successful in 9m18s Details
Tests and linters / Lint (pull_request) Successful in 12m10s Details
Tests and linters / Staticcheck (pull_request) Successful in 14m20s Details
Tests and linters / Tests (1.21) (pull_request) Failing after 14m37s Details
Tests and linters / Tests (1.22) (pull_request) Failing after 15m45s Details
Tests and linters / Tests with -race (pull_request) Failing after 19m11s Details
Pre-commit hooks / Pre-commit (pull_request) Successful in 22m48s Details
b83eb0e01f
[#9999] shard: Check metabase existence before read shard ID
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
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) {

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?
Poster
Collaborator

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
There is no content yet.