metabase: Skip expired objects in ListWithCursor #1583

Merged
fyrchik merged 2 commits from a-savchuk/frostfs-node:do-not-list-expired-objects into master 2024-12-27 05:42:07 +00:00
Member

Before this change, the result of ListWithCursor included expired objects. This caused unnecessary attempts by the replicator to replicate these objects, leading to errors like this one below:

aug 06 11:56:12 node frostfs-node[4795]: 2024-08-06T11:56:12.630Z error replicator/process.go:78 could not replicate object {"component": "Object Replicator", "node": "03c5d517303e09d058371c03098becf5fc4089e301aa64d1e6f41602b11dd7b50f", "object": "H6esfqFaG3AcmdQnZ7UBKVQ38zpyUEt5nq4gAhHKDMFR/GQ3yizn5sCaTGrTGNzWgjQ6GADPRjCdANVRKyBiphHX2", "trace_id": "", "error": "(*putsvc.RemoteSender) could not send object: (*putsvc.remoteTarget) could not put single object to [/ip4/10.252.11.12/tcp/8080]: put single object via client: status: code = 1024 message = object has expired"}
Before this change, the result of `ListWithCursor` included expired objects. This caused unnecessary attempts by the replicator to replicate these objects, leading to errors like this one below: ``` aug 06 11:56:12 node frostfs-node[4795]: 2024-08-06T11:56:12.630Z error replicator/process.go:78 could not replicate object {"component": "Object Replicator", "node": "03c5d517303e09d058371c03098becf5fc4089e301aa64d1e6f41602b11dd7b50f", "object": "H6esfqFaG3AcmdQnZ7UBKVQ38zpyUEt5nq4gAhHKDMFR/GQ3yizn5sCaTGrTGNzWgjQ6GADPRjCdANVRKyBiphHX2", "trace_id": "", "error": "(*putsvc.RemoteSender) could not send object: (*putsvc.remoteTarget) could not put single object to [/ip4/10.252.11.12/tcp/8080]: put single object via client: status: code = 1024 message = object has expired"} ```
a-savchuk added 3 commits 2024-12-25 19:30:25 +00:00
The function is riskly long. so adding just a few lines of code
might trigger the `funlen` linter. Kept the changes minimal:
- Moved the logic for filling object info into a separate function
- Preserved all existing side effects

Signed-off-by: Aleksey Savchuk <a.savchuk@yadro.com>
Signed-off-by: Aleksey Savchuk <a.savchuk@yadro.com>
[#xx] metabase/test: Update TestLisObjectsWithCursor
Some checks failed
DCO action / DCO (pull_request) Failing after 4m27s
Vulncheck / Vulncheck (pull_request) Successful in 4m48s
Tests and linters / Run gofumpt (pull_request) Successful in 5m1s
Pre-commit hooks / Pre-commit (pull_request) Successful in 5m44s
Build / Build Components (pull_request) Successful in 6m11s
Tests and linters / Staticcheck (pull_request) Successful in 6m10s
Tests and linters / gopls check (pull_request) Successful in 6m23s
Tests and linters / Tests (pull_request) Successful in 6m33s
Tests and linters / Tests with -race (pull_request) Successful in 6m39s
Tests and linters / Lint (pull_request) Successful in 7m3s
c926fe4065
Update this test following recent changes to ensure
that `(*DB).ListWithCursor` skips expired objects.

Signed-off-by: Aleksey Savchuk <a.savchuk@yadro.com>
a-savchuk force-pushed do-not-list-expired-objects from c926fe4065 to 967072e52d 2024-12-25 19:32:53 +00:00 Compare
a-savchuk force-pushed do-not-list-expired-objects from 967072e52d to 2473257925 2024-12-25 19:38:32 +00:00 Compare
a-savchuk changed title from WIP: metabase: Skip expired objects in ListWithCursor to metabase: Skip expired objects in ListWithCursor 2024-12-25 19:50:36 +00:00
a-savchuk requested review from storage-core-committers 2024-12-25 19:50:37 +00:00
a-savchuk requested review from storage-core-developers 2024-12-25 19:50:37 +00:00
a-savchuk force-pushed do-not-list-expired-objects from 2473257925 to b49ce50daa 2024-12-25 19:59:55 +00:00 Compare
a-savchuk force-pushed do-not-list-expired-objects from b49ce50daa to dffae78eb2 2024-12-25 21:07:17 +00:00 Compare
fyrchik requested changes 2024-12-26 06:43:28 +00:00
Dismissed
fyrchik left a comment
Owner

Please, look at the already existing fix which was not in master for some reason 284b270c1f
It seems shorter and handles expired but locked objects (which thus should be available).
There should be tests for expired but locked objects too.

Please, look at the already existing fix which was not in master for some reason https://git.frostfs.info/fyrchik/frostfs-node/commit/284b270c1f1c5e17c6bd9a63f540d1dc14a633e9 It seems shorter and handles expired but locked objects (which thus should be available). There should be tests for expired but locked objects too.
@ -125,3 +128,3 @@
}
func (db *DB) listWithCursor(tx *bbolt.Tx, result []objectcore.Info, count int, cursor *Cursor) ([]objectcore.Info, *Cursor, error) {
func (db *DB) listWithCursor(ctx context.Context, tx *bbolt.Tx, result []objectcore.Info, count int, cursor *Cursor) ([]objectcore.Info, *Cursor, error) {
Owner

Please, let's not have any ctx in unexported function of the metabase package.
It is unnecessary an complicates code.

Please, let's not have any `ctx` in unexported function of the metabase package. It is unnecessary an complicates code.
Author
Member

Fixed

Fixed
@ -225,6 +234,9 @@ func selectNFromBucket(bkt *bbolt.Bucket, // main bucket
if !threshold {
c.Seek(offset)
// TODO(@a-savchuk): What'd be if the object with this offset was
Owner

What do we need to do in this TODO?

What do we need to do in this TODO?
Author
Member

If we can't decode one object ID, we skip the rest of the bucket. We can't log this error. I'm not sure, maybe use continue?

If we can't decode one object ID, we skip the rest of the bucket. We can't log this error. I'm not sure, maybe use `continue`?
Owner

It is unrelated to the PR, please create an issue instead.

It is unrelated to the PR, please create an issue instead.
fyrchik marked this conversation as resolved
a-savchuk force-pushed do-not-list-expired-objects from dffae78eb2 to 3260fd60b3 2024-12-26 08:13:29 +00:00 Compare
a-savchuk force-pushed do-not-list-expired-objects from 3260fd60b3 to fa08bfa553 2024-12-26 11:39:56 +00:00 Compare
fyrchik approved these changes 2024-12-26 11:55:38 +00:00
aarifullin approved these changes 2024-12-26 13:26:42 +00:00
fyrchik merged commit fa08bfa553 into master 2024-12-27 05:42:07 +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#1583
No description provided.