mirror of
https://gitee.com/dify_ai/dify.git
synced 2024-12-03 03:38:08 +08:00
fix: add redis lock to AnalyticdbVector init (#6859)
Co-authored-by: xiaozeyu <xiaozeyu.xzy@alibaba-inc.com>
This commit is contained in:
parent
df8f8c9a2c
commit
40c6f3c724
@ -65,8 +65,15 @@ class AnalyticdbVector(BaseVector):
|
|||||||
AnalyticdbVector._init = True
|
AnalyticdbVector._init = True
|
||||||
|
|
||||||
def _initialize(self) -> None:
|
def _initialize(self) -> None:
|
||||||
self._initialize_vector_database()
|
cache_key = f"vector_indexing_{self.config.instance_id}"
|
||||||
self._create_namespace_if_not_exists()
|
lock_name = f"{cache_key}_lock"
|
||||||
|
with redis_client.lock(lock_name, timeout=20):
|
||||||
|
collection_exist_cache_key = f"vector_indexing_{self.config.instance_id}"
|
||||||
|
if redis_client.get(collection_exist_cache_key):
|
||||||
|
return
|
||||||
|
self._initialize_vector_database()
|
||||||
|
self._create_namespace_if_not_exists()
|
||||||
|
redis_client.set(collection_exist_cache_key, 1, ex=3600)
|
||||||
|
|
||||||
def _initialize_vector_database(self) -> None:
|
def _initialize_vector_database(self) -> None:
|
||||||
from alibabacloud_gpdb20160503 import models as gpdb_20160503_models
|
from alibabacloud_gpdb20160503 import models as gpdb_20160503_models
|
||||||
|
Loading…
Reference in New Issue
Block a user