Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

services/uss: Disable async delete for unexpected behavior #345

Merged
merged 2 commits into from
May 19, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 17 additions & 19 deletions services/uss/storager.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,21 @@ func (s *Storage) ListDir(path string, pairs ...*types.Pair) (err error) {
return err
}

maxListLevel := 1

rp := s.getAbsPath(path)

// USS SDK will close this channel in List
ch := make(chan *upyun.FileInfo, 200)

go func() {
errlock.Lock()
defer errlock.Unlock()

err = s.bucket.List(&upyun.GetObjectsConfig{
xerr := s.bucket.List(&upyun.GetObjectsConfig{
Path: rp,
ObjectsChan: ch,
MaxListLevel: maxListLevel,
MaxListLevel: 1,
})

errlock.Lock()
defer errlock.Unlock()
err = xerr
}()

for v := range ch {
Expand Down Expand Up @@ -117,22 +116,21 @@ func (s *Storage) ListPrefix(prefix string, pairs ...*types.Pair) (err error) {
return err
}

maxListLevel := -1

rp := s.getAbsPath(prefix)

// USS SDK will close this channel in List
ch := make(chan *upyun.FileInfo, 200)

go func() {
errlock.Lock()
defer errlock.Unlock()

err = s.bucket.List(&upyun.GetObjectsConfig{
xerr := s.bucket.List(&upyun.GetObjectsConfig{
Path: rp,
ObjectsChan: ch,
MaxListLevel: maxListLevel,
MaxListLevel: -1,
})

errlock.Lock()
defer errlock.Unlock()
err = xerr
}()

for v := range ch {
Expand Down Expand Up @@ -245,6 +243,11 @@ func (s *Storage) Stat(path string, pairs ...*types.Pair) (o *types.Object, err
}

// Delete implements Storager.Delete
//
// USS requires a short time between PUT and DELETE, or we will get this error:
// DELETE 429 {"msg":"concurrent put or delete","code":42900007,"id":"xxx"}
//
// Due to this problem, uss can't pass the storager integration tests.
func (s *Storage) Delete(path string, pairs ...*types.Pair) (err error) {
defer func() {
err = s.formatError(services.OpDelete, err, path)
Expand All @@ -254,11 +257,6 @@ func (s *Storage) Delete(path string, pairs ...*types.Pair) (err error) {

err = s.bucket.Delete(&upyun.DeleteObjectConfig{
Path: rp,
// USS requires a short time between PUT and DELETE, or we will get this error:
// DELETE 429 {"msg":"concurrent put or delete","code":42900007,"id":"xxx"}
//
// In order to pass the integration tests, use async delete instead
Async: true,
})
if err != nil {
return err
Expand Down