influxdb-python icon indicating copy to clipboard operation
influxdb-python copied to clipboard

Connection pool is full, discarding connection

Open newtoncorp opened this issue 10 years ago • 11 comments

When using influxdb-python in code that uses concurrent.futures.ThreadPoolExecutor heavily, the connections are not reaped and at some point, the data is discarded because there are too many different connections.

newtoncorp avatar Jul 04 '16 12:07 newtoncorp

I had the same problem when writing data to influxdb. I wrote 20 points at almost the same time, within different requests. Default connection pool size by 10 was not enough in this case.

wolong12 avatar Aug 25 '16 03:08 wolong12

Same issue when writing a lot of points from Home Assistant. It exhausts the connection pool very quickly (immediately)

TeraHz avatar Oct 03 '16 22:10 TeraHz

Hi

Seems I have the same problem. Did you fix it?

alyan2008 avatar Oct 04 '16 16:10 alyan2008

This seems like a requests limitation when handling the urllib3 connection pool manager. It's pretty much hardcoded here: https://github.com/kennethreitz/requests/blob/master/requests/adapters.py

lesingerouge avatar Oct 11 '16 10:10 lesingerouge

I had the same problem. Maybe some additional info can help to reproduce?

daddy-shark avatar Dec 14 '16 15:12 daddy-shark

I've also run into this issue. So does this effectively make InfluxDB totally useless for Home Assistant? Or is there another way to connect to it from Home Assistant?

dobrynski avatar Mar 23 '17 01:03 dobrynski

My Issue has gone away since HA changed the schema. I think it happened around release 36?

TeraHz avatar Mar 23 '17 03:03 TeraHz

I'm getting a lot of:

Traceback (most recent call last):
  File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/influxdb.py", line 155, in influx_event_listener
    influx.write_points(json_body)
  File "/home/homeassistant/.homeassistant/deps/influxdb/client.py", line 402, in write_points
    tags=tags)
  File "/home/homeassistant/.homeassistant/deps/influxdb/client.py", line 447, in _write_points
    expected_response_code=204
  File "/home/homeassistant/.homeassistant/deps/influxdb/client.py", line 289, in write
    headers=headers
  File "/home/homeassistant/.homeassistant/deps/influxdb/client.py", line 245, in request
    timeout=self._timeout
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/sessions.py", line 488, in request
    resp = self.send(prep, **send_kwargs)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/sessions.py", line 609, in send
    r = adapter.send(request, **kwargs)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/adapters.py", line 499, in send
    raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPConnectionPool(host='127.0.0.1', port=8086): Read timed out. (read timeout=5)
17-03-23 11:53:49 ERROR (MainThread) [homeassistant.core] Error doing job: Future exception was never retrieved
Traceback (most recent call last):
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 386, in _make_request
    six.raise_from(e, None)
  File "<string>", line 2, in raise_from
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 382, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/lib/python3.4/http/client.py", line 1172, in getresponse
    response.begin()
  File "/usr/lib/python3.4/http/client.py", line 351, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.4/http/client.py", line 313, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/usr/lib/python3.4/socket.py", line 371, in readinto
    return self._sock.recv_into(b)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/adapters.py", line 423, in send
    timeout=timeout
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 649, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/packages/urllib3/util/retry.py", line 347, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/packages/urllib3/packages/six.py", line 686, in reraise
    raise value
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 388, in _make_request
    self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 308, in _raise_timeout
    raise ReadTimeoutError(self, url, "Read timed out. (read timeout=%s)" % timeout_value)
requests.packages.urllib3.exceptions.ReadTimeoutError: HTTPConnectionPool(host='127.0.0.1', port=8086): Read timed out. (read timeout=5)

With 40.1 installed at the moment.

dobrynski avatar Mar 23 '17 03:03 dobrynski

Closing as this is now configurable. If there are still issues regarding this error, we'll reopen.

xginn8 avatar Nov 17 '17 02:11 xginn8

@xginn8 Hi, any plan for a new release that can be installed via pip? Seems the latest version is still 4.1.1 for now.

clasnake avatar Dec 13 '17 11:12 clasnake

We released 5.0 a week or so ago and pypi looks up to date: https://pypi.python.org/pypi/influxdb

On Dec 13, 2017 6:28 AM, "clasnake" [email protected] wrote:

@xginn8 https://github.com/xginn8 Hi, any plan for a new release that can be installed via pip? Seems the latest version is still 4.1.1 for now.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/influxdata/influxdb-python/issues/349#issuecomment-351364360, or mute the thread https://github.com/notifications/unsubscribe-auth/AGYxLU5dgj-tpdDX3ivoKnURKZrGM6dxks5s_7TzgaJpZM4JETro .

xginn8 avatar Dec 13 '17 13:12 xginn8