Add deep startup-performance diagnosis for pgAdmin desktop launch path#1
Draft
Copilot wants to merge 2 commits into
Draft
Add deep startup-performance diagnosis for pgAdmin desktop launch path#1Copilot wants to merge 2 commits into
Copilot wants to merge 2 commits into
Conversation
Co-authored-by: dev-hari-prasad <161151819+dev-hari-prasad@users.noreply.github.com> Agent-Logs-Url: https://github.com/dev-hari-prasad/pgadmin4/sessions/74114d00-7f5f-4015-9182-7838e71d5a32
Copilot
AI
changed the title
[WIP] Investigate performance issues in pgAdmin application launch
Add deep startup-performance diagnosis for pgAdmin desktop launch path
Mar 21, 2026
dev-hari-prasad
pushed a commit
that referenced
this pull request
Jun 2, 2026
…st context
Two related issues that surfaced in BatchProcessTest:
1. ConnectionLocker.__enter__ accessed Flask session (via 'in' check)
AFTER acquiring the lock. When called outside a request context,
session access raises RuntimeError. Python's 'with' semantics skip
__exit__ if __enter__ raises, so the lock leaked - any subsequent
call to ConnectionLocker hung forever waiting on a lock that
would never be released.
Wrap session access in try/except RuntimeError so missing-request-
context falls through cleanly and the lock is released normally
on with-block exit. Also use .get() chains so partial session
shapes do not raise KeyError.
2. The four batch_process unit tests (backup, import_export,
maintenance, restore) used app_context() instead of
test_request_context(). flask-babel's gettext() in
BackupMessage.details() and similar code paths require a request
context; ConnectionLocker.__enter__ also touches session as above.
Switching to test_request_context('/') gives both the request
binding they need.
Verified: tools.backup.tests.test_batch_process now runs 4/4 passing
(was 3 ERROR + 1 hang before fix #1; 3 FAIL before fix #2).
Both are pre-existing issues exposed by Python 3.14 / flask 3.1 /
flask-babel stricter context enforcement; not introduced by 9.15
CVE work.
dev-hari-prasad
pushed a commit
that referenced
this pull request
Jun 2, 2026
…lity test Two related issues, both surfaced when running the regression suite non-interactively: 1. user_info_server()'s while-not-validate retry loops had no upper bound. With a mocked or closed stdin (test mocks, EOF in CI/cron, typo'd PGADMIN_SETUP_EMAIL=''), the loop would call input()/pprompt() forever, printing 'Invalid email address. Please try again.' on every iteration. We saw this manifest as a 13.5 million-line 25 GB log when test_no_email_deliverability hit the case. Cap each loop at MAX_PROMPT_ATTEMPTS=5 and raise RuntimeError with a pointer to PGADMIN_SETUP_EMAIL/PASSWORD env vars on exhaustion. 2. test_no_email_deliverability included pg@postgres.local in its "should be accepted with deliverability=False" data set. The .local suffix is in email_validator.SPECIAL_USE_DOMAIN_NAMES which fails syntactic validation regardless of the deliverability flag, so validate_email always rejected it - looping forever pre-fix #1. Set config.ALLOW_SPECIAL_EMAIL_DOMAINS = ['local'] in the test's try/finally block so .local is allowed for this scenario, restored afterward to avoid leaking state into other tests. With both fixes in place, the test can be removed from the regression runtests --exclude list.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
pgAdmin desktop startup can be disproportionately slow because heavy backend initialization completes before Electron can pass readiness checks. This PR adds a code-referenced diagnosis of the startup critical path, pinpoints concrete bottlenecks, and evaluates whether ~10x speedup is realistic and where limits/trade-offs exist.
What was added
docs/en_US/startup_performance_diagnosis.rstdocs/en_US/index.rstBottlenecks identified (with exact code anchors)
web/pgadmin/__init__.py,web/pgadmin/setup/db_upgrade.py,web/pgadmin/setup/db_table_check.pyweb/pgadmin/submodules.py,web/pgadmin/__init__.pyweb/pgadmin/utils/driver/registry.py,web/pgadmin/authenticate/registry.pyweb/pgadmin/__init__.pyruntime/src/js/pgadmin.jsruntime/src/js/misc.jsOptimization feasibility and constraints
💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.