influxdata / influxdata/influxdb1-client

Client is not thread safe

Open
#53 1 comment 2 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
192
Forks
109
PR merge metrics
No merged PRs in 30d

Description

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?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the goroutine loop described around client.NewQuery and c.Query, then compare it with the version protected by sync.Mutex. Inspect the client query path to identify why concurrent requests produce unexpected EOF; done means establishing the concurrent-use behavior and adding the appropriate fix or documentation.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.