Resetting "open issue" counters

67 views
Skip to first unread message

Alexey Neyman

unread,
Sep 22, 2014, 4:30:42 PM9/22/14
to revie...@googlegroups.com
Hi all,

We have just upgraded our installation of RB to 2.0.7. One nice new feature is that the dashboard now displays the number of open issues in a review request.

However, I have noticed that the counters don't seem to be accurate in some request. For example, one of the review requests has 4 reviews with ship-its, with 2 of them making a comment on the code which were not marked as issues. Yet, the status displayed in the dashboard is "1 open issue". I verified this in admin/database/review requests, and this review request is indeed recorded as having "ship-it count: 4" and "open issue count: 1".

I am not sure if this was a 1.7 bug, or if it was caused by the upgrade  - the request and some of the reviews were submitted before the RB upgrade. However, I am not sure if the rest of the counters are valid - going through all the requests and verifying them manually is obviously a lot of work. So, is there a way to make RB recalculate these counters - like it was with the dashboard counters and the "rb-site manage /path/to/site fixreviewcounts" command?

As a side note, it seems that the 'rb-site --help' message does not mention the 'manage' command at all. Is it intentional or an oversight?

Regards,
Alexey.

Stephen Gallagher

unread,
Sep 22, 2014, 4:51:00 PM9/22/14
to revie...@googlegroups.com
On 09/22/2014 04:30 PM, Alexey Neyman wrote:
> Hi all,
>
> We have just upgraded our installation of RB to 2.0.7. One nice new
> feature is that the dashboard now displays the number of open issues in
> a review request.
>
> However, I have noticed that the counters don't seem to be accurate in
> some request. For example, one of the review requests has 4 reviews with
> ship-its, with 2 of them making a comment on the code which were not
> marked as issues. Yet, the status displayed in the dashboard is "1 open
> issue". I verified this in admin/database/review requests, and this
> review request is indeed recorded as having "ship-it count: 4" and "open
> issue count: 1".
>

I've hit the same bug on one of my deployments, but I haven't been able
to reproduce it yet.


> I am not sure if this was a 1.7 bug, or if it was caused by the upgrade
> - the request and some of the reviews were submitted before the RB
> upgrade. However, I am not sure if the rest of the counters are valid -
> going through all the requests and verifying them manually is obviously
> a lot of work. So, is there a way to make RB recalculate these counters
> - like it was with the dashboard counters and the "rb-site manage
> /path/to/site fixreviewcounts" command?
>
> As a side note, it seems that the 'rb-site --help' message does not
> mention the 'manage' command at all. Is it intentional or an oversight?
>
> Regards,
> Alexey.
>
> --
> Get the Review Board Power Pack at http://www.reviewboard.org/powerpack/
> ---
> Sign up for Review Board hosting at RBCommons: https://rbcommons.com/
> ---
> Happy user? Let us know at http://www.reviewboard.org/users/
> ---
> You received this message because you are subscribed to the Google
> Groups "reviewboard" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to reviewboard...@googlegroups.com
> <mailto:reviewboard...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.

Christian Hammond

unread,
Sep 22, 2014, 5:00:30 PM9/22/14
to revie...@googlegroups.com
I would love a repro case for this. I've seen a couple of reports, and have tried desperately to reproduce it, with no luck. The code is fairly straightforward in how it counts the initial values.

Christian
To unsubscribe from this group and stop receiving emails from it, send an email to reviewboard...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.


--
--
Christian Hammond - chi...@chipx86.com
Review Board - http://www.reviewboard.org

Alexey Neyman

unread,
Sep 22, 2014, 6:09:44 PM9/22/14
to revie...@googlegroups.com

Christian,

Meanwhile, is it possible to have a rb-site manage subcommand to recalculate these counters?

Thanks,
Alexey.

> You received this message because you are subscribed to a topic in the Google Groups "reviewboard" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/reviewboard/LKmrIXZGuDI/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to reviewboard...@googlegroups.com.

Christian Hammond

unread,
Sep 22, 2014, 7:15:23 PM9/22/14
to revie...@googlegroups.com, Alexey Neyman
Hi Alexey,

That's something we can get in.

As for the manage command, it's just an oversight.

Christian

--
Christian Hammond - chri...@beanbaginc.com
Review Board - https://www.reviewboard.org
Beanbag, Inc. - https://www.beanbaginc.com


On September 22, 2014 at 3:09:41 PM, Alexey Neyman (alexey...@gmail.com) wrote:
> Christian,
>
> Meanwhile, is it possible to have a rb-site manage subcommand to
> recalculate these counters?
>
> Thanks,
> Alexey.

