@override
def connect(self, *args: Any, **kwargs: Any) -> Connection:
if hasattr(self._connection, "conn") and self._connection.conn is not None:
return self._connection.conn # type: ignore # cast doesn't work here for some reason
else:
new_connection = Connection(
self, self._db_file, self._is_uri, *args, **kwargs
)
self._connection.conn = new_connection
with self._lock:
self._connections.add(weakref.ref(new_connection))
return new_connection
We are using Chroma to build a project. The service is deployed on a Linux system. Initially, the service ran without any issues. However, after we increased the scale of the database, problems began to occur. The service now frequently crashes with the same error (the detailed traceback is attached). The current situation is that the service can start normally, but after some time (erratically), it crashes.
File "lib/python3.11/site-packages/chromadb/api/models/Collection.py", line 195, in query File "lib/python3.11/site-packages/chromadb/telemetry/opentelemetry/__init__.py", line 146, in wrapper File "lib/python3.11/site-packages/chromadb/rate_limiting/__init__.py", line 47, in wrapper File "lib/python3.11/site-packages/chromadb/api/segment.py", line 754, in _query File "lib/python3.11/site-packages/chromadb/telemetry/opentelemetry/__init__.py", line 146, in wrapper File "lib/python3.11/site-packages/chromadb/segment/impl/metadata/sqlite.py", line 214, in get_metadata File "lib/python3.11/site-packages/chromadb/db/impl/sqlite.py", line 132, in tx File "lib/python3.11/site-packages/chromadb/db/impl/sqlite.py", line 31, in __init__ File "lib/python3.11/site-packages/chromadb/db/impl/sqlite_pool.py", line 141, in connect File "lib/python3.11/site-packages/chromadb/db/impl/sqlite_pool.py", line 20, in __init__ sqlite3.OperationalError: unable to open database file
We have Googled and found some solutions, but they still do not work:
- We changed the relative database file path to the absolute ones.
- We used print() to ensure that the database connection can be closed.
- We used multi-process to request the main service, but in the test, we did NOT receive the same error.