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

Client is not thread safe #53

Open
asettouf opened this issue Apr 29, 2021 · 1 comment
Open

Client is not thread safe #53

asettouf opened this issue Apr 29, 2021 · 1 comment

Comments

@asettouf
Copy link

Hi,

after some thorough testing with goroutines, I do not understand how the documentation can claim:

// client is safe for concurrent use as the fields are all read-only
// once the client is instantiated.

Indeed, trying this snippet of code in a for loop works properly:

q := client.NewQuery(query_string, "mydb", "s")
response, err := c.Query(q)

However trying the same in a for loop starting goroutines, most of my functions error out with:
2021/04/29 15:05:24 Error querying influx unable to decode json: received status code 200 err: unexpected EOF

Now with goroutines, the same snippet works with a sync.Mutex:

l.Lock()
q := client.NewQuery(query_string, "schoonschip", "s")
response, err := c.Query(q)
l.Unlock()

What am I missing here?

@wxmeng04
Copy link

I met a new issue. When writing to influxdb with the same client in 36 go routines, there is the following error:
Post \"http://127.0.0.1:8086/write?consistency=&db=smp&precision=s&rp=\": read tcp 127.0.0.1:42896->127.0.0.1:8086: read: connection reset by peer
I guess it's the same reason.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants