influxdata / influxdata/influxdb-client-python

Is query_api() thread-safe?

Open
#429 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question
Dominant language
Python
Stars
793
Forks
186
Avg merge
3h 2m
Merged PRs (30d)
1

Description

Steps to reproduce:
List the minimal actions needed to reproduce the behavior.

  1. We use one connection with InfluxDBClient -> query_api().
  2. Run multiple threads re-using this same connection.
  3. We got an error (see screenshots).

Expected behavior:
I would expect influx to be thread-safe.

Actual behavior:
An error during read happend.

urllib3.exceptions.ProtocolError: ('Connection aborted.', OSError(9, 'Bad file descriptor'))
return self._sslobj.read(len, buffer)
File "/usr/lib/python3.8/ssl.py", line 1099, in read
return self.read(nbytes, buffer)
File "/usr/lib/python3.8/ssl.py", line 1241, in recv_into
return self._sock.recv_into(b)
File "/usr/lib/python3.8/socket.py", line 669, in readinto
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/usr/lib/python3.8/http/client.py", line 277, in _read_status
version, status, reason = self._read_status()
File "/usr/lib/python3.8/http/client.py", line 316, in begin
response.begin()
File "/usr/lib/python3.8/http/client.py", line 1348, in getresponse
httplib_response = conn.getresponse()
File "/usr/local/lib/python3.8/dist-packages/urllib3/connectionpool.py", line 440, in _make_request
File "", line 3, in raise_from
six.raise_from(e, None)
File "/usr/local/lib/python3.8/dist-packages/urllib3/connectionpool.py", line 445, in _make_request
httplib_response = self._make_request(
File "/usr/local/lib/python3.8/dist-packages/urllib3/connectionpool.py", line 699, in urlopen
raise value.with_traceback(tb)
File "/usr/local/lib/python3.8/dist-packages/urllib3/packages/six.py", line 734, in reraise
raise six.reraise(type(error), error, _stacktrace)
File "/usr/local/lib/python3.8/dist-packages/urllib3/util/retry.py", line 507, in increment
retries = retries.increment(
File "/usr/local/lib/python3.8/dist-packages/urllib3/connectionpool.py", line 755, in urlopen
response = conn.urlopen(method, u.request_uri, **kw)
File "/usr/local/lib/python3.8/dist-packages/urllib3/poolmanager.py", line 375, in urlopen
return self.urlopen(method, url, **extra_kw)
File "/usr/local/lib/python3.8/dist-packages/urllib3/request.py", line 170, in request_encode_body
return self.request_encode_body(
File "/usr/local/lib/python3.8/dist-packages/urllib3/request.py", line 78, in request
r = self.pool_manager.request(
File "/usr/local/lib/python3.8/dist-packages/influxdb_client/rest.py", line 179, in request
return self.request("POST", url,
File "/usr/local/lib/python3.8/dist-packages/influxdb_client/rest.py", line 300, in POST
return self.rest_client.POST(url,
File "/usr/local/lib/python3.8/dist-packages/influxdb_client/api_client.py", line 385, in request
response_data = self.request(
File "/usr/local/lib/python3.8/dist-packages/influxdb_client/api_client.py", line 170, in __call_api
return self._call_api(resource_path, method,
File "/usr/local/lib/python3.8/dist-packages/influxdb_client/api_client.py", line 340, in call_api
return self.api_client.call_api(
File "/usr/local/lib/python3.8/dist-packages/influxdb_client/service/query_service.py", line 340, in post_query_with_http
>
(data) = self.post_query_with_http_info(**kwargs) # noqa: E501
File "/usr/local/lib/python3.8/dist-packages/influxdb_client/service/query_service.py", line 260, in post_query
response = self._query_api.post_query(org=org, query=self._create_query(query, self.default_dialect),
File "/usr/local/lib/python3.8/dist-packages/influxdb_client/client/query_api.py", line 140, in query_data_frame_stream
_generator = self.query_data_frame_stream(query, org=org, data_frame_index=data_frame_index)
File "/usr/local/lib/python3.8/dist-packages/influxdb_client/client/query_api.py", line 116, in query_data_frame
result = self.query_api.query_data_frame(query, data_frame_index=["_time"])
Traceback (most recent call last):
During handling of the above exception, another exception occurred:
OSError: [Errno 9] Bad file descriptor
return self._sslobj.read(len, buffer)
File "/usr/lib/python3.8/ssl.py", line 1099, in read
return self.read(nbytes, buffer)
File "/usr/lib/python3.8/ssl.py", line 1241, in recv_into
return self._sock.recv_into(b)
File "/usr/lib/python3.8/socket.py", line 669, in readinto
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/usr/lib/python3.8/http/client.py", line 277, in _read_status
version, status, reason = self._read_status()
File "/usr/lib/python3.8/http/client.py", line 316, in begin
response.begin()
File "/usr/lib/python3.8/http/client.py", line 1348, in getresponse
httplib_response = conn.getresponse()
File "/usr/local/lib/python3.8/dist-packages/urllib3/connectionpool.py", line 440, in _make_request
File "", line 3, in raise_from
six.raise_from(e, None)
File "/usr/local/lib/python3.8/dist-packages/urllib3/connectionpool.py", line 445, in _make_request
httplib_response = self._make_request(
File "/usr/local/lib/python3.8/dist-packages/urllib3/connectionpool.py", line 699, in urlopen

Specifications:

  • Client Version: 1.16.0
  • InfluxDB Version: InfluxDB 2.0
  • Platform: Ubuntu 20.04.4 LTS

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with influxdb_client/client/query_api.py and trace the request through service/query_service.py, api_client.py, and rest.py. Reproduce concurrent reuse of one client using the reported query_data_frame path and determine the supported thread-safety behavior; done means the failure is explained and the issue has a confirmed resolution or documented usage guidance.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, 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.