Skip to content

Remove eager DB access in proxy AppConfig.ready()#14121

Draft
Copilot wants to merge 3 commits intomasterfrom
copilot/fix-proxy-warning-at-boot-time
Draft

Remove eager DB access in proxy AppConfig.ready()#14121
Copilot wants to merge 3 commits intomasterfrom
copilot/fix-proxy-warning-at-boot-time

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 9, 2026

geonode.proxy was calling proxy_urls_registry.initialize() inside AppConfig.ready(), triggering a DB query at startup and causing Django to emit a RuntimeWarning about database access during app initialization.

The registry already supports lazy initialization — get_proxy_allowed_hosts() re-initializes automatically when the cache is empty or stale — so there's no need to eagerly populate it at boot.

Changes

  • geonode/proxy/apps.py: Remove run_setup_hooks() and its try/except wrapper. Wire Link post-save/post-delete signal handlers directly in ready() (no DB access required).
  • geonode/proxy/utils.py: Remove _first_init flag and signal-connection code from initialize() — signals are now owned by AppConfig.ready(). Drop the unused signals import.
# Before: DB hit at every startup
def ready(self):
    super().ready()
    try:
        proxy_urls_registry.initialize()  # queries DB
    except Exception:
        post_migrate.connect(run_setup_hooks, sender=self)

# After: no DB access; signals wired cleanly; registry initializes lazily on first use
def ready(self):
    super().ready()
    from geonode.base.models import Link
    signals.post_save.connect(link_post_save, sender=Link)
    signals.post_delete.connect(link_post_delete, sender=Link)

Copilot AI assigned Copilot and etj Apr 9, 2026
@cla-bot
Copy link
Copy Markdown

cla-bot bot commented Apr 9, 2026

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have the users @Copilot on file. In order for us to review and merge your code, please contact the project maintainers to get yourself added.

Copilot AI linked an issue Apr 9, 2026 that may be closed by this pull request
@cla-bot
Copy link
Copy Markdown

cla-bot bot commented Apr 9, 2026

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have the users @Copilot on file. In order for us to review and merge your code, please contact the project maintainers to get yourself added.

@cla-bot
Copy link
Copy Markdown

cla-bot bot commented Apr 9, 2026

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have the users @Copilot on file. In order for us to review and merge your code, please contact the project maintainers to get yourself added.

Copilot AI changed the title [WIP] Fix proxy warning during app initialization Remove eager DB access in proxy AppConfig.ready() Apr 9, 2026
Copilot AI requested a review from etj April 9, 2026 17:10
Copilot finished work on behalf of etj April 9, 2026 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Proxy warning at boot time

2 participants