🚨 故障排除分享:通知頁面 EntityNotFoundError
中文版
近期發現 Sharkey 通知頁面出現 EntityNotFoundError,前端「重試」無效。
💡 根本原因:Redis 與 PostgreSQL 資料不同步,常見於容器重啟或高併發下 note 刪除與通知創建競態。
簡單排查步驟:
檢查資料庫孤立引用
SELECT COUNT(*) FROM note n LEFT JOIN note r ON n."replyId" = r.id WHERE n."replyId" IS NOT NULL AND r.id IS NULL;
檢查 Redis 通知快取
redis-cli KEYS notificationTimeline:*
建議修復:清理孤立引用、刷新 Redis 快取、重啟服務。
預防措施:啟用 Redis 持久化、優雅關閉容器、定期檢查日誌。
English Version
Recently, Sharkey’s notification page showed EntityNotFoundError, making the frontend "Retry" button ineffective.
💡 Root cause: Redis and PostgreSQL are out of sync, usually triggered by container restarts or race conditions between note deletion and notification creation.
Quick check steps:
Check orphaned references in the database
SELECT COUNT(*) FROM note n LEFT JOIN note r ON n."replyId" = r.id WHERE n."replyId" IS NOT NULL AND r.id IS NULL;
Inspect Redis notification cache
redis-cli KEYS notificationTimeline:*
Recommended fix: Remove orphaned references, clear Redis cache, restart service.
Prevention: Enable Redis persistence, gracefully stop containers, monitor logs regularly.
日本語版
最近、Sharkey の通知ページで EntityNotFoundError が発生し、フロントの「再試行」ボタンが効かない問題を確認。
💡 原因:Redis と PostgreSQL のデータが同期せず、コンテナ再起動や note 削除と通知作成の競合で発生。
簡単な確認手順:
データベースの孤立参照を確認
SELECT COUNT(*) FROM note n LEFT JOIN note r ON n."replyId" = r.id WHERE n."replyId" IS NOT NULL AND r.id IS NULL;
Redis 通知キャッシュを確認
redis-cli KEYS notificationTimeline:*
修復方法: 孤立参照の削除、Redis キャッシュのクリア、サービス再起動
予防策: Redis 永続化の有効化、コンテナの安全停止、ログの定期監視
#Sharkey #Misskey #Mastodon #TechNews #Redis #PostgreSQL #DevelopersLife #開發者日常 #技術觀察 #テックニュース #tech