Skip to content

Send back 503 on query requests if the database is otherwise occupied.#4704

Draft
paul-m wants to merge 6 commits into
4.xfrom
429-on-db-connect
Draft

Send back 503 on query requests if the database is otherwise occupied.#4704
paul-m wants to merge 6 commits into
4.xfrom
429-on-db-connect

Conversation

@paul-m
Copy link
Copy Markdown
Contributor

@paul-m paul-m commented May 4, 2026

Fixes [issue#]

Describe your changes

On a client project, we got some interesting watchdog logs, sorting them by frequency. The log represented a week of data.
The top entry is this one:

[HY000] [1203] User u0hFhL5uTb1qLmLI already has more than 'max_user_connections' active connections in Drupal\common\Storage\AbstractDatabaseConnectionFactory->getConnection() (line 81 of /var/www/html/docroot/modules/contrib/dkan/modules/common/src/Storage/AbstractDatabaseConnectionFactory.php).

This had 4,285 occurrences within a week, which is 612 a day.

This means we can handle this error better, and turn it into a useful 429 response.

This PR handles this within the AbstractQueryController, which is where it is most likely to occur (at least on our site).

We could place similar catch blocks on other controllers as well, or figure out a more centralized way to handle this.

QA Steps

  • Add manual QA steps in checklist format for a reviewer to perform. Be as specific as possible, provide examples if appropriate.

Checklist before requesting review

If any of these are left unchecked, please provide an explanation

  • I have updated or added tests to cover my code
  • I have updated or added documentation

@paul-m paul-m changed the title Send back 429 on query requests if the database is otherwise occupied. Send back 503 on query requests if the database is otherwise occupied. May 8, 2026
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.

1 participant