Error with Postgres request when opening Racks or Devices #1696

Closed
opened 2025-12-29 16:34:30 +01:00 by adam · 9 comments
Owner

Originally created by @omen89 on GitHub (Apr 25, 2018).

Issue type

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

Environment

  • Python version: 2.7.5
  • NetBox version: 2.3.3

Description

Hello!
We noticed the problem on version 2.3.1, update to 2.3.3 did not help
Let's go to Organization > Sites > some site.
image

When you open Devices, an error occurs:

image

If you open Racks, then an empty list is opened
image

In logs of Postgres I see errors with the query:

postgres[113893]: [10-3]  "dcim_device"."primary_ip6_id" AS Col17, "dcim_device"."cluster_id" AS Col18, "dcim_device"."virtual_chassis_id" AS Col19, "dcim_device"."vc_position" AS Col20, "dcim_device"."vc_priority" AS Col21, "dcim_device"."comments" AS Col22 FROM "dcim_device" INNER JOIN "dcim_site" ON ("dcim_device"."site_id" = "dcim_site"."id") WHERE "dcim_site"."slug" = E'l-rus-msk-kdr15') subquery

postgres[113893]: [10-2] < 2018-04-25 11:24:45.707 MSK > STATEMENT:  SELECT COUNT(*) FROM (SELECT DISTINCT (CAST(SUBSTRING(dcim_device.name FROM '(\d{1,9})$') AS integer)) AS "_dcim_device_name3", (SUBSTRING(dcim_device.name FROM '^\d*(.*?)\d*$')) AS "_dcim_device_name2", (CAST(SUBSTRING(dcim_device.name FROM '^(\d{1,9})') AS integer)) AS "_dcim_device_name1", "dcim_device"."id" AS Col1, "dcim_device"."created" AS Col2, "dcim_device"."last_updated" AS Col3, "dcim_device"."device_type_id" AS Col4, "dcim_device"."device_role_id" AS Col5, "dcim_device"."tenant_id" AS Col6, "dcim_device"."platform_id" AS Col7, "dcim_device"."name" AS Col8, "dcim_device"."serial" AS Col9, "dcim_device"."asset_tag" AS Col10, "dcim_device"."site_id" AS Col11, "dcim_device"."rack_id" AS Col12, "dcim_device"."position" AS Col13, "dcim_device"."face" AS Col14, "dcim_device"."status" AS Col15, "dcim_device"."primary_ip4_id" AS Col16,

postgres[113893]: [10-1] < 2018-04-25 11:24:45.707 MSK > ERROR:  invalid input syntax for integer: "d"

And in some Sites everything is OK. Found such a problem with 3 sites of 20, checked out selectively.

Originally created by @omen89 on GitHub (Apr 25, 2018). <!-- Before opening a new issue, please search through the existing issues to see if your topic has already been addressed. Note that you may need to remove the "is:open" filter from the search bar to include closed issues. Check the appropriate type for your issue below by placing an x between the brackets. For assistance with installation issues, or for any other issues other than those listed below, please raise your topic for discussion on our mailing list: https://groups.google.com/forum/#!forum/netbox-discuss Please note that issues which do not fall under any of the below categories will be closed. Due to an excessive backlog of feature requests, we are not currently accepting any proposals which extend NetBox's feature scope. Do not prepend any sort of tag to your issue's title. An administrator will review your issue and assign labels as appropriate. ---> ### Issue type [ ] Feature request <!-- An enhancement of existing functionality --> [X] Bug report <!-- Unexpected or erroneous behavior --> [ ] Documentation <!-- A modification to the documentation --> <!-- Please describe the environment in which you are running NetBox. (Be sure to verify that you are running the latest stable release of NetBox before submitting a bug report.) If you are submitting a bug report and have made any changes to the code base, please first validate that your bug can be recreated while running an official release. --> ### Environment * Python version: 2.7.5 * NetBox version: 2.3.3 <!-- BUG REPORTS must include: * A list of the steps needed for someone else to reproduce the bug * A description of the expected and observed behavior * Any relevant error messages (screenshots may also help) FEATURE REQUESTS must include: * A detailed description of the proposed functionality * A use case for the new feature * A rough description of any necessary changes to the database schema * Any relevant third-party libraries which would be needed --> ### Description Hello! We noticed the problem on version 2.3.1, update to 2.3.3 did not help Let's go to Organization > Sites > some site. ![image](https://user-images.githubusercontent.com/24832262/39235116-b2ed2f1c-487d-11e8-9128-37477985dd37.png) When you open Devices, an error occurs: ![image](https://user-images.githubusercontent.com/24832262/39234992-6cd3f3bc-487d-11e8-94a5-27c181d1e45d.png) If you open Racks, then an empty list is opened ![image](https://user-images.githubusercontent.com/24832262/39235150-cd4dc2cc-487d-11e8-9449-5e32443c1b90.png) In logs of Postgres I see errors with the query: ``` postgres[113893]: [10-3] "dcim_device"."primary_ip6_id" AS Col17, "dcim_device"."cluster_id" AS Col18, "dcim_device"."virtual_chassis_id" AS Col19, "dcim_device"."vc_position" AS Col20, "dcim_device"."vc_priority" AS Col21, "dcim_device"."comments" AS Col22 FROM "dcim_device" INNER JOIN "dcim_site" ON ("dcim_device"."site_id" = "dcim_site"."id") WHERE "dcim_site"."slug" = E'l-rus-msk-kdr15') subquery postgres[113893]: [10-2] < 2018-04-25 11:24:45.707 MSK > STATEMENT: SELECT COUNT(*) FROM (SELECT DISTINCT (CAST(SUBSTRING(dcim_device.name FROM '(\d{1,9})$') AS integer)) AS "_dcim_device_name3", (SUBSTRING(dcim_device.name FROM '^\d*(.*?)\d*$')) AS "_dcim_device_name2", (CAST(SUBSTRING(dcim_device.name FROM '^(\d{1,9})') AS integer)) AS "_dcim_device_name1", "dcim_device"."id" AS Col1, "dcim_device"."created" AS Col2, "dcim_device"."last_updated" AS Col3, "dcim_device"."device_type_id" AS Col4, "dcim_device"."device_role_id" AS Col5, "dcim_device"."tenant_id" AS Col6, "dcim_device"."platform_id" AS Col7, "dcim_device"."name" AS Col8, "dcim_device"."serial" AS Col9, "dcim_device"."asset_tag" AS Col10, "dcim_device"."site_id" AS Col11, "dcim_device"."rack_id" AS Col12, "dcim_device"."position" AS Col13, "dcim_device"."face" AS Col14, "dcim_device"."status" AS Col15, "dcim_device"."primary_ip4_id" AS Col16, postgres[113893]: [10-1] < 2018-04-25 11:24:45.707 MSK > ERROR: invalid input syntax for integer: "d" ``` And in some Sites everything is OK. Found such a problem with 3 sites of 20, checked out selectively.
adam added the type: bugstatus: accepted labels 2025-12-29 16:34:30 +01:00
adam closed this issue 2025-12-29 16:34:30 +01:00
Author
Owner

@jeremystretch commented on GitHub (May 4, 2018):

No idea what could be causing that. It doesn't appear to be a reproducible issue. Have you made any modifications to the code base?

@jeremystretch commented on GitHub (May 4, 2018): No idea what could be causing that. It doesn't appear to be a reproducible issue. Have you made any modifications to the code base?
Author
Owner

@omen89 commented on GitHub (May 7, 2018):

Hello! We did not change code and did not make any changes to the database

@omen89 commented on GitHub (May 7, 2018): Hello! We did not change code and did not make any changes to the database
Author
Owner

@akhmarov commented on GitHub (May 21, 2018):

Hello, Jeremy

This issue is a bit critical. We have faced the same error opening several racks on several sites. How could we gather additional info to help debug process? What can help you to find root cause?

@akhmarov commented on GitHub (May 21, 2018): Hello, Jeremy This issue is a bit critical. We have faced the same error opening several racks on several sites. How could we gather additional info to help debug process? What can help you to find root cause?
Author
Owner

@jeremystretch commented on GitHub (May 21, 2018):

@akhmarov Can you post the list of device names within the site which gives you the error? I think this has something to do with the logic in NaturalOrderByManager.

@jeremystretch commented on GitHub (May 21, 2018): @akhmarov Can you post the list of device names within the site which gives you the error? I think this has something to do with the logic in [`NaturalOrderByManager`](https://github.com/digitalocean/netbox/blob/develop/netbox/utilities/managers.py#L6).
Author
Owner

@omen89 commented on GitHub (Jun 5, 2018):

@jeremystretch Hello! Is there a solution to this problem?

@omen89 commented on GitHub (Jun 5, 2018): @jeremystretch Hello! Is there a solution to this problem?
Author
Owner

@DanSheps commented on GitHub (Jun 6, 2018):

@omen89

You need to give him time to research this and play around with it.

@DanSheps commented on GitHub (Jun 6, 2018): @omen89 You need to give him time to research this and play around with it.
Author
Owner

@jeremystretch commented on GitHub (Jun 6, 2018):

Sorry but I'm not able to recreate this locally. If you can recreate the error on a new install and post the exact replication instructions and sample data, I'll try digging into it more.

@jeremystretch commented on GitHub (Jun 6, 2018): Sorry but I'm not able to recreate this locally. If you can recreate the error on a new install and post the exact replication instructions and sample data, I'll try digging into it more.
Author
Owner

@omen89 commented on GitHub (Jun 9, 2018):

Hello @jeremystretch!
We found problems and solved it. For another product in PostgreSQL the parameters were set:

escape_string_warning = off
standard_conforming_strings = off

Because of them, the netbox issued an error. You can close the bug. Perhaps this information will be useful.

@omen89 commented on GitHub (Jun 9, 2018): Hello @jeremystretch! We found problems and solved it. For another product in PostgreSQL the parameters were set: ``` escape_string_warning = off standard_conforming_strings = off ``` Because of them, the netbox issued an error. You can close the bug. Perhaps this information will be useful.
Author
Owner

@jeremystretch commented on GitHub (Jun 11, 2018):

Interesting. Thank you for posting the follow-up!

@jeremystretch commented on GitHub (Jun 11, 2018): Interesting. Thank you for posting the follow-up!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#1696