Could not get JDBC Connection; nested exception is java.sql.SQLException: The table '/home/mysql/data 3009/tmp/#sql_2cf03_2' is full

1. 出现这个错误信息的原因

在SQL查询进行 group by、order by、distinct、union、多表更新、group_concat、count(distinct)、子查询或表连接的情况下,MySQL 有可能会使用内部临时表。MySQL 首先在内存中创建 Memory 引擎临时表,当临时表的尺寸过大时,会自动转换为磁盘上的 MyISAM 引擎临时表(当查询涉及到 Blob 或 Text 类型字段,MySQL 会直接使用磁盘临时表)。

这个错误信息,说明磁盘上的临时表 #sql_19472_5 的物理尺寸受到限制,已经无法再继续扩展了。

导致这个错误信息的原因是查询语句使用的内部磁盘临时表(MyISAM 引擎表)总大小已经达到了实例参数loose_rds_max_tmp_disk_space指定的限制(默认 10 GB)。

Could not get JDBC Connection; nested exception is java.sql.SQLException: The table '/home/mysql/data 3009/tmp/#sql_2cf03_2' is full_第1张图片

2. 如何处理该错误信息

在控制台

参数设置中根据 RDS 实例当前空闲空间应用空间使用情况,调高参数loose_rds_max_tmp_disk_space的设置,建议考虑设置为略小于当前空闲空间(保留一部分空间以便 Binlog 和 数据文件使用),以避免磁盘临时表总占用空间过高,超过实例规格而导致实例锁定,影响业务。该参数单位是 字节(Byte),默认 10 GB,上限 1000 GB。

Could not get JDBC Connection; nested exception is java.sql.SQLException: The table '/home/mysql/data 3009/tmp/#sql_2cf03_2' is full_第2张图片

注:修改该参数会自动重启 RDS 实例。

减少同时使用磁盘临时表的会话数量。因为参数 loose_rds_max_tmp_disk_space 指定的是磁盘临时表文件的总大小,因此减少并发使用磁盘临时表的会话数量可以避免超过该参数指定的限制。

可以通过在控制台

参数设置 中调高tmp_table_size参数值来调高内存临时表的上限。

Could not get JDBC Connection; nested exception is java.sql.SQLException: The table '/home/mysql/data 3009/tmp/#sql_2cf03_2' is full_第3张图片

注:tmp_table_size 单位字节(Byte),默认 256 KB,最大64 MB。

在查询中,尽量避免使用 Blog 和 Text 类型字段。

优化查询逻辑,避免过大的中间数据集操作。

3. 如何判断查询是否使用内部临时表

查看 explain SQL 命令的输出,在 Extra 字段中有 Using temporary 字样的代表会使用内部临时表。比如:

select*fromalarmgroupbycreated_on orderbydefault;

Could not get JDBC Connection; nested exception is java.sql.SQLException: The table '/home/mysql/data 3009/tmp/#sql_2cf03_2' is full_第4张图片

你可能感兴趣的:(Could not get JDBC Connection; nested exception is java.sql.SQLException: The table '/home/mysql/data 3009/tmp/#sql_2cf03_2' is full)