pt-online-schema-change报错

简介:

今天在对一个大表加索引的时候失败了,具体如下:

SELECT /*!40001 SQL_NO_CACHE */ `goods_id` FROM `rosegal_db`.`eload_goods` FORCE INDEX(`PRIMARY`) WHERE ((`goods_id` >= ?)) ORDER BY `goods_id` LIMIT ?, 2 /*next chunk boundary*/

2016-01-05T23:32:28 Dropping triggers...

DROP TRIGGER IF EXISTS `rosegal_db`.`pt_osc_rosegal_db_eload_goods_del`;

DROP TRIGGER IF EXISTS `rosegal_db`.`pt_osc_rosegal_db_eload_goods_upd`;

DROP TRIGGER IF EXISTS `rosegal_db`.`pt_osc_rosegal_db_eload_goods_ins`;

2016-01-05T23:32:28 Dropped triggers OK.

2016-01-05T23:32:28 Dropping new table...

DROP TABLE IF EXISTS `rosegal_db`.`_eload_goods_new`;

2016-01-05T23:32:28 Dropped new table OK.

`rosegal_db`.`eload_goods` was not altered.

2016-01-05T23:32:28 Error copying rows from `rosegal_db`.`eload_goods` to `rosegal_db`.`_eload_goods_new`: Threads_running=52 exceeds its critical threshold 50

从提示上可以看出是Threads_running 超过了警告的阀值,查看官方文档,有两种方式来设置这个参数:

--critical-load
type: Array; default: Threads_running=50
Examine SHOW GLOBAL STATUS after every chunk, 
and abort if the load is too high. The option accepts a comma-separated list of MySQL status variables and thresholds. 
An optional =MAX_VALUE (or :MAX_VALUE) can follow each variable. If not given, 
the tool determines a threshold by examining the current value at startup and doubling it.
See --max-load for further details. These options work similarly, 
except that this option will abort the tool’s operation instead of pausing it,
 and the default value is computed differently if you specify no threshold. 
 The reason for this option is as a safety check in case the triggers on the
 original table add so much load to the server that it causes downtime. 
 There is probably no single value of Threads_running that is wrong for 
 every server, but a default of 50 seems likely to be unacceptably high
 for most servers, indicating that the operation should be canceled immediately.

大致的意思如下:
每次chunk操作前后,会根据show global status统计指定的状态量的变化,默认是统计Thread_running。
目的是为了安全,防止原始表上的触发器引起负载过高。这也是为了防止在线DDL对线上的影响。
超过设置的阀值,就会终止操作,在线DDL就会中断。提示的异常如上报错信息。


--max-load
type: Array; default: Threads_running=25
Examine SHOW GLOBAL STATUS after every chunk, and pause if any status variables are higher than their thresholds. 
The option accepts a comma-separated list of MySQL status variables. An optional =MAX_VALUE (or :MAX_VALUE) can 
follow each variable. If not given, the tool determines a threshold by examining the current value and increasing it by 20%.

For example, if you want the tool to pause when Threads_connected gets too high, you can specify “Threads_connected”,
 and the tool will check the current value when it starts working and add 20% to that value. If the current value is 100, 
 then the tool will pause when Threads_connected exceeds 120, and resume working when it is below 120 again. If you want to
 specify an explicit threshold, such as 110, you can use either “Threads_connected:110” or “Threads_connected=110”.

The purpose of this option is to prevent the tool from adding too much load to the server. If the data-copy queries are 
intrusive, or if they cause lock waits, then other queries on the server will tend to block and queue. This will typically 
cause Threads_running to increase, and the tool can detect that by running SHOW GLOBAL STATUS immediately after each query finishes. 
If you specify a threshold for this variable, then you can instruct the tool to wait until queries are running normally again. This will 
not prevent queueing, however; it will only give the server a chance to recover from the queueing. If you notice queueing, it is best to decrease the chunk time.

