feat: stabilize multi-region runtime sync and worker orchestration

This commit is contained in:
root
2026-04-27 15:48:12 +08:00
parent 7cbde2aa78
commit 215a364891
137 changed files with 31931 additions and 1943 deletions

View File

@@ -47,6 +47,8 @@ def import_domains_from_path(file_path: Path, source_type: int = 7) -> dict:
domains = [row[0] for row in normalized_rows]
existing_set: set[str] = set()
inserted = 0
exists = 0
seen_in_batch: set[str] = set()
with get_db() as conn:
with conn.cursor() as cur:
@@ -55,7 +57,12 @@ def import_domains_from_path(file_path: Path, source_type: int = 7) -> dict:
existing_set = {row[0] for row in cur.fetchall()}
for domain, tld in normalized_rows:
if domain in seen_in_batch:
exists += 1
continue
seen_in_batch.add(domain)
if domain in existing_set:
exists += 1
continue
cur.execute(
"""
@@ -70,11 +77,17 @@ def import_domains_from_path(file_path: Path, source_type: int = 7) -> dict:
null, now(), now(), 0, null,
0, 0, 0
)
on conflict (domain) do nothing
returning id
""",
(domain, tld, source_type),
)
domain_id = cur.fetchone()[0]
inserted_row = cur.fetchone()
if not inserted_row:
existing_set.add(domain)
exists += 1
continue
domain_id = inserted_row[0]
cur.execute(
"""
insert into detect_tasks (domain_id, task_type, status, priority, retry_count, create_time, update_time)
@@ -82,10 +95,10 @@ def import_domains_from_path(file_path: Path, source_type: int = 7) -> dict:
""",
(domain_id,),
)
existing_set.add(domain)
inserted += 1
conn.commit()
exists = len(existing_set)
valid = len(normalized_rows)
stats = {
"total": total,