Christian Hammond

unread,
Sep 23, 2014, 7:21:28 PM9/23/14
to revie...@googlegroups.com, Alexey Neyman
Do you happen to have a database backup prior to the upgrade? I'd love to try with a real before/after.

Christian

--
Christian Hammond - chri...@beanbaginc.com
Review Board - https://www.reviewboard.org
Beanbag, Inc. - https://www.beanbaginc.com


Christian Hammond

unread,
Sep 23, 2014, 7:29:58 PM9/23/14
to revie...@googlegroups.com, Alexey Neyman
Oh, regarding the "fix the counts" script, I can write one, but it's very unlikely to matter, I realized. It's just going to trigger the exact same logic that's triggered when viewing the review request for the first time, post-upgrade. If it got it wrong before, I don't have much reason to believe it'll get it right the next time.

I'll have to fix the bug properly. For that, I'll probably need a before/after or a solid repro case.

Christian

--
Christian Hammond - chri...@beanbaginc.com
Review Board - https://www.reviewboard.org
Beanbag, Inc. - https://www.beanbaginc.com


Christian Hammond

unread,
Sep 24, 2014, 1:28:57 PM9/24/14
to revie...@googlegroups.com, Alexey Neyman
Hey,

2.0.8 contains a new reset-issue-counts management command that can be used. I takes a list of IDs, or --all to reset all review requests. Issue counts will be recalculated on next access.

It can also provide debug info about the calculations. Can you find one of the miscalculated review requests and run:

    rb-site manage /path/to/site reset-issue-counts -- -verbosity=2 --recalculate <id>

See if the counts are right and then paste the debug output from that command. It'll help me get a sense of what's going wrong (hopefully).

(Also, I added basic --help output to rb-site for the "manage" command.)

Christian

--
Christian Hammond - chri...@beanbaginc.com
Review Board - https://www.reviewboard.org
Beanbag, Inc. - https://www.beanbaginc.com


Alexey Neyman

unread,
Sep 24, 2014, 3:40:14 PM9/24/14
to Christian Hammond, revie...@googlegroups.com
Hi Christian,

Just upgraded to 2.0.8:

[[[
bash-4.1# rb-site manage /var/www.reviewboard reset-issue-counts --recalculate --verbosity=2 2050
Usage: rb-site command [options] path

rb-site: error: no such option: --recalculate
bash-4.1# rb-site --version
rb-site 2.0.8
]]]

BTW, release notes for 2.0.8 seem to omit the 'manage' argument from the command line:

rb-site <path> reset-issue-counts --recalculate --verbosity=2 <id>

Also, the usage in --help message is wrong: it suggests to use 'rb-site <path> manage command' - while the correct order is 'rb-site manage <path> command'.

Regards,
Alexey.


Christian Hammond

unread,
Sep 24, 2014, 3:42:01 PM9/24/14
to Alexey Neyman, revie...@googlegroups.com
Thanks, I'll fix the release notes.

Make sure to put a -- before any --arguments, like:

    rb-site manage /var/www/reviewboard reset-issue-counts -- --verbosity=2 --recalculate

Not sure what you mean by the help output being wrong though?

Christian

--
Christian Hammond - chri...@beanbaginc.com
Review Board - https://www.reviewboard.org
Beanbag, Inc. - https://www.beanbaginc.com


On September 24, 2014 at 12:40:11 PM, Alexey Neyman (alexey...@gmail.com) wrote:
> Hi Christian,
>
> Just upgraded to 2.0.8:
>
> [[[
> bash-4.1# rb-site manage /var/www.reviewboard reset-issue-counts
> --recalculate --verbosity=2 2050
> Usage: rb-site command [options] path
>
> rb-site: error: no such option: --recalculate
> bash-4.1# rb-site --version
> rb-site 2.0.8
> ]]]
>
> BTW, release notes for 2.0.8 seem to omit the 'manage' argument from the
> command line:
>
> rb-site reset-issue-counts --recalculate --verbosity=2
>
> Also, the usage in --help message is wrong: it suggests to use 'rb-site
> manage command' - while the correct order is 'rb-site manage
> command'.
>
> Regards,
> Alexey.
>
>
>
> On Wed, Sep 24, 2014 at 10:28 AM, Christian Hammond <
> chri...@beanbaginc.com> wrote:
>
> > Hey,
> >
> > 2.0.8 contains a new reset-issue-counts management command that can be
> > used. I takes a list of IDs, or --all to reset all review requests. Issue
> > counts will be recalculated on next access.
> >
> > It can also provide debug info about the calculations. Can you find one of
> > the miscalculated review requests and run:
> >
> > rb-site manage /path/to/site reset-issue-counts -- -verbosity=2
> > --recalculate
> >

