I just noticed a bug on the site.

When someone replies to one of your messages and then deletes the reply, the deleted message won't appear on the messages page (obviously) but it gets taken into consideration for the new messages notification.

Therefore, the displayed number of new messages is wrong because it takes into account the deleted ones too even if they're not available anymore.

Example:
As you can see from the picture, there are only two new messages available, but three new messages reported.

View attached image.
7 years ago

Comment has been collapsed.

Deleted

This comment was deleted 4 years ago.

7 years ago
Permalink

Comment has been collapsed.

Don't ask me, I'm just linking the related announcement.

7 years ago
Permalink

Comment has been collapsed.

If it's of any interest, for a solution suggestion you can read this comment.

7 years ago
Permalink

Comment has been collapsed.

I think I know why. If the user resets his unread messages, then he receives some more new messages but some of the old replies to his messages get deleted, the number gets subtracted from his new messages and the value would be incorrect.

This can be easily solved by also storing in the cache the last reset date and decrementing the cache depending on the last reset date.

So, if the last reset date for userX is an hour ago and userY deletes his reply to userX from yesterday the cache is not decremented for userX. But if the same userY deletes the message he posted as a reply to userX after the last reset date for userX, the cache gets decremented by one for userX.

I'll simply ignore the negligible race condition that can appear due to non-atomic execution.

But, all in all, that fixes the problem without having any overhead.

7 years ago
Permalink

Comment has been collapsed.

Deleted

This comment was deleted 4 years ago.

7 years ago
Permalink

Comment has been collapsed.

My understanding is cg tried to avoid cross-checking with the db and did it at the cache level. When userX gets a message, the cache field for userX gets incremented by one. When userX marks his messages as read, his unread messages cache field gets reset.
So this bypasses the database completely but only when checking how many unread messages userX has, when the value is taken from cache instead of the database.

7 years ago
Permalink

Comment has been collapsed.

Deleted

This comment was deleted 4 years ago.

7 years ago
Permalink

Comment has been collapsed.

You might want to post that into the announcement thread

Good idea. Posted a link into the announcement thread as well.

7 years ago
Permalink

Comment has been collapsed.

So it was a deliberate choice. Thanks for pointing out that thread.

7 years ago
Permalink

Comment has been collapsed.

And does it really matter that much? I always thought it was kind of useful actually.

7 years ago
Permalink

Comment has been collapsed.

caught!

7 years ago
Permalink

Comment has been collapsed.

lol what for? :D

7 years ago
Permalink

Comment has been collapsed.

Knowing someone replied to you. :P
Also this is a trap reply.

7 years ago
Permalink

Comment has been collapsed.

View attached image.
7 years ago
Permalink

Comment has been collapsed.

Are you sure it's not a rap reply? :\

7 years ago
Permalink

Comment has been collapsed.

Sign in through Steam to add a comment.