Skip to content

Commit

Permalink
node/meta: do not stop deleting objects on errors, log them instead
Browse files Browse the repository at this point in the history
Relates #2822.

Signed-off-by: Pavel Karpy <[email protected]>
  • Loading branch information
carpawell committed Jun 26, 2024
1 parent 5b6b5a4 commit bd94a60
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion pkg/local_object_storage/metabase/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
"go.etcd.io/bbolt"
"go.uber.org/zap"
)

// DeletePrm groups the parameters of Delete operation.
Expand Down Expand Up @@ -99,11 +100,21 @@ func (db *DB) deleteGroup(tx *bbolt.Tx, addrs []oid.Address, sizes []uint64) (ui

var rawDeleted uint64
var availableDeleted uint64
var errorCount uint64
var firstErr error

for i := range addrs {
removed, available, size, err := db.delete(tx, addrs[i], currEpoch)
if err != nil {
return 0, 0, err // maybe log and continue?
errorCount++
err = fmt.Errorf("%s object delete fail: %w", addrs[i], err)
if firstErr == nil {
firstErr = err

Check warning on line 112 in pkg/local_object_storage/metabase/delete.go

View check run for this annotation

Codecov / codecov/patch

pkg/local_object_storage/metabase/delete.go#L109-L112

Added lines #L109 - L112 were not covered by tests
}

db.log.Warn("failed to delete object", zap.Error(err))

Check warning on line 115 in pkg/local_object_storage/metabase/delete.go

View check run for this annotation

Codecov / codecov/patch

pkg/local_object_storage/metabase/delete.go#L115

Added line #L115 was not covered by tests

continue

Check warning on line 117 in pkg/local_object_storage/metabase/delete.go

View check run for this annotation

Codecov / codecov/patch

pkg/local_object_storage/metabase/delete.go#L117

Added line #L117 was not covered by tests
}

if removed {
Expand All @@ -116,6 +127,12 @@ func (db *DB) deleteGroup(tx *bbolt.Tx, addrs []oid.Address, sizes []uint64) (ui
}
}

if firstErr != nil {
all := uint64(len(addrs))
success := all - errorCount
return 0, 0, fmt.Errorf("deleted %d out of %d objects, first error: %w", success, all, firstErr)

Check warning on line 133 in pkg/local_object_storage/metabase/delete.go

View check run for this annotation

Codecov / codecov/patch

pkg/local_object_storage/metabase/delete.go#L131-L133

Added lines #L131 - L133 were not covered by tests
}

if rawDeleted > 0 {
err := db.updateCounter(tx, phy, rawDeleted, false)
if err != nil {
Expand Down

0 comments on commit bd94a60

Please sign in to comment.