From 393a8f6858c4684ccaa0fff018cc4806f3d58ba1 Mon Sep 17 00:00:00 2001 From: caohuipeng Date: Sun, 27 Sep 2026 22:42:12 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix(docker):=20=E5=90=AF=E7=94=A8=20pip=20?= =?UTF-8?q?=E8=B6=85=E6=97=B6/=E9=87=8D=E8=AF=95=E6=9E=84=E5=BB=BA?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E5=B9=B6=E4=BF=9D=E7=95=99=20BuildKit=20?= =?UTF-8?q?=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/Dockerfile | 4 +++- docker-compose.yml | 10 ++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index 002544f7..f0b08bcc 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -45,10 +45,12 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ && rm -rf /var/lib/apt/lists/* # Install Python dependencies +# 注意:勿加 --no-cache-dir,否则 BuildKit 的 /root/.cache/pip 挂载无效, +# 每次重建都全量下载 onnxruntime 等大包,镜像源抖动时极易 Read timed out。 COPY backend/requirements.txt backend/requirements-ocr.txt ./ RUN --mount=type=cache,target=/root/.cache/pip \ set -eux; \ - PIP_ARGS="--no-cache-dir --retries 10 --timeout 60"; \ + PIP_ARGS="--retries ${PIP_RETRIES} --timeout ${PIP_TIMEOUT}"; \ if [ -n "${PIP_INDEX_URL:-}" ]; then \ PIP_ARGS="$PIP_ARGS --index-url ${PIP_INDEX_URL}"; \ fi; \ diff --git a/docker-compose.yml b/docker-compose.yml index 35421fe9..b9ea3bf2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -26,6 +26,8 @@ services: PYTHON_BASE_IMAGE: ${PYTHON_BASE_IMAGE:-python:3.12-slim-bookworm} PIP_INDEX_URL: ${PIP_INDEX_URL:-https://mirrors.aliyun.com/pypi/simple} PIP_EXTRA_INDEX_URL: ${PIP_EXTRA_INDEX_URL:-} + PIP_TIMEOUT: ${PIP_TIMEOUT:-300} + PIP_RETRIES: ${PIP_RETRIES:-15} container_name: hxops-backend restart: always # 与 scripts/deploy_compose.sh 使用的 .env. 对齐(通过 COMPOSE_ENV_BASENAME) @@ -96,6 +98,8 @@ services: PYTHON_BASE_IMAGE: ${PYTHON_BASE_IMAGE:-python:3.12-slim-bookworm} PIP_INDEX_URL: ${PIP_INDEX_URL:-https://mirrors.aliyun.com/pypi/simple} PIP_EXTRA_INDEX_URL: ${PIP_EXTRA_INDEX_URL:-} + PIP_TIMEOUT: ${PIP_TIMEOUT:-300} + PIP_RETRIES: ${PIP_RETRIES:-15} container_name: hxops-kb-worker restart: always command: ["python", "worker_kb.py"] @@ -151,6 +155,8 @@ services: PYTHON_BASE_IMAGE: ${PYTHON_BASE_IMAGE:-python:3.12-slim-bookworm} PIP_INDEX_URL: ${PIP_INDEX_URL:-https://mirrors.aliyun.com/pypi/simple} PIP_EXTRA_INDEX_URL: ${PIP_EXTRA_INDEX_URL:-} + PIP_TIMEOUT: ${PIP_TIMEOUT:-300} + PIP_RETRIES: ${PIP_RETRIES:-15} container_name: hxops-schedule-worker restart: always command: ["python", "workers/worker_scheduler.py"] @@ -199,6 +205,8 @@ services: PYTHON_BASE_IMAGE: ${PYTHON_BASE_IMAGE:-python:3.12-slim-bookworm} PIP_INDEX_URL: ${PIP_INDEX_URL:-https://mirrors.aliyun.com/pypi/simple} PIP_EXTRA_INDEX_URL: ${PIP_EXTRA_INDEX_URL:-} + PIP_TIMEOUT: ${PIP_TIMEOUT:-300} + PIP_RETRIES: ${PIP_RETRIES:-15} container_name: hxops-shipping-worker restart: always command: ["python", "worker_shipping.py"] @@ -249,6 +257,8 @@ services: PYTHON_BASE_IMAGE: ${PYTHON_BASE_IMAGE:-python:3.12-slim-bookworm} PIP_INDEX_URL: ${PIP_INDEX_URL:-https://mirrors.aliyun.com/pypi/simple} PIP_EXTRA_INDEX_URL: ${PIP_EXTRA_INDEX_URL:-} + PIP_TIMEOUT: ${PIP_TIMEOUT:-300} + PIP_RETRIES: ${PIP_RETRIES:-15} container_name: hxops-transfer-worker restart: always command: ["python", "workers/worker_in_transit_transfer.py"] From 9c7776b5cb706b4e87efb95e869dae16b62902d7 Mon Sep 17 00:00:00 2001 From: caohuipeng Date: Sun, 27 Sep 2026 22:43:48 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix(shipping-notice):=20=E5=BA=93=E5=AD=98?= =?UTF-8?q?=20RPA=20=E5=9B=9E=E8=B0=83=20source=5Frun=5Fno=20=E5=88=97?= =?UTF-8?q?=E5=8A=A0=E5=AE=BD=E5=88=B0=20128?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - shipping_task_inventory_rpa_attempts.source_run_no 64→128,与模型 String(128) 对齐;RPA Worker 回传编号由源系统/仓库/厂商等外部段拼装、长度不受后端控制, 65 字符组合超 64 上限致库存准备门禁 Attempt 终态失败(2026-09-27 test 8878) - 补齐历史欠账:gw4d5e6f7g8h 仅做 run_no→source_run_no 改名漏了加宽 - downgrade 收窄前须确认无 >64 长度行,不做静默截断(截断破坏回关联) --- ...b2c3d_widen_inventory_rpa_source_run_no.py | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 backend/migrations/versions/we9f0a1b2c3d_widen_inventory_rpa_source_run_no.py diff --git a/backend/migrations/versions/we9f0a1b2c3d_widen_inventory_rpa_source_run_no.py b/backend/migrations/versions/we9f0a1b2c3d_widen_inventory_rpa_source_run_no.py new file mode 100644 index 00000000..a105058c --- /dev/null +++ b/backend/migrations/versions/we9f0a1b2c3d_widen_inventory_rpa_source_run_no.py @@ -0,0 +1,49 @@ +"""Widen inventory RPA attempts.source_run_no to 128. + +Revision ID: we9f0a1b2c3d +Revises: wd7e8f9a0b1c +Create Date: 2026-09-27 00:00:00.000000 + +用途:shipping_task_inventory_rpa_attempts.source_run_no 由 varchar(64) 加宽到 +varchar(128),与模型 String(128) 对齐。 +依赖:shipping_task_inventory_rpa_attempts 表(含 uq_shipping_task_inv_rpa_triplet +唯一约束,覆盖 task_no/source_code/source_run_no 三列)。 +逻辑:RPA Worker 回传的 source_run_no 由源系统/仓库/厂商/尝试序号等外部段拼装, +长度不受后端控制(2026-09-27 test:65 字符的 PSR 组合超 64 上限,门禁 Attempt +以 StringDataRightTruncation 终态失败,Gate 收口为 blocked_retryable)。历史迁移 +gw4d5e6f7g8h 仅做了 run_no→source_run_no 改名、漏了加宽,本迁移补齐。 + +注意:downgrade 收窄前须确认不存在长度 >64 的行,否则将失败(不做静默截断, +标识符截断会破坏与 RPA Worker 的精确回关联)。 +""" + +from __future__ import annotations + +from alembic import op +import sqlalchemy as sa + + +revision = "we9f0a1b2c3d" +down_revision = "wd7e8f9a0b1c" +branch_labels = None +depends_on = None + + +def upgrade() -> None: + op.alter_column( + "shipping_task_inventory_rpa_attempts", + "source_run_no", + existing_type=sa.String(length=64), + type_=sa.String(length=128), + existing_nullable=False, + ) + + +def downgrade() -> None: + op.alter_column( + "shipping_task_inventory_rpa_attempts", + "source_run_no", + existing_type=sa.String(length=128), + type_=sa.String(length=64), + existing_nullable=False, + )