- Add ActionBar component with expandable toolbar for mobile - Add @mention functionality with autocomplete dropdown - Add browser notification system (push, sound, vibration) - Add NotificationSettings modal for user preferences - Add mention badges on room list cards - Add ReportPreview with Markdown rendering and copy/download - Add message copy functionality with hover actions - Add backend mentions field to messages with Alembic migration - Add lots field to rooms, remove templates - Optimize WebSocket database session handling - Various UX polish (animations, accessibility) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1.1 KiB
1.1 KiB
Change: Optimize WebSocket Database Sessions for Production
Status: ✅ COMPLETED - Ready for archive
Why
目前 WebSocket 連線在整個生命週期中持有單一資料庫 Session,造成連線池快速耗盡。當 50+ 用戶同時在線時,15 個連線池容量無法支撐,導致資料庫操作阻塞或失敗。此外,sequence_number 的計算存在競爭條件,可能導致訊息順序錯誤。
What Changes
- BREAKING: 移除 WebSocket 連線的長期 Session 持有模式
- 改用短期 Session 模式:每次 DB 操作獨立取得連線
- 增加連線池容量配置(可透過環境變數調整)
- 修復 sequence_number 競爭條件(使用資料庫層級鎖定)
- 新增環境變數支援動態調整連線池參數
Impact
- Affected specs: realtime-messaging
- Affected code:
app/core/database.py- 連線池配置app/core/config.py- 新增環境變數app/modules/realtime/router.py- WebSocket Session 管理app/modules/realtime/services/message_service.py- Sequence 鎖定.env.example- 新增配置說明.env- 同步更新目前使用的環境變數檔案