Skip to content
This repository was archived by the owner on Oct 29, 2024. It is now read-only.

Connection pool is full, discarding connection #349

Closed
newtoncorp opened this issue Jul 4, 2016 · 11 comments
Closed

Connection pool is full, discarding connection #349

newtoncorp opened this issue Jul 4, 2016 · 11 comments

Comments

@newtoncorp
Copy link

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.

@wolong12
Copy link

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.

@TeraHz
Copy link

TeraHz commented Oct 3, 2016

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

@alyan2008
Copy link

Hi

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

@lesingerouge
Copy link

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

@daddy-shark
Copy link

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

@mihalski
Copy link

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?

@TeraHz
Copy link

TeraHz commented Mar 23, 2017

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

@mihalski
Copy link

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.

@xginn8
Copy link
Collaborator

xginn8 commented Nov 17, 2017

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

@xginn8 xginn8 closed this as completed Nov 17, 2017
@clasnake
Copy link

@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.

@xginn8
Copy link
Collaborator

xginn8 commented Dec 13, 2017 via email

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

No branches or pull requests

9 participants