Open zotanmew opened 1 year ago
This repeatedly occurred on my instance with under ten active users and is completely breaking the timeline :/
Manual fix is executing delete from note where "replyId" = '9a9mqnudl5';
(replacing the id with the affected missing note) on the postgres database
This query deletes all affected notes, restoring old behavior. However, this isn't exactly a fix, so I'll leave the issue open for now
DELETE
FROM "note" l
WHERE
"replyId" IS NOT NULL
AND
NOT EXISTS (
SELECT "id"
FROM "note"
WHERE "id" = l."replyId"
)
;
We basically need a migration like this: ALTER TABLE "note" ADD CONSTRAINT "FK_temp_reply_fix_zotan" FOREIGN KEY ("replyId") REFERENCES "note"("id") ON DELETE CASCADE ON UPDATE NO ACTION;
, though that only works after spamming the query mentioned above til it responds DELETE 0 (on every pass it deletes one more note in a reply chain, the replies of which then become orphaned. I'm not good enough at (Postgre)SQL to write a query that will cascade that deletion process, but I'm sure it's possible.
I had to create two indices to get the server load down, though the second might be unrelated.
CREATE INDEX "IDX_temp_reply_fix_zotan" ON "note" ("replyId");
CREATE INDEX "IDX_temp_reply_fix_zotan_perf_optimiz" ON "note" ("uri");
Another possible solution would be keeping those root-less notes, and only to display a warning to users viewing the note that the root note is deleted. Not sure whether way is the one that Mastodon uses.
💡 Summary
Replies of deleted notes are no longer automatically deleted, causing timeline errors
🥰 Expected Behavior
Either replyId of replies should be set to null, or replies should also be deleted (previous behavior)
🤬 Actual Behavior
When a note with replies is deleted, timeline shows an error occured, log shows
📝 Steps to Reproduce
📌 Environment
Misskey version: 13.1.0 Your OS: Arch linux Your browser: Chrome latest stable