-
Notifications
You must be signed in to change notification settings - Fork 659
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
Too many open files #1210
Comments
As a workaround I fixed it locally by setting my file |
@stefdoerr are you using one Minio client instance or initiating multiple instances ? |
Just one, inside a singularity container built from the |
This works fine for me:
Can you paste the code that reproduces your issue so we can inspect it ? |
I think this your application issue, you are not closing http connections used with presigned URL |
You are probably right, but I cannot figure it out. I made a small example that can reproduce it. I have a net/http server which sends the requests for bucket creation. I would appreciate if you could tell me what is wrong. package main
import (
"flag"
"fmt"
"os"
"strings"
stdlog "log"
log "github.com/inconshreveable/log15"
"net/http"
"time"
"io/ioutil"
"encoding/json"
"github.com/gorilla/mux"
_ "github.com/lib/pq"
minio "github.com/minio/minio-go"
)
func CreateUrlBucket(bucketName, direction string) string {
endpoint := "127.0.0.1:9000"
accessKeyID := "xxx"
secretAccessKey := "xxx"
useSSL := false
// Initialize minio client object.
minioClient, err := minio.New(endpoint, accessKeyID, secretAccessKey, useSSL)
if err != nil {
stdlog.Fatalln(err)
}
expiry := time.Second * 24 * 60 * 60 * 7 // 1000 day.
presignedURL, err := minioClient.PresignedPutObject(bucketName, direction, expiry)
if err != nil {
logger.Error("Failed at creating presigned URL for bucket", "err", err)
} else {
logger.Info("Successfully created presigned URL for bucket", "bucketName", bucketName)
}
return presignedURL.String()
}
type Execution struct {
InputID string `gorm:"type:text" json:"inputid"`
}
func DoStuff(w http.ResponseWriter, r *http.Request) {
defer r.Body.Close()
var e Execution
b, _ := ioutil.ReadAll(r.Body)
json.Unmarshal(b, &e)
input := "input" + e.InputID
_ = CreateUrlBucket(input, "input")
}
type Runner struct {
Router *mux.Router
}
func (r *Runner) Initialize() {
r.Router = mux.NewRouter()
r.initializeRoutes()
}
func (r *Runner) initializeRoutes() {
r.Router.HandleFunc("/test", DoStuff).Methods("POST")
}
func (r *Runner) Run(addr string, update bool) {
stdlog.Fatal(http.ListenAndServe(addr, r.Router))
}
var (
logger = log.New("module", "test/main")
flagUpdate = flag.Bool("update", false, "Update")
flagLogLevel = flag.String("l", "info", "Log level")
)
func init() {
flag.Parse()
handler := log.StreamHandler(os.Stderr, log.TerminalFormat())
level, err := log.LvlFromString(strings.ToLower(*flagLogLevel))
if err != nil {
stdlog.Fatal(err)
}
filteredHandler := log.LvlFilterHandler(level, handler)
log.Root().SetHandler(filteredHandler)
}
func main() {
r := Runner{}
r.Initialize()
addr := fmt.Sprintf(":%s", "9997")
r.Run(addr, *flagUpdate)
} And then I can break it after a few hundred requests by using python requests: import requests
import uuid
headers = {"Content-type": "application/json", "Accept": "text/plain" }
for i in range(50000):
r = requests.post("http://127.0.0.1:9997/test", headers, json={"inputid": uuid.uuid4(), "outputid": uuid.uuid4(), "intermediateid": uuid.uuid4()})
print(r) with log:
|
First bug is creating minio.New() for each new requests @stefdoerr |
Yup, that solved it. Thanks a bunch! I inherited that code from someone else so I was not that sure on the details of how to use the Minio client correctly. |
I think the documentation just needs a line saying that you should have one client shared across context. I landed here after having the same issue with too many open files using the golang client. Similar issue #598 All of the examples kind of look like it should be one client per operation (though i will admit of course that they need to be like that for brevity... but then you get dumb people like me misusing it..) Thanks |
I'm facing a similar issue with the
minio-go
client as here: minio/minio#5093If I spam
PresignedPutObject
requests I get:Get http://127.0.0.1:9000/inputdd2ca3fa-de29-4915-9db7-7de1a5287d25/?location=: dial tcp 127.0.0.1:9000: socket: too many open files
Is seems to have been fixed in the js client, is it possible that the fix has not been ported to the go client?
The text was updated successfully, but these errors were encountered: