Skip scheduled sync of a remote source paused for reconnect

S3 and GitHub sources synced from a connection kept being retried on
every schedule after their connection needed reconnecting, failing and
notifying the owner each time. They now wait, like Drive and Confluence
sources, and resume when the connection is reconnected.
This commit is contained in:
arc53-machine committed 2026-09-29 10:41:03 +01:00
1 parent 84230409c6
commit bbf83f02b2
2 files changed
+39 -1

No files matched your search

+18 -1
View File
@@ -1519,7 +1519,7 @@ def sync_worker(self, frequency):
with db_readonly() as conn:
result = conn.execute(
sql_text(
"SELECT id, name, user_id, type, remote_data, retriever, connection_id "
"SELECT id, name, user_id, type, remote_data, retriever, connection_id, metadata "
"FROM sources WHERE sync_frequency = :freq"
),
{"freq": frequency},
@@ -1549,6 +1549,23 @@ def sync_worker(self, frequency):
sync_counts["sync_skipped"] += 1
continue
metadata = doc.get("metadata")
if isinstance(metadata, str):
try:
metadata = json.loads(metadata)
except ValueError:
metadata = {}
if (
doc.get("connection_id")
and isinstance(metadata, dict)
and metadata.get("sync_state") == "paused_reconnect"
):
# An S3 or GitHub source whose connection needs reconnecting:
# it resumes when the owner reconnects, rather than failing (and
# notifying) on every schedule until then.
sync_counts["sync_skipped"] += 1
continue
source_data = normalize_remote_data(source_type, doc.get("remote_data"))
if not source_data:
# No syncable URL/config — skip instead of dispatching a sync