4129
MariaDBERRORNotableHIGH confidence

Thread stack overrun during query execution

Production Risk

Medium — The query fails; if in a stored program, the program terminates with an error.

Why it happens
  1. 1A stored procedure or function with deep or infinite recursion.
  2. 2An extremely complex query with deeply nested subqueries.
  3. 3thread_stack variable is set too low for the workload.

Fix 1

Increase thread_stack in my.cnf

Why this works

Setting thread_stack=512K or higher provides more stack space per thread.

Fix 2

Reduce recursion depth in stored programs

Why this works

Refactor recursive stored programs to use iteration or limit recursion depth with max_sp_recursion_depth.

What not to do

Sources
Official documentation ↗

MySQL 8.0 — 4129 ER_STACK_OVERRUN2

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All MariaDB errors