'If a user has experienced drift in their inbox counts, correct it.
A small percentage (~0.2%) of users are seeing drift in their inbox
counts (presumably because _incr is experiencing rare failures). If the
user has no unread messages in their inbox currently, this will repair
that drift and log it. Yes, this is a hack.'

def _verify_inbox_count(self, kept_msgs):

    if g.disallow_db_writes:
        return
    if ((not len(kept_msgs)) and (c.user.inbox_count != 0)):
        g.log.info('Fixing    inbox    drift    for    %r.    Kept    msgs:    %d.    Inbox_count:    %d.', c.user, len(kept_msgs), c.user.inbox_count)
        g.stats.simple_event('inbox_counts.drift_fix')
        c.user._incr('inbox_count', (- c.user.inbox_count))
