Skip to content

Commit

Permalink
Merge pull request #870 from versity/ben/upload_race
Browse files Browse the repository at this point in the history
fix: unexpected errors during upload races
  • Loading branch information
benmcclelland authored Oct 8, 2024
2 parents d2b0d24 + b7a2e8a commit de4c3c8
Show file tree
Hide file tree
Showing 15 changed files with 608 additions and 285 deletions.
3 changes: 3 additions & 0 deletions auth/object_lock.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,9 @@ func CheckObjectAccess(ctx context.Context, bucket, userAccess string, objects [

status, err := be.GetObjectLegalHold(ctx, bucket, key, versionId)
if err != nil {
if errors.Is(err, s3err.GetAPIError(s3err.ErrNoSuchKey)) {
continue
}
if errors.Is(err, s3err.GetAPIError(s3err.ErrNoSuchObjectLockConfiguration)) {
checkLegalHold = false
} else {
Expand Down
6 changes: 4 additions & 2 deletions backend/meta/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,19 @@

package meta

import "os"

// MetadataStorer defines the interface for managing metadata.
// When object == "", the operation is on the bucket.
type MetadataStorer interface {
// RetrieveAttribute retrieves the value of a specific attribute for an object or a bucket.
// Returns the value of the attribute, or an error if the attribute does not exist.
RetrieveAttribute(bucket, object, attribute string) ([]byte, error)
RetrieveAttribute(f *os.File, bucket, object, attribute string) ([]byte, error)

// StoreAttribute stores the value of a specific attribute for an object or a bucket.
// If attribute already exists, new attribute should replace existing.
// Returns an error if the operation fails.
StoreAttribute(bucket, object, attribute string, value []byte) error
StoreAttribute(f *os.File, bucket, object, attribute string, value []byte) error

// DeleteAttribute removes the value of a specific attribute for an object or a bucket.
// Returns an error if the operation fails.
Expand Down
17 changes: 15 additions & 2 deletions backend/meta/xattr.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package meta
import (
"errors"
"fmt"
"os"
"path/filepath"
"strings"
"syscall"
Expand All @@ -36,7 +37,15 @@ var (
type XattrMeta struct{}

// RetrieveAttribute retrieves the value of a specific attribute for an object in a bucket.
func (x XattrMeta) RetrieveAttribute(bucket, object, attribute string) ([]byte, error) {
func (x XattrMeta) RetrieveAttribute(f *os.File, bucket, object, attribute string) ([]byte, error) {
if f != nil {
b, err := xattr.FGet(f, xattrPrefix+attribute)
if errors.Is(err, xattr.ENOATTR) {
return nil, ErrNoSuchKey
}
return b, err
}

b, err := xattr.Get(filepath.Join(bucket, object), xattrPrefix+attribute)
if errors.Is(err, xattr.ENOATTR) {
return nil, ErrNoSuchKey
Expand All @@ -45,7 +54,11 @@ func (x XattrMeta) RetrieveAttribute(bucket, object, attribute string) ([]byte,
}

// StoreAttribute stores the value of a specific attribute for an object in a bucket.
func (x XattrMeta) StoreAttribute(bucket, object, attribute string, value []byte) error {
func (x XattrMeta) StoreAttribute(f *os.File, bucket, object, attribute string, value []byte) error {
if f != nil {
return xattr.FSet(f, xattrPrefix+attribute, value)
}

return xattr.Set(filepath.Join(bucket, object), xattrPrefix+attribute, value)
}

Expand Down
Loading

0 comments on commit de4c3c8

Please sign in to comment.