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

Deadline exceeded when drivers cannot be allocated (even if the client provides context.Background()) #229

Closed
smola opened this issue Dec 13, 2018 · 9 comments
Assignees
Labels

Comments

@smola
Copy link
Member

smola commented Dec 13, 2018

Possibly duped or related to #227 #209

Using bblfshd:2.11.0-drivers image.

bblfshd logs:

time="2018-12-13T11:42:21Z" level=warning msg="unable to allocate a driver instance: context deadline exceeded" language=go
time="2018-12-13T11:42:21Z" level=error msg="request processed content 6534844 bytes error: context deadline exceeded" elapsed=6.198363245s language=go

client logs:

rpc error: code = Unknown desc = context deadline exceeded

Code to reproduce:

package main

import (
	"context"
	"fmt"
	"io/ioutil"
	"net/http"
	"runtime"
	"sync"
	"sync/atomic"

	bblfsh "gopkg.in/bblfsh/client-go.v3"
)

func main() {

	url := `https://raw.githubusercontent.com/src-d/enry/master/data/frequencies.go`
	resp, err := http.DefaultClient.Get(url)
	if err != nil {
		panic(err)
	}

	bs, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		panic(err)
	}

	code := string(bs)

	client, err := bblfsh.NewClient("0.0.0.0:9432")
	if err != nil {
		panic(err)
	}

	wg := sync.WaitGroup{}
	var count int32
	for i := 0; i < runtime.NumCPU()*2; i++ {
		wg.Add(1)
		go func() {
			for {
				_, _, err = client.
					NewParseRequest().
					Context(context.Background()).
					Language("go").
					Content(code).
					UAST()
				if err != nil {
					fmt.Println(err)
				}

				newCount := atomic.AddInt32(&count, 1)
				if newCount%100 == 0 {
					fmt.Printf("Requests: %d\n", newCount)
				}
			}
			wg.Done()
		}()
	}
	wg.Wait()
}
@bzz bzz added the bug label Jan 11, 2019
@smacker
Copy link

smacker commented Jan 25, 2019

I'm having the same issue with csharp driver. Most probably it takes more than 5 seconds to start it on my system and:

[2019-01-23T16:37:35Z]  INFO driver csharp installed "bblfsh/csharp-driver:latest"
[2019-01-23T16:39:06Z]  INFO csharp-driver version: v0.2.0 (build: 2019-01-22T15:05:36Z) id=01d1xs8h4919r040kregr8qr3p language=csharp
[2019-01-23T16:39:06Z]  INFO server listening in /tmp/rpc.sock (unix) id=01d1xs8h4919r040kregr8qr3p language=csharp
[2019-01-23T16:39:49Z]  WARN unable to allocate a driver instance: context deadline exceeded language=csharp
[2019-01-23T16:39:49Z] ERROR request processed content 343 bytes error: context deadline exceeded elapsed=5.0019308s filename=hello.java language=csharp

Looks like timeout is triggered by this value: https://github.com/bblfsh/bblfshd/blob/master/daemon/pool.go#L24
I tried to change timeout in context of the client but no luck.

@dennwc
Copy link
Member

dennwc commented Jan 25, 2019

I'm working right now to fix some timeout issues, and I think the general consensus is to remove default timeout from bblfshd and let the client decide. I will fix it shortly.

@dennwc dennwc self-assigned this Jan 25, 2019
@dennwc
Copy link
Member

dennwc commented Jan 31, 2019

Can you please test it on the latest release?

@smacker
Copy link

smacker commented Jan 31, 2019

hm...

$ docker run --privileged -p 9432:9432 --rm -it bblfsh/bblfshd:v2.11.1
[2019-01-31T17:28:52Z]  INFO bblfshd version: v2.11.1 (build: 2019-01-31T17:16:13+0000)
[2019-01-31T17:28:52Z]  INFO initializing runtime at /var/lib/bblfshd
[2019-01-31T17:28:52Z] ERROR wrong date format for build: parsing time "2019-01-31T17:16:13+0000" as "2006-01-02T15:04:05Z07:00": cannot parse "+0000" as "Z07:00

@dennwc
Copy link
Member

dennwc commented Jan 31, 2019

Probably broken by e5ca340

@smacker
Copy link

smacker commented Feb 6, 2019

Looks like the issue is solved: bblfsh/csharp-driver#25

@dennwc
Copy link
Member

dennwc commented Feb 6, 2019

@smacker Is it? What is different now?

@smacker
Copy link

smacker commented Feb 6, 2019

There is no context deadline exceeded error anymore, request runs forever with context.Background().

@dennwc
Copy link
Member

dennwc commented Feb 6, 2019

Awesome! It means you are using the v2 API under the hood. I'll close this one then. Thanks for checking it!

@dennwc dennwc closed this as completed Feb 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants