Established connection is never closed on Python 2.7
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
| python-swiftclient |
High
|
Tim Burke |
Bug Description
When we use python2.7 and python-
For example if you run 5 swiftclient.
~~~
>>> import swiftclient
>>> url, token = swiftclient.
>>> swiftclient.
>>> swiftclient.
>>> swiftclient.
>>> swiftclient.
>>> swiftclient.
~~~
You see that the process still has 5 TCP connection in ESTABLISHED status.
~~~
vagrant@
...
Output information may be incomplete.
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
python 16245 vagrant cwd DIR 8,3 4096 400663 /home/vagrant/
...
python 16245 vagrant 3u IPv4 2193105 0t0 TCP localhost:
python 16245 vagrant 4u IPv4 2195534 0t0 TCP localhost:
python 16245 vagrant 5u IPv4 2195673 0t0 TCP localhost:
python 16245 vagrant 6u IPv4 2195695 0t0 TCP localhost:
python 16245 vagrant 7u IPv4 2195717 0t0 TCP localhost:
python 16245 vagrant 13r CHR 1,9 0t0 11 /dev/urandom
~~~
This issue was observed in storlets functional tests, which use swiftclient to test api requests, and this remaining connections cause 'too many open files' error because the test process keeps lots of opened connections.
We don't observe the same in our py3 tests, so it seems that this happens only on Python2.7.
Also, we don't reproduce the issue after we switch to swiftclient 3.8.1, so the issue caused by some changes during 3.8.1 and 3.9.0 .
description: | updated |
Tim Burke (1-tim-z) wrote : | #1 |
Changed in python-swiftclient: | |
status: | In Progress → Confirmed |
importance: | Undecided → High |
assignee: | nobody → Tim Burke (1-tim-z) |
Changed in python-swiftclient: | |
status: | Confirmed → In Progress |
John Leach (johnleach) wrote : | #2 |
We've not seen open file leaks, but we have seen a memory leak when making lots of requests under a long running process, on python 2.7, after upgrading to 3.9.0 from 3.8.1
I've tested this patch on 3.9.0 and it's fixed our memory leak!
Fix proposed to branch: master
Review: https:/
Reviewed: https:/
Committed: https:/
Submitter: Zuul
Branch: master
commit 0c70d164ba52d76
Author: Tim Burke <email address hidden>
Date: Wed Jun 17 15:44:22 2020 -0700
(Mostly) revert "Cleanup session on delete"
This reverts commit 1f26c5736949e1c
Apparently the existence of the __del__ method on Python 2 prevents us
from cleaning up all file descriptors.
Change-Id: Id6cff5dd7b9faf
Closes-Bug: #1873435
Related-Bug: #1838775
Changed in python-swiftclient: | |
status: | In Progress → Fix Released |
Reviewed: https:/
Committed: https:/
Submitter: Zuul
Branch: master
commit 97aa3e65412ee24
Author: Tim Burke <email address hidden>
Date: Sat Apr 18 22:41:55 2020 -0700
Close connections created when calling module-level functions
Co-Authored-By: Clay Gerrard <email address hidden>
Change-Id: Id62e63afc6f2ff
Related-Change: I200ad0cdc8b799
Related-Bug: #1873435
Closes-Bug: #1838775
This issue was fixed in the openstack/
Thanks for the detailed bug report! Ironically, I think this was caused by https:/ /review. opendev. org/#/c/ 674320/ which attempted to solve exactly the same problem :-( I think https:/ /review. opendev. org/721051 should fix it reasonably well, though?