Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add validation for pruning #3882

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions backend/onyx/background/celery/tasks/indexing/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,8 @@ def connector_indexing_task(
# define a callback class
callback = IndexingCallback(
os.getppid(),
redis_connector.stop.fence_key,
redis_connector_index.generator_progress_key,
redis_connector,
redis_connector_index,
lock,
r,
)
Expand Down
16 changes: 10 additions & 6 deletions backend/onyx/background/celery/tasks/indexing/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,16 @@ class IndexingCallback(IndexingHeartbeatInterface):
def __init__(
self,
parent_pid: int,
stop_key: str,
generator_progress_key: str,
redis_connector: RedisConnector,
redis_connector_index: RedisConnectorIndex,
redis_lock: RedisLock,
redis_client: Redis,
):
super().__init__()
self.parent_pid = parent_pid
self.redis_connector: RedisConnector = redis_connector
self.redis_connector_index: RedisConnectorIndex = redis_connector_index
self.redis_lock: RedisLock = redis_lock
self.stop_key: str = stop_key
self.generator_progress_key: str = generator_progress_key
self.redis_client = redis_client
self.started: datetime = datetime.now(timezone.utc)
self.redis_lock.reacquire()
Expand All @@ -120,7 +120,7 @@ def __init__(
self.last_parent_check = time.monotonic()

def should_stop(self) -> bool:
if self.redis_client.exists(self.stop_key):
if self.redis_connector.stop.fenced:
return True

return False
Expand All @@ -143,6 +143,8 @@ def progress(self, tag: str, amount: int) -> None:
# self.last_parent_check = now

try:
self.redis_connector.prune.set_active()

current_time = time.monotonic()
if current_time - self.last_lock_monotonic >= (
CELERY_GENERIC_BEAT_LOCK_TIMEOUT / 4
Expand All @@ -165,7 +167,9 @@ def progress(self, tag: str, amount: int) -> None:
redis_lock_dump(self.redis_lock, self.redis_client)
raise

self.redis_client.incrby(self.generator_progress_key, amount)
self.redis_client.incrby(
self.redis_connector_index.generator_progress_key, amount
)


def validate_indexing_fence(
Expand Down
Loading
Loading