Table has no partition for value .....

0. 环境

mysql5.5版本

1. 问题发生

最近发现应用服务异常,排查日志发现显示报错 java.sql.SQLException:Table has no partition for value;出现该问题的原因是 mysql 中库表的分区表没有创建、或者创建失败。

2. 排查问题

  1. 对相应的库表进行表分区的恢复和创建,发现还是失败的,并且mysql 日志报错 Too many partitions (including subpartitions) were defined在这里插入图片描述
  2. 查看表分区相关信息
a. 下面sql执行发现分区表个数达到了1024
select count(*) from INFORMATION_SCHEMA.PARTITIONS  WHERE TABLE_SCHEMA = 'schema-name' AND TABLE_NAME = 'table-name' ;

b. 下面sql查看 open_files_limit 的值为102400(值已经很大了)
show variables like 'open%';
show global status like 'open%file%';

在这里插入图片描述
在这里插入图片描述

  1. 现在mysql版本5.5,官网查询发现最大表分区为1024,这个和存储引擎有关,无法修改
https://dev.mysql.com/doc/refman/5.6/en/partitioning-limitations.html

Maximum number of partitions.  Prior to MySQL 5.6.7, the maximum possible 
number of partitions for a given table not using the NDB storage engine was
1024. Beginning with MySQL 5.6.7, this limit is increased to 8192 
partitions. Regardless of the MySQL Server version, this maximum includes
subpartitions.

3. 解决问题

  1. 删除之前部分旧的表分区
 1. 查询 PARTITION_NAME 的值 (升序查询后删除)
 select * from INFORMATION_SCHEMA.PARTITIONS  WHERE TABLE_SCHEMA = 'schema-name' AND TABLE_NAME = 'table-name' ORDER BY partition_ordinal_position asc LIMIT 1;
 
 2. 删除 PARTITION_NAME
ALTER TABLE table-name DROP partition xxxx;
  1. 对相应的库表进行表分区的恢复和创建,发现成功,应用服务异常消失
  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值