pymilvus icon indicating copy to clipboard operation
pymilvus copied to clipboard

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

Open speechwrecko opened this issue 1 year ago • 9 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

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

speechwrecko avatar Jul 22 '24 19:07 speechwrecko

+1, I ran into this issue as well.

thom-bahm avatar Aug 11 '24 23:08 thom-bahm

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

trish11953 avatar Oct 07 '24 18:10 trish11953

+1

wyhanz avatar Oct 15 '24 09:10 wyhanz

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

wyhanz avatar Oct 15 '24 09:10 wyhanz

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.

AlexKupreev avatar Oct 27 '24 11:10 AlexKupreev

在sanic多进程中使用也会遇到类似错误。Open milvus.db failed, the file has been opened by another program Start local milvus failed。Failed to create new connection using:XXX

husongjiang avatar Nov 21 '24 02:11 husongjiang

Same problem while working with pymilvus locally, can't get any logic behind the unexpected errors while opening the db

photosartd avatar Dec 03 '24 08:12 photosartd

I just solved it by changing the flask API debugging mode to false! 🫡

mertbozkir avatar Dec 17 '24 23:12 mertbozkir

+1

Subilan avatar May 31 '25 11:05 Subilan