Compare commits

...

2 Commits

Author SHA1 Message Date
jze9
e328236d0f fix(ci): pip через Tsinghua-зеркало во всех Dockerfile — надёжные сборки
All checks were successful
Deploy / deploy (push) Successful in 17m2s
pypi.org с этой сети отдаёт данные с таймаутами (TCP есть, пакеты почти не
качаются) → CI-сборки падали. pypi.tuna.tsinghua.edu.cn — полное зеркало,
отдаёт стабильно (celery за 13с). Прописал -i зеркало во все 5 Dockerfile.
Сборки перестанут зависеть от флоки-канала до pypi.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-08-07 16:46:08 +05:00
jze9
52e5550f91 fix(indexer): гонка дублей ext_id (IntegrityError→duplicate) + откат Dockerfile
- add_document: параллельные воркеры проходили проверку existing и оба
  вставляли один ext_id → IntegrityError в логах. Теперь ловим её, откатываем
  и возвращаем duplicate — чисто, без шумных ошибок.
- Dockerfile: откат --timeout/--retries (он инвалидировал кэш pip-слоя, а
  толку от него при недоступном pypi нет). Устойчивость сборки решать зеркалом
  когда появится рабочее.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-08-07 16:05:42 +05:00
6 changed files with 16 additions and 7 deletions

View File

@@ -10,7 +10,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
&& rm -rf /var/lib/apt/lists/*
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
RUN pip install --no-cache-dir --timeout 60 -i https://pypi.tuna.tsinghua.edu.cn/simple/ -r requirements.txt
COPY . .

View File

@@ -8,7 +8,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
RUN pip install --no-cache-dir --timeout 60 -i https://pypi.tuna.tsinghua.edu.cn/simple/ -r requirements.txt
COPY . .

View File

@@ -21,7 +21,7 @@ RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 1
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
RUN pip install --no-cache-dir --timeout 60 -i https://pypi.tuna.tsinghua.edu.cn/simple/ -r requirements.txt
COPY . .

View File

@@ -13,8 +13,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
WORKDIR /app
COPY requirements.txt .
# --timeout/--retries: канал до pypi медленный и флоки, без этого сборка падает
RUN pip install --no-cache-dir --timeout 120 --retries 10 -r requirements.txt
RUN pip install --no-cache-dir --timeout 60 -i https://pypi.tuna.tsinghua.edu.cn/simple/ -r requirements.txt
COPY . .

View File

@@ -7,6 +7,7 @@ from typing import Any
from celery.utils.log import get_task_logger
from sqlalchemy import func, select
from sqlalchemy.exc import IntegrityError
from app.algorithms.minhash import add_to_lsh, find_similar
from app.algorithms.winnowing import winnow
@@ -299,7 +300,16 @@ def add_document(doc_data: dict[str, Any], dispatch_embed: bool = True) -> dict[
doc = Document(**doc_kwargs)
session.add(doc)
try:
session.flush()
except IntegrityError:
# Гонка: другой воркер параллельно вставил этот ext_id между нашей
# проверкой existing и flush. Уникальный индекс отработал — это дубль.
session.rollback()
existing = session.execute(
select(Document).where(Document.ext_id == ext_id)
).scalar_one_or_none()
return {"status": "duplicate", "doc_id": existing.id if existing else None}
doc_id = doc.id
# Вычислить fingerprints

View File

@@ -8,7 +8,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
RUN pip install --no-cache-dir --timeout 60 -i https://pypi.tuna.tsinghua.edu.cn/simple/ -r requirements.txt
COPY . .