--max-load 选项定义一个阀值,在每次chunk操作后,查看show global status状态值是否高于指定的阀值。该参数接受一个mysql status状态变量以及一个阀值,
如果没有给定阀值,则定义一个阀值为为高于当前值的20%。
注意这个参数不会像--critical-load终止操作,而只是暂停操作。当status值低于阀值时,则继续往下操作。
是暂停还是终止操作这是--max-load和--critical-load的差别。

参数值为列表形式,可以指定show global status出现的状态值。比如,Thread_connect 等等。
格式如下:--critical-load="Threads_running=200"  或者--critical-load="Threads_running:200"。



本文转自 emma_cql 51CTO博客,原文链接:http://blog.51cto.com/chenql/1732076
相关文章
|
SQL 关系型数据库 MySQL
pt-tools系列:pt-online-schema-change 最佳实践
pt的详细步骤 Step 1: Create the new table. Step 2: Alter the new, empty table. This should be very quick, or die if the user specified a bad alter statement.
5765 0
|
域名解析 安全 数据建模
阿里云域名注册政策参考,新人首单1元,域名代金券及注册和续费优惠口令
阿里云推出最新客专享域名低至1元活动,活动提供企业新用户1元注册com域名,个人新用户33元注册com域名,cn域名首年8.8元等政策,此外,阿里云还有注册和续费优惠口令和域名代金券等长期政策,本文对这些政策做个汇总,以供参考。
阿里云域名注册政策参考,新人首单1元,域名代金券及注册和续费优惠口令
|
NoSQL MongoDB SQL
MongoShake最佳实践
mongoshake最佳实践,到底该怎么玩?
22223 0
|
12月前
|
关系型数据库 Linux 数据库
PostgreSQL 入门指南:安装、配置与基本命令
本文从零开始,详细介绍如何在 Windows、Linux 和 macOS 上安装和配置 PostgreSQL,涵盖30+个实操代码示例。内容包括安装步骤、配置远程访问和用户权限、基础数据库操作命令(如创建表、插入和查询数据),以及常见问题的解决方案。通过学习,你将掌握 PostgreSQL 的基本使用方法,并为后续深入学习打下坚实基础。
12841 1
|
存储 监控 关系型数据库
MySQL 参数innodb_read_io_threads
`innodb_read_io_threads` 是 MySQL 数据库中 InnoDB 存储引擎的一个配置参数,它用于指定后台线程池中用于处理读取 I/O 请求的线程数量。InnoDB 存储引擎负责管理数据库的物理存储和检索,是 MySQL 最常用的存储引擎之一。 ### 参数说明 - **名称**: `innodb_read_io_threads` - **默认值**: 4 - **范围**: 1 到 64 - **动态修改**: 不能动态修改(需要重启服务器) - **适用版本**: MySQL 5.6 及以上版本 ### 作用 `innodb_read_io_threads`
1564 1
|
人工智能 算法
大模型不会推理,为什么也能有思路?有人把原理搞明白了
大模型(LLMs)在推理任务上表现出与人类不同的问题解决思路。最新研究《Procedural Knowledge in Pretraining Drives Reasoning in Large Language Models》发现,大模型通过合成程序性知识来完成推理任务,而非简单检索答案。这为理解其推理能力提供了新视角,并指出了改进方向,如设计更有效的算法和使用更大规模数据。论文链接:https://arxiv.org/abs/2411.12580。
427 3
|
缓存 负载均衡 网络协议
CDN负载均衡技术
【10月更文挑战第26天】内容分发网络(CDN)是一种通过将数据缓存至全球各地的节点,以提高用户访问速度和数据传输稳定性的技术。CDN负载均衡技术是其核心,通过智能分配用户请求至最近最稳定的节点,确保高效稳定的网络体验。该技术分为全局负载均衡和本地负载均衡,前者实现用户请求的初步定向,后者则根据节点状态进行精细化管理。
490 2
|
存储 缓存 NoSQL
Nginx缓存
Nginx缓存
225 2
|
移动开发 JavaScript 前端开发
ThreeJs简介
这篇文章介绍了Three.js的基础知识,包括其相对于WebGL的优势以及如何使用Three.js创建基本的3D场景。
750 1

热门文章

最新文章