mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-10-10 13:15:18 +02:00
Fix document lock acquisition for user group sync
This commit is contained in:
@@ -25,26 +25,25 @@ def _sync_user_group_batch(
|
|||||||
logger.debug(f"Syncing document sets for: {document_ids}")
|
logger.debug(f"Syncing document sets for: {document_ids}")
|
||||||
|
|
||||||
# Acquires a lock on the documents so that no other process can modify them
|
# Acquires a lock on the documents so that no other process can modify them
|
||||||
prepare_to_modify_documents(db_session=db_session, document_ids=document_ids)
|
with prepare_to_modify_documents(db_session=db_session, document_ids=document_ids):
|
||||||
|
# get current state of document sets for these documents
|
||||||
|
document_id_to_access = get_access_for_documents(
|
||||||
|
document_ids=document_ids, db_session=db_session
|
||||||
|
)
|
||||||
|
|
||||||
# get current state of document sets for these documents
|
# update Vespa
|
||||||
document_id_to_access = get_access_for_documents(
|
document_index.update(
|
||||||
document_ids=document_ids, db_session=db_session
|
update_requests=[
|
||||||
)
|
UpdateRequest(
|
||||||
|
document_ids=[document_id],
|
||||||
|
access=document_id_to_access[document_id],
|
||||||
|
)
|
||||||
|
for document_id in document_ids
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
# update Vespa
|
# Finish the transaction and release the locks
|
||||||
document_index.update(
|
db_session.commit()
|
||||||
update_requests=[
|
|
||||||
UpdateRequest(
|
|
||||||
document_ids=[document_id],
|
|
||||||
access=document_id_to_access[document_id],
|
|
||||||
)
|
|
||||||
for document_id in document_ids
|
|
||||||
]
|
|
||||||
)
|
|
||||||
|
|
||||||
# Finish the transaction and release the locks
|
|
||||||
db_session.commit()
|
|
||||||
|
|
||||||
|
|
||||||
def sync_user_groups(user_group_id: int, db_session: Session) -> None:
|
def sync_user_groups(user_group_id: int, db_session: Session) -> None:
|
||||||
|
Reference in New Issue
Block a user