Alexey Neyman

unread,
Sep 24, 2014, 3:44:19 PM9/24/14
to Christian Hammond, revie...@googlegroups.com
Figured it out, needs -- to have --recalculate argument applied to 'reset-issue-counts' rather than rb-site itself.

Here is the output:

DEBUG:root:Calculated issue counts for review request ID 2050 across 5 review(s): Resulting counts = {u'R': 0, u'D': 0, u'O': 1}; DB values = [{u'screenshot_comments__issue_status': None, u'file_attachment_comments__pk': None, u'screenshot_comments__pk': None, u'comments__pk': None, u'comments__issue_status': None, u'file_attachment_comments__issue_status': None}, {u'screenshot_comments__issue_status': None, u'file_attachment_comments__pk': None, u'screenshot_comments__pk': None, u'comments__pk': 8194L, u'comments__issue_status': None, u'file_attachment_comments__issue_status': None}, {u'screenshot_comments__issue_status': None, u'file_attachment_comments__pk': None, u'screenshot_comments__pk': None, u'comments__pk': 8199L, u'comments__issue_status': u'O', u'file_attachment_comments__issue_status': None}, {u'screenshot_comments__issue_status': None, u'file_attachment_comments__pk': None, u'screenshot_comments__pk': None, u'comments__pk': None, u'comments__issue_status': None, u'file_attachment_comments__issue_status': None}, {u'screenshot_comments__issue_status': None, u'file_attachment_comments__pk': None, u'screenshot_comments__pk': None, u'comments__pk': None, u'comments__issue_status': None, u'file_attachment_comments__issue_status': None}]; Field IDs = {u'screenshot_comments': set([None]), u'comments': set([None, 8194L, 8199L]), u'file_attachment_comments': set([None])}
Issue counts for review request(s) 2050 reset.

However, this review request still shows 1 open issue and there are no issues raised in any of the reviews - there is even no 'issue summary' block at the bottom of this request.

Regards,
Alexey.

Alexey Neyman

unread,
Sep 24, 2014, 3:45:49 PM9/24/14
to Christian Hammond, revie...@googlegroups.com
Re help: the order of the 'manage' and <path> arguments is swapped.

Correct order: rb-site manage <path>
Help message: rb-site <path> manage

Regards,
Alexey.

Christian Hammond

unread,
Sep 24, 2014, 3:47:08 PM9/24/14
to revie...@googlegroups.com, Alexey Neyman, revie...@googlegroups.com
Thanks for the debug info!

Yeah, as I mentioned in an earlier reply, a reset command will *not* fix the problem, because the calculation is broken. Best I could do is to get this command in to reset and provide debug information, so that I can hopefully figure out the cause. I'll look into what the output below says and see if I can figure this out.

Christian

--
Christian Hammond - chri...@beanbaginc.com
Review Board - https://www.reviewboard.org
Beanbag, Inc. - https://www.beanbaginc.com


> wrote:
>
> > Hi Christian,
> >
> > Just upgraded to 2.0.8:
> >
> > [[[
> > bash-4.1# rb-site manage /var/www.reviewboard reset-issue-counts
> > --recalculate --verbosity=2 2050
> > Usage: rb-site command [options] path
> >
> > rb-site: error: no such option: --recalculate
> > bash-4.1# rb-site --version
> > rb-site 2.0.8
> > ]]]
> >
> > BTW, release notes for 2.0.8 seem to omit the 'manage' argument from the
> > command line:
> >
> > rb-site reset-issue-counts --recalculate --verbosity=2
> >
> > Also, the usage in --help message is wrong: it suggests to use 'rb-site
> > manage command' - while the correct order is 'rb-site manage
> > command'.
> >
> > Regards,
> > Alexey.
> >
> >
> >
> > On Wed, Sep 24, 2014 at 10:28 AM, Christian Hammond <
> > chri...@beanbaginc.com> wrote:
> >
> >> Hey,
> >>
> >> 2.0.8 contains a new reset-issue-counts management command that can be
> >> used. I takes a list of IDs, or --all to reset all review requests. Issue
> >> counts will be recalculated on next access.
> >>
> >> It can also provide debug info about the calculations. Can you find one
> >> of the miscalculated review requests and run:
> >>
> >> rb-site manage /path/to/site reset-issue-counts -- -verbosity=2
> >> --recalculate
> >>

Alexey Neyman

unread,
Sep 24, 2014, 3:47:42 PM9/24/14
to Christian Hammond, revie...@googlegroups.com
Re release notes: you've fixed only one instance of the two where 'manage' was missing:

