Ai_GirlFriend/xuniYou/问题解决-表名前缀.md
2026-03-02 18:57:11 +08:00

133 lines
2.8 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 问题解决:数据库表名前缀
## 问题原因
数据库中的实际表名是 `nf_generation_tasks`(带 `nf_` 前缀),但查询时使用了 `generation_task`(无前缀)。
## 错误信息
```
1146 - Table 'fastadmin.generation_task' doesn't exist
```
## 正确的表名
根据代码和数据库结构:
- 实际表名:`nf_generation_tasks`
- 模型定义:`lover/models.py` 中 `__tablename__ = "nf_generation_tasks"`
## 正确的SQL查询
### 查询任务详情
```sql
SELECT
id,
user_id,
lover_id,
status,
error_msg,
JSON_PRETTY(payload) as payload_detail,
created_at,
updated_at
FROM nf_generation_tasks
WHERE id = 382;
```
### 查询最近的失败任务
```sql
SELECT
id,
user_id,
lover_id,
task_type,
status,
error_msg,
created_at,
updated_at
FROM nf_generation_tasks
WHERE task_type = 'video'
AND status = 'failed'
ORDER BY id DESC
LIMIT 10;
```
### 查询任务382附近的任务
```sql
SELECT
id,
user_id,
lover_id,
task_type,
status,
error_msg,
created_at
FROM nf_generation_tasks
WHERE id BETWEEN 380 AND 390
ORDER BY id;
```
### 查询所有视频任务的统计
```sql
SELECT
status,
COUNT(*) as count,
MAX(created_at) as last_time
FROM nf_generation_tasks
WHERE task_type = 'video'
GROUP BY status;
```
## 从数据库导出看到的信息
根据数据库导出文件,最近的任务记录:
- 最大ID380AUTO_INCREMENT=381
- 任务类型image, video, outfit, voice
- 视频任务对应唱歌功能
## 实际情况
从数据库导出可以看到:
- 任务262-264失败错误信息 "Input data may contain inappropriate content."(内容安全审核失败)
- 任务268, 270成功但标记了 `content_safety_blocked: true`
- 任务272-305大部分成功
## 常见失败原因
### 1. 内容安全审核失败
错误信息:`Input data may contain inappropriate content.`
这是阿里云DashScope的内容安全机制可能原因
- 歌词内容敏感
- 人物形象不合规
- 音频内容触发审核
解决方案:
- 更换其他歌曲
- 检查恋人形象
- 联系阿里云客服了解具体原因
### 2. 任务不存在ID 382
从数据库看最大任务ID是380所以任务382确实不存在。可能
- 截图中的382是其他系统的ID
- 或者是前端显示的临时ID
## 下一步操作
1. 使用正确的表名查询数据库
2. 查看最近的失败任务262-264, 266
3. 了解内容安全审核的具体原因
4. 如需重试,使用重试接口
## 重试失败任务的SQL
```sql
-- 查看失败任务的详细信息
SELECT
id,
JSON_PRETTY(payload) as payload,
error_msg
FROM nf_generation_tasks
WHERE id IN (262, 263, 264, 266)
AND status = 'failed';
```