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

net/http: panic: persistConn was already in LRU #18058

Closed
zeropool opened this issue Nov 27, 2016 · 5 comments

Comments

Projects
None yet
5 participants
@zeropool
Copy link

commented Nov 27, 2016

Please do not ignore the windows system !!!!

What version of Go are you using (go version)?

go1.7.3

What operating system and processor architecture are you using (go env)?

Windows Server Standard 2007 SP2 32bit

panic: persistConn was already in LRU

goroutine 609111 [running]:
panic(0xa50dc0, 0x125a45d8)
        /opt/dev/gopkg/go/src/runtime/panic.go:500 +0x331
net/http.(*connLRU).add(0x125de5b4, 0x1267c510)
        /opt/dev/gopkg/go/src/net/http/transport.go:2147 +0x177
net/http.(*Transport).tryPutIdleConn(0x125de5a0, 0x1267c510, 0x0, 0x0)
        /opt/dev/gopkg/go/src/net/http/transport.go:678 +0x5d8
net/http.(*persistConn).readLoop.func2(0x0, 0x125f2b01)
        /opt/dev/gopkg/go/src/net/http/transport.go:1391 +0x32
net/http.(*persistConn).readLoop(0x1267c510)
        /opt/dev/gopkg/go/src/net/http/transport.go:1548 +0xce1
created by net/http.(*Transport).dialConn
        /opt/dev/gopkg/go/src/net/http/transport.go:1062 +0xda5

this is part of my code:


func DoRequest(/* som arguments */) {
        // Very high frequency call code
	var res *http.Response
	err = nil
	if r.Timeout > 0 {
		err = errors.New("timeout")
		c := make(chan *httpPeek)
		go func() {
			newRes, newErr := httpClient.Do(req)
			select {
			case c <- &httpPeek{newRes, newErr}:
			default:
				if newErr == nil && newRes != nil && newRes.Body != nil {
					// Discard and close so we can reuse it
					io.Copy(ioutil.Discard, newRes.Body)
					newRes.Body.Close()
				}
			}
			close(c)
		}()
		select {
		case <-time.After(r.Timeout):
		case v := <-c:
			if v != nil {
				res = v.res
				err = v.err
			}
		}
	} else {
		res, err = httpClient.Do(req)
	}
	if err != nil {
		return nil, err
	}
      // other code..
}
func init() {
	timeout := time.Minute
	httpClient = &http.Client{
		Transport: &http.Transport{
			MaxIdleConnsPerHost:   5,
			TLSClientConfig:       &tls.Config{InsecureSkipVerify: true},
			ResponseHeaderTimeout: timeout,
		},
		Timeout: timeout,
	}
}

It's very hard to reproduce, program running about 20 hours, then panic and exit !!

@rsc

This comment has been minimized.

Copy link
Contributor

commented Jan 4, 2017

/cc @bradfitz

@rsc rsc added this to the Go1.8Maybe milestone Jan 4, 2017

@rsc rsc changed the title panic: persistConn was already in LRU net/http: panic: persistConn was already in LRU Jan 4, 2017

@bradfitz

This comment has been minimized.

Copy link
Member

commented Jan 4, 2017

I saw a previous report of this too (in #18061), which is worrying, but in the previous case the poster couldn't answer whether their program was race-free and I spent a fair bit of time reading the relevant code again and couldn't see a way for this to happen.

@zeropool, how easily can you reproduce this? Can you send a complete program that causes the program? If so, and you're unable to run the race detector yourself, I could run your stand-alone reproducer program on a 64-bit host to check for races.

@bradfitz bradfitz self-assigned this Jan 4, 2017

@ALTree

This comment has been minimized.

Copy link
Member

commented Jan 4, 2017

FWIW that previous report is an exact duplicate of this one (filed the same day, and it has the same code snippets), probably opened by another person working on the same codebase as zeropool (or maybe it's even the same person).

@bradfitz

This comment has been minimized.

Copy link
Member

commented Jan 5, 2017

@botvs, @zeropool, is the full code for this available? Are you still having this problem? Can you still reproduce it with Go1.8beta2?

@bradfitz

This comment has been minimized.

Copy link
Member

commented Jan 10, 2017

Timed out.

@bradfitz bradfitz closed this Jan 10, 2017

@golang golang locked and limited conversation to collaborators Jan 10, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.