Skip to content

enhancement(connectors): mid-sync checkpoint state so large syncs resume on crash #8146

Description

@mrveiss

Problem

AbstractConnector.sync() updates last_sync_at only on successful completion. If a large sync crashes mid-way (OOM, timeout, worker restart), the next run restarts from the beginning. For connectors with thousands of sources (large file servers, deep web crawls), this wastes significant time and network I/O.

Current state:

sync starts → process N sources → … crash → next run restarts from last_sync_at (hours ago)

Proposed Solution

Write a checkpoint to Redis after each successfully processed source during sync:

connector:{id}:checkpoint → {
    "started_at": ISO,
    "processed_source_ids": [...],
    "last_checkpointed_at": ISO
}

At sync start, check for an in-progress checkpoint. If found and started within a configurable window (e.g., 2h), resume by skipping already-processed source IDs. Clear the checkpoint on successful completion or explicit full-refresh.

Changes to AbstractConnector:

  • _write_checkpoint(source_id) — called after each successful _process_change()
  • _read_checkpoint() → set of already-processed source IDs or empty set
  • _clear_checkpoint() — called on clean completion
  • sync() — skip sources in checkpoint set, write checkpoint after each

Files

  • autobot-backend/knowledge/connectors/base.py — add checkpoint methods; update sync() loop
  • autobot-backend/knowledge/connectors/models.py — add resumed_from_checkpoint: bool to SyncResult
  • autobot-backend/api/knowledge_connectors.py — expose checkpoint status in history entries

Acceptance Criteria

  • sync() writes a checkpoint to Redis after each successfully processed source
  • On restart, sync reads checkpoint and skips already-processed sources
  • SyncResult includes resumed_from_checkpoint: bool
  • Checkpoint is cleared on successful full completion
  • Full-refresh (incremental=False) always ignores and clears any checkpoint
  • Checkpoint TTL set to 24h to prevent stale state accumulation
  • Unit tests: normal flow, crash-and-resume, full-refresh override

Activity

  1. mrveiss commented on May 22, 2026

    @mrveiss
    OwnerAuthor

    Implemented and merged via PR #8277 into Dev_new_gui. Closing.

  2. mrveiss commented on May 22, 2026

    @mrveiss
    OwnerAuthor

    ✅ Closed — implementation merged to Dev_new_gui

    Commit: be3c276 feat(connectors): HTTP retry, typed auth, mid-sync checkpoint (#8144, #8145, #8146)

    Acceptance Criteria Met:

    • ✅ Redis-backed checkpoint via connector:{id}:checkpoint SADD with 24h TTL
    • ✅ _write_checkpoint(), _read_checkpoint(), _clear_checkpoint() implemented on AbstractConnector
    • ✅ sync() skips already-processed sources on restart (change.source_id in already_processed)
    • ✅ Checkpoint cleared on successful/partial completion; preserved on crash (exception path)
    • ✅ SyncResult.resumed_from_checkpoint bool exposed and recorded in history entries
    • ✅ Full-refresh (incremental=False) clears checkpoint first

    Discovery follow-ups (filed, not blocking closure):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions