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

compute/metadata: goroutine leak #2417

Closed
menghanl opened this issue Jun 10, 2020 · 1 comment · Fixed by #2431
Closed

compute/metadata: goroutine leak #2417

menghanl opened this issue Jun 10, 2020 · 1 comment · Fixed by #2431
Assignees
Labels
api: compute Issues related to the Compute Engine API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@menghanl
Copy link

Client

compute/metadata

Environment

Only reproducible on GCE VMs

Code

$ cat leak_test.go

package leak

import (
        "testing"

        "cloud.google.com/go/compute/metadata"
        "go.uber.org/goleak"
)

func TestGCEMetadata(t *testing.T) {
        defer goleak.VerifyNone(t)
        metadata.OnGCE()
}

$ cat go.mod

module leak

require (
        cloud.google.com/go v0.58.0
        github.com/davecgh/go-spew v1.1.1 // indirect
        github.com/kr/text v0.2.0 // indirect
        github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
        github.com/stretchr/testify v1.6.1 // indirect
        go.uber.org/goleak v1.0.0
        golang.org/x/tools v0.0.0-20200609164405-eb789aa7ce50 // indirect
        gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
        gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c // indirect
)
$ go test ./
--- FAIL: TestGCEMetadata (0.44s)
    leaks.go:78: found unexpected goroutines:
        [Goroutine 10 in state IO wait, with internal/poll.runtime_pollWait on top of the stack:
        goroutine 10 [IO wait]:
        internal/poll.runtime_pollWait(0x7f4768090f00, 0x72, 0xc000042a88)
                /usr/lib/go-1.11/src/runtime/netpoll.go:173 +0x66
        internal/poll.(*pollDesc).wait(0xc0000e8118, 0x72, 0xffffffffffffff00, 0x72ed60, 0x8c4430)
                /usr/lib/go-1.11/src/internal/poll/fd_poll_runtime.go:85 +0x9a
        internal/poll.(*pollDesc).waitRead(0xc0000e8118, 0xc0000eb000, 0x1000, 0x1000)
                /usr/lib/go-1.11/src/internal/poll/fd_poll_runtime.go:90 +0x3d
        internal/poll.(*FD).Read(0xc0000e8100, 0xc0000eb000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
                /usr/lib/go-1.11/src/internal/poll/fd_unix.go:169 +0x179
        net.(*netFD).Read(0xc0000e8100, 0xc0000eb000, 0x1000, 0x1000, 0x0, 0xc00002e3b8, 0x468c29)
                /usr/lib/go-1.11/src/net/fd_unix.go:202 +0x4f
        net.(*conn).Read(0xc00000e050, 0xc0000eb000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
                /usr/lib/go-1.11/src/net/net.go:177 +0x68
        net/http.(*persistConn).Read(0xc0000aeea0, 0xc0000eb000, 0x1000, 0x1000, 0x4064f3, 0xc00002e470, 0x42c0d2)
                /usr/lib/go-1.11/src/net/http/transport.go:1499 +0x75
        bufio.(*Reader).fill(0xc00005a7e0)
                /usr/lib/go-1.11/src/bufio/bufio.go:100 +0x10f
        bufio.(*Reader).Peek(0xc00005a7e0, 0x1, 0xc000188d80, 0xc00002e558, 0x60, 0x60, 0xc00005a720)
                /usr/lib/go-1.11/src/bufio/bufio.go:132 +0x3f
        net/http.(*persistConn).readLoop(0xc0000aeea0)
                /usr/lib/go-1.11/src/net/http/transport.go:1647 +0x1a2
        created by net/http.(*Transport).dialConn
                /usr/lib/go-1.11/src/net/http/transport.go:1340 +0x941
        
         Goroutine 11 in state select, with net/http.(*persistConn).writeLoop on top of the stack:
        goroutine 11 [select]:
        net/http.(*persistConn).writeLoop(0xc0000aeea0)
                /usr/lib/go-1.11/src/net/http/transport.go:1887 +0x113
        created by net/http.(*Transport).dialConn
                /usr/lib/go-1.11/src/net/http/transport.go:1341 +0x966
        ]
FAIL
FAIL    leak    0.442s
@menghanl menghanl added the triage me I really want to be triaged. label Jun 10, 2020
@product-auto-label product-auto-label bot added the api: compute Issues related to the Compute Engine API. label Jun 10, 2020
@codyoss codyoss added priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Jun 10, 2020
@codyoss codyoss self-assigned this Jun 10, 2020
@codyoss codyoss removed the triage me I really want to be triaged. label Jun 10, 2020
@codyoss
Copy link
Member

codyoss commented Jun 10, 2020

Thanks for the report, I will look into this later today.

codyoss added a commit that referenced this issue Jun 11, 2020
Tested changes on GCE to make sure this fixed the leak.

Fixes: #2417
menghanl added a commit to grpc/grpc-go that referenced this issue Jun 11, 2020
- use google default creds, so the client works not only on GCE (e.g. it also reads env variable for creds).
- Change google default creds to use jwt directly if scope is not set.

- Leak check is disabled temporarily due to googleapis/google-cloud-go#2417
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: compute Issues related to the Compute Engine API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants