最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - SQLITE & CHROMA:sqlite3.OperationalError: unable to open database file - Stack Overflow

programmeradmin7浏览0评论
    @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:

  1. We changed the relative database file path to the absolute ones.
  2. We used print() to ensure that the database connection can be closed.
  3. We used multi-process to request the main service, but in the test, we did NOT receive the same error.
发布评论

评论列表(0)

  1. 暂无评论