Files
Nexus/docs/changelog/2026-06-08-batch-detect-path-server-name.md
T

39 lines
1.6 KiB
Markdown
Raw Normal View History

# 2026-06-08 批量检测目标路径 — 服务器名称与并发 Session 修复
## 摘要
修复「自动检测目标路径」等批量 SSH 操作结果弹窗显示 `#164` 而非服务器全名的问题;消除并行任务共用 `AsyncSession` 导致的 `isce` / `readexactly` 错误。
## 动机
- 批量 `detect-path` / install / upgrade / uninstall 在 `asyncio.gather` 内并发调用 `service.get_server()``db.commit()`,触发 SQLAlchemy `This session is provisioning a new connection; concurrent operations are not permitted`
- 异常发生在读取 `server.name` 之前时 `server_name` 为空,前端回退为 `#${server_id}`
## 涉及文件
- `server/api/servers.py``_prefetch_batch_servers`、独立 Session 写库、`_batch_server_display_name`
- `frontend/src/components/servers/BatchAgentResultDialog.vue` — 移除 `#id` 回退
- `tests/test_batch_server_display_name.py`
## 行为
1. 批量操作前一次性 `get_by_ids` 预取服务器
2. 并行阶段仅 SSH,写库使用独立 `AsyncSessionLocal`
3. 结果始终带完整 `server_name`name → domain →「未知服务器」)
## 迁移/重启
- 需重启 API / 重建镜像
## 验证
```bash
pytest tests/test_batch_server_display_name.py -q
# 跨页多选 → 检测目标路径 → 弹窗每台显示完整公司/站点名(非 #id)
```
## 2026-06-08 补充(名称仍缺失)
- 预取后立即固化 `labels` dict,不等到并行任务内再读 ORM
- 前端 `enrichBatchAgentResults`API `server_name` 为空时用列表页已加载的 `name` 补全(表格勾选仅存 ID