Details
-
Bug
-
Status: Closed
-
Major - P3
-
Resolution: Cannot Reproduce
-
None
-
None
-
None
-
None
-
debian 9.9
python 3.5.3
pymongo 3.8.0
Description
Hello,
- On script exit, MongoClient() hangs for ~0.5 seconds for no apparent reason.
- Even without any active connection or any operation done.
How to reproduce }}{{:{{}}
docker run -it --rm debian bash
|
#
|
apt update
|
apt install -y python3-pip
|
pip3 install pymongo
|
#
|
cat /etc/debian_version
|
-> 9.9 |
python3 -c "import sys; print(sys.version)" |
-> 3.5.3 (default, Sep 27 2018, 17:25:39) |
-> [GCC 6.3.0 20170516] |
python3 -c "import pymongo; print(pymongo.version); print(pymongo.has_c())" |
-> 3.8.0 |
-> True
|
#
|
echo ''' |
import sys |
import pymongo |
|
if len(sys.argv) > 1: |
print("MongoClient") |
pymongo.MongoClient(connect=False)
|
else: |
print("nothing") |
|
print("end") |
''' > test.py |
#
|
time python3 test.py
|
nothing
|
end
|
-> real 0m0.120s
|
time python3 test.py foo
|
MongoClient
|
end
|
-> real 0m0.633s
|
- on the 1st run (without foo arg), their is not lag between the "end" and the time command output.
- but, on the 2nd run (with foo arg to trigger MongoClient) their is a distinct lag between the "end" and the time command output.
- this is the simplest example to reproduce the bug, but :
- a explicit ".close()" on MongoClient does NOT help.
- a "connect=True" does NOT help.
- doing real CRUD operations on a real authenticated mongod/replicaset/mongos does NOT help.
- When your applicative processing - including mongo auth and CRUD - takes about 200ms, a +500ms is a huge performance loss.
- I tried to reproduce this bug in php and nodejs but could not :
- php : 21ms -> 29ms => no loss.
- nodejs : 48ms -> 107ms => +50ms loss (still huge, but acceptable).
Any help would be greatly appreciated.
Attachments
Issue Links
- is related to
-
PYTHON-3174 Remove noisy Topology has THREADS RUNNING check for main test client
-
- Closed
-
- related to
-
PYTHON-1897 Topology.close can open sockets and background threads
-
- Closed
-
-
PYTHON-1898 Close topology events executor faster after the topology is garbage collected
-
- Closed
-
-
PYTHON-1634 Provide a way to join background threads when closing a MongoClient
-
- Backlog
-