11

There's a particular answer giving me a weird bug. I see a "show 1 more comment" link beneath it:

"show 1 more comment"

But when I click that link no comments actually show up:

blank comment section

This happens even after I refresh, and I can keep refreshing and keep doing it, so this isn't merely because the comment vanished between me loading the page and hitting the button. There's genuinely some phantom comment bugging out the system.

  • 4
    I have the same problem with this post – Ælis Dec 18 '18 at 16:53
  • 2
    Hmm I saw it too, after I deleted some comments there. I just dismissed it as caching, but apparently not! It's still there, for me too, even on another device. – Tinkeringbell Dec 18 '18 at 16:57
11

The number of comments on a post is denormalized, stored as a simple integer attached to the post itself. This is updated when comments are added or deleted, but the update isn't atomic - that is, the count can become inaccurate if two of those actions happen at very nearly the same time:

  • deletion #1: retrieve comment count (2 comments)
  • deletion #2: retrieve comment count (2 comments)
  • deletion #1: delete 1st comment
  • deletion #2: delete 2nd comment
  • deletion #1: set CommentCount to retrieved count -1 (1 comment)
  • deletion #2: set CommentCount to retrieved count -1 (1 comment)

At the end of both deletions in this scenario, both comments on the post are gone... But the CommentCount is still set to 1, because both deletions each thought there was still 1 comment remaining.

This scenario is a bit contrived - the actual logic is slightly less prone to this mistake. But, it can still happen; to correct for this, there's a script that runs daily which counts all comments on all posts and corrects the saved CommentCount for those posts where it is inaccurate. This script last ran slightly more than 15 hours ago; the count on that post became inaccurate about 4 hours ago... So it would've fixed itself in a bit less than 9 hours.

But, there's a quicker fix: just add a comment. Adding a comment re-counts all the comments currently on the post and updates the stored count. I've done this (and then deleted the new comment), thus ensuring that the count is now accurate and no phantom comment is hinted at.

  • 1
    Does this script consider deleted posts as well? Like when comments are removed from deleted posts or a post is deleted after deleting comments but before that script runs. – A J Dec 19 '18 at 7:21
  • 1
    No, @aj - though this rarely matters. Somewhat more problematic is the score correction script, which exhibits the same reluctance to touch deleted posts; this can occasionally require manual intervention if votes on deleted posts are invalidated. – Shog9 Dec 19 '18 at 7:47
  • 1
    Oh. I just asked this because if this script did consider deleted posts, this same issue wouldn't be occurring here. – A J Dec 20 '18 at 7:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .