r/mysql • u/Upper-Lifeguard-8478 • Aug 04 '26
question DB parameter suggestion
Hi,
Its aurora mysql Serverless v2 (Max up to 80 ACUs). Suddenly , we saw with bit high concurrency , the application hits a hard JDBC query timeout, killing the thread and throwing this error: "Database Query Time out. Exception: JDBC exception executing SQL [(conn=548672) Table './rdsdbdata/tmp/#sql171_85f40_1' doesn't exist]"
Some team members are suggesting to bump both temptable_max_ram and temptable_max_mmap from 1GB to 2GB to give the query more breathing room. However, checking performance_schema.variables_info reveals that temptable_max_** is currently showing below:
VARIABLE_NAME current_value_bytes current_value_MB VARIABLE_SOURCE VARIABLE_PATH
temptable_max_mmap 1073741824 1024 GLOBAL /etc/my.cnf
temptable_max_ram 1073741824 1024 COMPILED
Want to know if this is correct setting and Is it advisable to bump these values to 2GB. Want to confirm the safest parameter strategy for temporary storage thresholds in the meantime we tune the query?
1
u/TroubledSquirrel Aug 05 '26
Liamsorsby has it right but I will expand on the parts they didn't mention you shoudl run explain on the offending queries and look for using temporary. if it's a sort or group by hat's spilling, the real fix is usually an index that avoids the temp table entirely, not a bigger container for it.
also check "Database Query Time out" might be your connection pool or driver level querytimeout firing client side before MySQL even finishes, which then races with MySQL's cleanup of the temp table and produces exactly this "table doesn't exist" as a secondary symptom. check your HikariCP config or driver defaults and see if the timeout is shorter than what the query actually needs under load.
if you do end up touching the temptable params, don't bump both blindly by the same amount. figure out whether you're RAM bound before the mmap spill or mmap bound after it, and raise only the one that's actually the bottleneck. bumping both "for breathing room" without that data doubles your worst case memory footprint under concurrency, which if scaling churn is your actual root cause could make things worse.
3
u/liamsorsby Aug 04 '26
You seem to be trying to treat the symptom here rather than the root cause.
I'd start out by enabling the slow query log, looking at your queries and explaining them.
I'd want to work out why your queries are spilling into the temp disk, 1GB is already rather generous.
1
u/alecc Aug 06 '26
temptable_max_ram and temptable_max_mmap are server-wide caps, not per query - every connection shares that 1GB of TempTable RAM and 1GB of mmap space. That's why it bites under concurrency: several sessions each spilling a few hundred MB hit the shared ceiling together, and the losing query is the one that errors with '#sql... doesn't exist' (as far as I can tell that error is the temp table dying under the query when temp space runs out, not a real missing table). Bumping both to 2GB on an instance that can reach 80 ACUs is safe memory-wise, but it only moves the ceiling and the next load spike finds it again. So agree with the slow query log advice - you're hunting queries with 'Using temporary' on big row estimates in EXPLAIN, usually a GROUP BY, DISTINCT or UNION without an index that covers it. One Aurora wrinkle: the mmap side lands on local instance storage, and on Serverless v2 that scales with the ACUs, so at low-ACU moments there's less temp room than the variables promise.