How to Fix MySQL Error 4121 (ER_TP_QUERY_THRS_PER_GRP_EXCEEDS_TXN_THR_LIMIT)
You get mysql error 4121 when query threads per group exceed the transaction thread limit. You fix it by setting a smaller query thread count per group. MySQL logs this issue with the symbol ER_TP_QUERY_THRS_PER_GRP_EXCEEDS_TXN_THR_LIMIT and SQLSTATE HY000. The engine blocks the change because the thread pool math does not add up. You must keep the query thread count below the transaction thread limit in each group. When you balance these two limits, the database starts and runs without thread
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
You get mysql error 4121 when query threads per group exceed the transaction thread limit. You fix it by setting a smaller query thread count per group.
MySQL logs this issue with the symbol ER_TP_QUERY_THRS_PER_GRP_EXCEEDS_TXN_THR_LIMIT and SQLSTATE HY000. The engine blocks the change because the thread pool math does not add up. You must keep the query thread count below the transaction thread limit in each group. When you balance these two limits, the database starts and runs without thread pool faults.
Why mysql error 4121 happens in the thread pool
The MySQL thread pool groups client work to keep CPU use steady under heavy load. Each group holds a set number of threads to run queries and transactions. Admins can split these workers into standard query threads and transaction threads.
This split helps keep open transactions moving even when new queries flood the server. Still, the engine sets a strict ceiling on transaction threads in each group. If you set the query thread count higher than that ceiling, MySQL rejects the change.
The server returns code 4121 and tells you that query threads exceed the limit. This check stops a single group from starving active transactions of CPU time. You will see this fault during startup or when changing runtime rules.
How to find the bad setting in your system
Start by reading the exact error message returned by your database log. The message prints two numbers in place of the placeholders in the text. The first number shows the query thread count that you tried to set.
The second number shows the active transaction thread limit for each thread group. Compare these two values to see how far off your new setting is. Next, review your startup files and recent admin change logs for thread pool edits.
MySQL Access Governance + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Look for recent changes made by automation scripts or database admins during tuning. Often, a team member raises query threads without checking the transaction thread cap first. Check both startup files and live runtime settings so no mismatch stays hidden.
How to fix the thread limit safely in production
You have two safe ways to resolve this thread pool conflict in production. First, you can lower the query thread count per group below the transaction limit. This is the exact fix that the official MySQL error message asks you to use.
Second, you can raise the transaction thread limit per group before raising query threads. Choose the first path if your host CPU is already working near full capacity. Adding too many threads per group causes context switching and slows down all queries.
Test your new thread pool numbers in a staging system before touching live servers. Apply the change during a low traffic window using a scoped admin role. Never grant broad superuser rights to app accounts just to bypass or change server variables.
Keep your startup file in sync with any live change you make on the server. If you only fix the running instance, a future restart may fail on boot. Good change tracking keeps your database stable and stops repeat outages for your team.
Check MySQL queries and results on the wire
MySQL grants control who logs in. They do not check single queries or mask sensitive columns once a session starts. With hoop.dev, you run an open-source proxy, a sidecar for your MySQL, inline in the MySQL wire protocol. On every query an AI agent or human runs against production MySQL, RDS, or Aurora, hoop.dev decides to pass, mask, block, or hold it for review.
Multi-statement batches and prepared queries are split and checked one by one by hoop.dev guardrails, which refuse banned queries with a native MySQL error or hold risky ones for approval. On the response path, hoop.dev data masking rewrites string values in returned rows in memory, and every decision is logged. See the MIT-licensed project on GitHub.
Frequently asked questions
What does SQLSTATE HY000 mean with error 4121?
HY000 is a general error state used by MySQL for server specific faults. You must look at code 4121 to know the exact thread pool rule that failed.
Can mysql error 4121 stop my database from starting?
Yes, putting an invalid thread pool ratio in your startup file can block startup. Fix the numbers in the file so the query thread count stays under the limit.
Should I disable the thread pool to clear this error?
No, turning off the thread pool removes protection against high concurrency spikes under load. Just lower the query thread count per group so it fits within the allowed limit.
Related guides
In this post