milvus-io / pymilvus

Python SDK for Milvus.
Apache License 2.0
1.03k stars 328 forks source link

[Bug]: Flask debug mode and Milvus Local appear to conflict #2193

Open speechwrecko opened 3 months ago

speechwrecko commented 3 months ago

Is there an existing issue for this?

Describe the bug

When I run PyMilvus with Milvus Local in a Python Flask application with debug set to True, Milvus fails saying it "Can't start local milvus" because the file is being used by another program.

It's as if FLASK debug is locking the file or perhaps there is some other odd issue

Stack trace:

Open demo.db failed, the file has been opened by another program Start local milvus failed Failed to create new connection using: c767688b751d4e47b68295a896cca39a Traceback (most recent call last): .... File "/home/jason/.local/lib/python3.8/site-packages/pymilvus/milvus_client/milvus_client.py", line 58, in init self._using = self._create_connection( File "/home/jason/.local/lib/python3.8/site-packages/pymilvus/milvus_client/milvus_client.py", line 651, in _create_connection raise ex from ex File "/home/jason/.local/lib/python3.8/site-packages/pymilvus/milvus_client/milvus_client.py", line 648, in _create_connection connections.connect(using, user, password, db_name, token, uri=uri, **kwargs) File "/home/jason/.local/lib/python3.8/site-packages/pymilvus/orm/connections.py", line 382, in connect raise ConnectionConfigException(message="Open local milvus failed") pymilvus.exceptions.ConnectionConfigException: <ConnectionConfigException: (code=1, message=Open local milvus failed)>

Expected Behavior

I see no reason why this shouldn't work and it implies there might be a larger issue

Steps/Code To Reproduce behavior

Create a simple flask app and load a local milvus file.  Set debug to true.

app.run(debug=True)

Environment details

- Hardware/Softward conditions (OS, CPU, GPU, Memory):
- Method of installation (Docker, or from source):
- Milvus version (v0.3.1, or v0.4.0):
- Milvus configuration (Settings you made in `server_config.yaml`):

Anything else?

No response

thom-bahm commented 3 months ago

+1, I ran into this issue as well.

trish11953 commented 1 month ago

Got the same error with demo.db while using multiple Ray Serve replicas. Any solution?

wyhanz commented 1 month ago

+1

wyhanz commented 1 month ago

+1

This bug can even be reproduced in a simple way. After creating a database connection, I insert three records, each with 768 dimensions. Immediately after, I let the program sleep for 60 seconds. When I create a new connection after that, the aforementioned error occurs. However, if I restart the program quickly, the error does not happen, and the program runs normally. I find this situation really confusing.

AlexKupreev commented 3 weeks ago

The same while working from different jupyter notebooks - the first one works as expected, but in the second one the error happens. Only manual deletion of .lock file helped.