"A new rb-site <path> reset-issue-counts management command has been added..."

On Wed, Sep 24, 2014 at 12:41 PM, Christian Hammond <chri...@beanbaginc.com> wrote:

Christian Hammond

unread,
Sep 24, 2014, 3:50:27 PM9/24/14
to Alexey Neyman, revie...@googlegroups.com
Can you tell it's been a very long few days?

Fixed. New docs are building now.

Christian

--
Christian Hammond - chri...@beanbaginc.com
Review Board - https://www.reviewboard.org
Beanbag, Inc. - https://www.beanbaginc.com


On September 24, 2014 at 12:47:39 PM, Alexey Neyman (alexey...@gmail.com) wrote:
> Re release notes: you've fixed only one instance of the two where 'manage'
> was missing:
>
> "A new rb-site reset-issue-counts management command has been

Christian Hammond

unread,
Sep 24, 2014, 3:57:32 PM9/24/14
to revie...@googlegroups.com, Alexey Neyman, revie...@googlegroups.com
So according to that debug output, there is one comment that has an issue open. I want to do some probing into this.

Can you run this and provide the full output, commands included?

    $ rb-site manage /path/to/site shell
    >>> from reviewboard.reviews.models import Comment, Review
    >>> comment = Comment.objects.get(pk=8199)
    >>> print comment.reply_to_id
    >>> print comment.issue_opened
    >>> print comment.issue_status
    >>> review = comment.review.get()
    >>> print review.pk
    >>> print review.public
    >>> print review.ship_it
    >>> print review.review_request_id
    >>> print review.base_reply_to_id
    >>> print review.comments.values_list('pk', flat=True)

Christian

--
Christian Hammond - chri...@beanbaginc.com
Review Board - https://www.reviewboard.org
Beanbag, Inc. - https://www.beanbaginc.com


> wrote:
>
> > Hi Christian,
> >
> > Just upgraded to 2.0.8:
> >
> > [[[
> > bash-4.1# rb-site manage /var/www.reviewboard reset-issue-counts
> > --recalculate --verbosity=2 2050
> > Usage: rb-site command [options] path
> >
> > rb-site: error: no such option: --recalculate
> > bash-4.1# rb-site --version
> > rb-site 2.0.8
> > ]]]
> >
> > BTW, release notes for 2.0.8 seem to omit the 'manage' argument from the
> > command line:
> >
> > rb-site reset-issue-counts --recalculate --verbosity=2
> >
> > Also, the usage in --help message is wrong: it suggests to use 'rb-site
> > manage command' - while the correct order is 'rb-site manage
> > command'.
> >
> > Regards,
> > Alexey.
> >
> >
> >
> > On Wed, Sep 24, 2014 at 10:28 AM, Christian Hammond <
> > chri...@beanbaginc.com> wrote:
> >
> >> Hey,
> >>
> >> 2.0.8 contains a new reset-issue-counts management command that can be
> >> used. I takes a list of IDs, or --all to reset all review requests. Issue
> >> counts will be recalculated on next access.
> >>
> >> It can also provide debug info about the calculations. Can you find one
> >> of the miscalculated review requests and run:
> >>
> >> rb-site manage /path/to/site reset-issue-counts -- -verbosity=2
> >> --recalculate
> >>

Alexey Neyman

unread,
Sep 24, 2014, 6:06:40 PM9/24/14
to Christian Hammond, revie...@googlegroups.com
Here it is:


>>> from reviewboard.reviews.models import Comment, Review
>>> comment = Comment.objects.get(pk=8199)
>>> print comment.reply_to_id
None
>>> print comment.issue_opened
False
>>> print comment.issue_status
O

>>> review = comment.review.get()
>>> print review.pk
6722
>>> print review.public
True
>>> print review.ship_it
True
>>> print review.review_request_id
2050
>>> print review.base_reply_to_id
None

>>> print review.comments.values_list('pk', flat=True)
[8199L]
>>>

I guess, the issue is that the comment has "issue opened" flag set to false, while the "issue status" is "open"?

Christian Hammond

unread,
Sep 24, 2014, 6:08:39 PM9/24/14
to revie...@googlegroups.com, Alexey Neyman, revie...@googlegroups.com
Hi Alexey,

Thanks, that helps a lot. I think I know what's going on then. I'll send a patch your way for testing once I have a fix.

Christian

--
Christian Hammond - chri...@beanbaginc.com
Review Board - https://www.reviewboard.org
Beanbag, Inc. - https://www.beanbaginc.com


Reply all
Reply to author
Forward
0 new messages