minio / minio

The Object Store for AI Data Infrastructure

Home Page:https://min.io/download

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Internal error while force-deleting a bucket

ramondeklein opened this issue · comments

Situation

I had set up an HTTP based audit web-hook to a service that wasn't able to deal with the generated load. I already got some deadline exceeded errors during the auditing web-hooks, but that was to be expected. I aborted the warp tool and tried to delete the bucket using mc rb local/warp-benchmark-bucket/ --force. It failed, because of an internal error, and the Minio log showed the following:

panic: "DELETE /warp-benchmark-bucket/": runtime error: invalid memory address or nil pointer dereference
goroutine 427091 [running]:
runtime/debug.Stack()
        /usr/local/go/src/runtime/debug/stack.go:24 +0x5e
github.com/minio/minio/cmd.serverMain.func8.setCriticalErrorHandler.func2.1()
        /home/ramon/minio/minio/cmd/generic-handlers.go:568 +0x97
panic({0x288e320?, 0x645d360?})
        /usr/local/go/src/runtime/panic.go:914 +0x21f
github.com/minio/minio/cmd.objectAPIHandlers.DeleteBucketHandler({0xc0b7245800?}, {0x4d35180, 0xc09b2f2780}, 0xc0aa9dc300)
        /home/ramon/minio/minio/cmd/bucket-handlers.go:1664 +0x533
net/http.HandlerFunc.ServeHTTP(0x5435129?, {0x4d35180?, 0xc09b2f2780?}, 0x6aa02c?)
        /usr/local/go/src/net/http/server.go:2136 +0x29
github.com/minio/minio/cmd.s3APIMiddleware.func1.httpTraceAll.httpTrace.func4({0x4d35180, 0xc09b2f2780}, 0xc09b46e480?)
        /home/ramon/minio/minio/cmd/http-tracer.go:189 +0xef
net/http.HandlerFunc.ServeHTTP(0x646e940?, {0x4d35180?, 0xc09b2f2780?}, 0x4?)
        /usr/local/go/src/net/http/server.go:2136 +0x29
github.com/klauspost/compress/gzhttp.NewWrapper.func1.1({0x4d33b78, 0xc09b46e480}, 0xc0aa991da0?)
        /home/ramon/go/pkg/mod/github.com/klauspost/compress@v1.17.8/gzhttp/compress.go:497 +0x37d
net/http.HandlerFunc.ServeHTTP(0xc0aa8bb310?, {0x4d33b78?, 0xc09b46e480?}, 0x1?)
        /usr/local/go/src/net/http/server.go:2136 +0x29
github.com/minio/minio/cmd.s3APIMiddleware.func1.maxClients.func1({0x4d33b78, 0xc09b46e480}, 0xc0aa9dc300)
        /home/ramon/minio/minio/cmd/handler-api.go:343 +0x47e
net/http.HandlerFunc.ServeHTTP(0x64e6a70?, {0x4d33b78?, 0xc09b46e480?}, 0x5435156?)
        /usr/local/go/src/net/http/server.go:2136 +0x29
github.com/minio/minio/cmd.s3APIMiddleware.func1.collectAPIStats.func2({0x4d33b78, 0xc09b46e480}, 0xc0aa9dc300)
        /home/ramon/minio/minio/cmd/handler-utils.go:337 +0x4aa
github.com/minio/minio/cmd.s3APIMiddleware.func1({0x4d33b78, 0xc09b46e480}, 0x1b?)
        /home/ramon/minio/minio/cmd/api-router.go:246 +0x174
net/http.HandlerFunc.ServeHTTP(0xc0aa9c9140?, {0x4d33b78?, 0xc09b46e480?}, 0xc0aa8bd460?)
        /usr/local/go/src/net/http/server.go:2136 +0x29

It looks like this method doesn't return a replication configuration:

func getReplicationConfig(ctx context.Context, bucketName string) (rc *replication.Config, err error) {
rCfg, _, err := globalBucketMetadataSys.GetReplicationConfig(ctx, bucketName)
if err != nil && !errors.Is(err, BucketReplicationConfigNotFound{Bucket: bucketName}) {
return rCfg, err
}
return rCfg, nil
}

I guess that's okay, because I didn't have any replication enabled. It is called from this code:

minio/cmd/bucket-handlers.go

Lines 1657 to 1667 in 1d03bea

rcfg, err := getReplicationConfig(ctx, bucket)
switch {
case err != nil:
if _, ok := err.(BucketReplicationConfigNotFound); !ok {
writeErrorResponse(ctx, w, errorCodes.ToAPIErr(ErrMethodNotAllowed), r.URL)
return
}
case rcfg.HasActiveRules("", true):
writeErrorResponse(ctx, w, errorCodes.ToAPIErr(ErrMethodNotAllowed), r.URL)
return
}

There is no error returned and rcfg is set to nil. That's causing the second case statement to fail. It looks this only fails when force-deleting a bucket without replication enabled.