Question

Mysql CPU alerts and max_execution_time

Once every few weeks, I get an alert on my CPU being at 100% on my DO Managed MYSQL

I manually kill a query from DO logs and queries tab and it gets solved.

I’d like to avoid these in the future so I have tried:

  • pool.query timeouts on my app, but that won’t kill the mysql query, it will just stop the execution on the app itself
  • improved performance in many queries, but apparently some still trigger these issue once every 5000k executions or so, it has been a bit hard to know exactly when / why using DO logs
  • setting max_execution_time but DO blocks me, saying i do not have permission (even with the main DB user)
  • used to DO API to get the config values and read the API reference, but I can’t find max_execution_time, only other similar ones like innodb_lock_wait_timeout, net_read_timeout, net_write_timeout, wait_timeout… but according to chatGPT that’s not really the same

So how do I set a max timeout -or- how do i have access to kill queries that are taking too long?

When I was running my own mysql it was easy, but with DO’s limitations I’m a bit lost


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

alexdo
Site Moderator
Site Moderator badge
March 31, 2025

Hi there,

For the Managed Database clusters, you can’t directly make the changes, but instead, you would need to use the DigitalOcean API. You can find the documentation on how to make such config changes to your managed clusters here:

https://docs.digitalocean.com/reference/api/api-reference/#operation/databases_patch_config

Your request will look something like this:

curl -X PATCH \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
  -d '{"config": {"max_allowed_packet": "67108864","sql_require_primary_key": true}}' \
  "https://api.digitalocean.com/v2/databases/9cc10173-e9ea-4176-9dbc-a4cee4c4ff30/config"

The max_execution_time is not configurable as far as I can see, but you can try also increasing the connect_timeout instead.

Let me know how it goes!

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.