Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pagination bug for VRF's in the web UI and API #1869

Closed
taka-psba opened this issue Feb 6, 2018 · 1 comment
Closed

Pagination bug for VRF's in the web UI and API #1869

taka-psba opened this issue Feb 6, 2018 · 1 comment
Labels
status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@taka-psba
Copy link

taka-psba commented Feb 6, 2018

Issue type

[ ] Feature request
[X] Bug report
[ ] Documentation

Environment

  • Python version: 2.7.5
  • NetBox version: 2.2.7

We have a lot of VRF's with the same name (don't ask :-() and if a group of such VRF's happens to span a page break, the web UI and API both can return the wrong thing when retrieving the list of VRF's. The problem appears to happen because the underlying SQL orders the VRF rows returned from the database by name only.

For example, if we have 5 VRF's called X, doing something like SELECT * FROM vrf ORDER BY name means that they must appear after all the W's and before all the Y's, but the ordering of the X's within themselves is undetermined. If these VRF's had RD's 1 through 5, and pagination was such that we want to show 3 of them on the first page and 2 on the second, for the first page, the database might return the X rows in ascending RD order, and we would see this:

    name   RD
    ====   ==
     W     ...
     X     1
     X     2
     X     3

On the second page, another SQL query is issued, and since the database is free to return the X's in any order it pleases, they could come back in descending RD order, and so we would see this:

    name   RD
    ====   ==
     X     2
     X     1
     Y     ...

IOTW, X-1 and X-2 appear twice, and X-4 and X-5 are missing. This also happens when calling the API.

Changing VRF.Meta.ordering to be ['name','rd'] clears the problem (presumably, this might be also happening elsewhere). I also checked the code for the v2.3-beta2 release you just pushed out, and it looks like the same thing will happen there as well.

I see here that sorting RD's is problematic, but in this particular case, it doesn't matter what the sort order of the VRF's is, just that it's stable across queries.

@jeremystretch jeremystretch added type: bug A confirmed report of unexpected behavior in the application status: accepted This issue has been accepted for implementation labels Feb 7, 2018
@jeremystretch
Copy link
Member

Yeah, the problem is that name isn't unique, so VRFs with the same name are ordered arbitrarily (and apparently inconsistently). We'll need a migration to add the rd field to the ordering declaration.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

No branches or pull requests

2 participants