# RNS1.1 E2E 测试 — FDW 直连改造 + performance_service bug 修复 > 日期:2026-03-18 > 触发:RNS1.1 端到端测试发现 postgres_fdw 不传递自定义 GUC 参数 ## 变更概述 ### 1. fdw_queries.py — FDW → 直连 ETL 库(架构变更) **根因**:`postgres_fdw` 不传递自定义 GUC 参数(`app.current_site_id`)到远端连接,导致 ETL 库的 RLS 视图 `current_setting('app.current_site_id')` 在远端未设置而报错。 **方案**:`_fdw_context()` 改为通过 `get_etl_readonly_connection(site_id)` 直连 ETL 库,在同一连接上 `SET LOCAL app.current_site_id`,然后查询 `app.v_*` RLS 视图。 **影响**: - 所有 SQL 表引用从 `fdw_etl.v_*` 改为 `app.v_*` - `conn` 参数保留(调用方仍需它查 `biz.*` 表),但 ETL 查询使用独立连接 - ETL 连接在 `_fdw_context` yield 后自动关闭 ### 2. performance_service.py — 两个 bug 修复 **Bug A**:`_build_customer_lists()` 残留 `fdw_etl.v_dwd_assistant_service_log` 引用 + 错误列名 - `fdw_etl.v_dwd_assistant_service_log` → `app.v_dwd_assistant_service_log` - `member_id` → `tenant_member_id` - `assistant_id` → `site_assistant_id` - `is_trash = false` → `is_delete = 0`(RLS 视图基于 dwd_assistant_service_log 基表,用 is_delete 整数) - `settle_time` → `create_time` **Bug B**:`get_overview()` 查询不存在的表/列 - `auth.sites` 表不存在 → 移除 LEFT JOIN - `users.display_name` → `users.nickname` - `uab.role_label` → `uab.binding_type` ## 验证 E2E 测试脚本 `scripts/ops/e2e_test_rns1.py`,4/4 接口通过: - TASK-1 任务列表 ✅ - TASK-2 任务详情 ✅(列表为空,跳过) - PERF-1 绩效概览 ✅ - PERF-2 绩效明细 ✅ ## 受影响文件 | 文件 | 变更类型 | |------|----------| | `apps/backend/app/services/fdw_queries.py` | 架构变更:FDW → 直连 ETL | | `apps/backend/app/services/performance_service.py` | Bug 修复:SQL 表名/列名 | | `docs/architecture/backend-architecture.md` | 文档同步 | | `scripts/ops/e2e_test_rns1.py` | 新增 E2E 测试脚本 | ## 已知遗留 以下文件仍有 `fdw_etl.` 引用,但不在本次 E2E 测试范围内,需后续修复: - `apps/backend/app/services/task_manager.py` - `apps/backend/app/services/task_generator.py` - `apps/backend/app/services/recall_detector.py` - `apps/backend/app/services/matching.py`