返回 Bug 清单
BUG-1411project-13高已修复backend-config

Flyway migration 未初始化 → knowledge_vectors 表不存在 → PostgreSQL 事务 aborted

发现:2026-10-27验证:2026-10-27置信度:85%

症状

Companion 陪练发消息 500 Internal Server Error;Spring Boot 日志里 knowledge_vectors does not exist + current transaction is aborted;同一 @Transactional 方法里其他正常表的查询也一起挂

根因

Flyway schema_history 表从未创建(Flyway migration 完全没跑过),knowledge_vectors 表是 Flyway V1.2 pgvector migration 手动创建的,不在 JPA Entity 里,Hibernate DDL auto=update 不会建。CompanionTutorService.sendMessage @Transactional 内调 isVectorEngineAvailable 查 knowledge_vectors → 表不存在 → PostgreSQL 把整个事务标为 aborted → 后续同事务内所有 SQL(包括 dkt_knowledge_state 查询)都报 25P02

修复方案

1) 直接在 PostgreSQL 里手动 CREATE TABLE knowledge_vectors(用 V1.2 compat JSONB 版本,无需 pgvector 扩展)+ 索引 + 唯一约束;2) JsonbVectorSearchService.isVectorEngineAvailable 加 @Transactional(propagation=REQUIRES_NEW) 让表不存在时的 SQL error 不污染外层事务(双保险)

错误签名

ERROR: relation "knowledge_vectors" does not exist; ERROR: current transaction is aborted, commands ignored until end of transaction block

技术信息

来源项目

project-13

涉及文件

backend/src/main/java/com/project-13/service/vector/JsonbVectorSearchService.java

标签

project-13, mcp-reported, source-agent