Changes in GreatSQL 5.7.36 (2022-4-7)

[toc]

1.新增特性

1.2 新增MGR角色列

在MySQL 5.7中,查询 performance_schema.replication_group_members 时,没有 MEMBER_ROLE 这个列,这很不便于快速查看哪个节点是Primary Node。

在GreatSQL中,增加了这个列,查看节点角色更便利了,对一些中间件支持也更友好。

mysql> select * from performance_schema.replication_group_members;
+---------------------------+--------------------------------------+-------------+-------------+--------------+-------------+
| CHANNEL_NAME              | MEMBER_ID                            | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE | MEMBER_ROLE |
+---------------------------+--------------------------------------+-------------+-------------+--------------+-------------+
| group_replication_applier | 4c21e81e-953f-11ec-98da-d08e7908bcb1 | 127.0.0.1   |        3308 | ONLINE       | SECONDARY   |
| group_replication_applier | b5e398ac-8e33-11ec-a6cd-d08e7908bcb1 | 127.0.0.1   |        3306 | ONLINE       | PRIMARY     |
| group_replication_applier | b61e7075-8e33-11ec-a5e3-d08e7908bcb1 | 127.0.0.1   |        3307 | ONLINE       | SECONDARY   |
+---------------------------+--------------------------------------+-------------+-------------+--------------+-------------+

1.2 采用全新的流控机制

原生的流控算法有较大缺陷,触发流控阈值后,会有短暂的流控停顿动作,之后继续放行事务,这会造成1秒的性能抖动,且没有真正起到持续流控的作用。

在GreatSQL中,重新设计了流控算法,增加主从延迟时间来计算流控阈值,并且同时考虑了大事务处理和主从节点的同步,流控粒度更细致,不会出现MySQL社区版本的1秒小抖动问题。

新增选项 group_replication_flow_control_replay_lag_behind 用于控制MGR主从节点复制延迟阈值,当MGR主从节点因为大事务等原因延迟超过阈值时,就会触发流控机制。

System Variable Namegroup_replication_flow_control_replay_lag_behind
Variable Scopeglobal
Dynamic VariableYES
Permitted Values[0 ~ ULONG_MAX]
Default600
Description单位:秒。
用于控制MGR主从节点复制延迟阈值,当MGR主从节点因为大事务等原因延迟超过阈值时,就会触发流控机制

该选项默认为600秒,可在线动态修改,例如:

mysql> SET GLOBAL group_replication_flow_control_replay_lag_behind = 600;

正常情况下,该参数无需调整。

1.3 新增MGR网络开销阈值

新增相应选项 group_replication_request_time_threshold

在MGR结构中,一个事务的开销包含网络层以及本地资源(例如CPU、磁盘I/O等)开销,GreatSQL针对MGR的网络层开销进行了多项优化工作,因此在网络层的开销通常不会成为瓶颈。

当事务响应较慢想要分析性能瓶颈时,可以先确定是网络层的开销还是本地性能瓶颈导致的。通过设置选项 group_replication_request_time_threshold 即可记录超过阈值的事件,便于进一步分析。输出的内容记录在error log中,例如:

2022-03-04T09:45:34.602093+08:00 128 [Note] Plugin group_replication reported: 'MGR request time:33775'

表示当时这个事务在MGR层的网络开销耗时33.775毫秒,再去查看那个时段的网络监控,分析网络延迟较大的原因。

选项 group_replication_request_time_threshold 单位是微秒,默认值是0,最小值0,最大值100000000,建议值20000(即20毫秒)。

System Variable Namegroup_replication_request_time_threshold
Variable ScopeGlobal
Dynamic VariableYES
Permitted Values[0 ~ 100000000]
Default0
Description单位:微秒。
设置阈值,当一个事务的MGR层网络开销超过该阈值时,会在error log中输出一条记录。
设置为0时,表示不启用。
当怀疑可能因为MGR通信耗时过久成为事务性能瓶颈时,再开启,平时不建议开启。

1.4 调整MGR大事务限制

调整MGR事务限制选项 group_replication_transaction_size_limit,其默认值为150000000(同时也是最大值)。

在MySQL 5.7中,MGR事务没有进行分片处理,执行大事务很容易造成超时(并反复重发事务数据),最终导致节点报错并退出集群。

在GreatSQL 5.7中,针对该问题进行优化,并设置事务上限,超过该上限事务会失败回滚,但节点不会再退出集群。

注意,这是硬限制,即便将其设置为0,也会自动调整成150000000。

mysql> set global group_replication_transaction_size_limit = 150000001;
Query OK, 0 rows affected, 1 warning (0.00 sec)

-- 提示被重置了
mysql> show warnings;
+---------+------+-------------------------------------------------------------------------+
| Level   | Code | Message                                                                 |
+---------+------+-------------------------------------------------------------------------+
| Warning | 1292 | Truncated incorrect group_replication_transaction_si value: '150000001' |
+---------+------+-------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> set global group_replication_transaction_size_limit=0;
Query OK, 0 rows affected (0.00 sec)

-- 虽然没有error也没warning,但也被重置了
mysql> select @@global.group_replication_transaction_size_limit;
+---------------------------------------------------+
| @@global.group_replication_transaction_size_limit |
+---------------------------------------------------+
|                                         150000000 |
+---------------------------------------------------+

当执行一个超限的大事务时,会报告下面的错误:

ERROR 3100 (HY000): Error on observer while running replication hook 'before_commit'.

以测试工具sysbench生成的表为例,事务一次可批量执行的数据行上限约73.2万条记录:

mysql> insert into t1 select * from sbtest1 limit 732000;
Query OK, 732000 rows affected (16.07 sec)
Records: 732000  Duplicates: 0  Warnings: 0

mysql> insert into t1 select * from sbtest1limit 733000;
ERROR 3100 (HY000): Error on observer while running replication hook 'before_commit'.

如果大事务能执行成功,也会记录类似下面的日志,告知该事务的字节数:

[Note] Plugin group_replication reported: 'large transaction size:149856412'
System Variable Namegroup_replication_transaction_size_limit
Variable ScopeGlobal
Dynamic VariableYES
Permitted Values[0 ~ 150000000]
Default150000000
Description单位:Bytes。
设置大事务阈值,当一个MGR事务超过该阈值时,会在error log中输出一条记录

2.稳定性提升

  1. 修复了在异常情况下(节点崩溃,关闭节点,网络分区)的剧烈性能抖动问题。
  2. 提升数个大事务造成的长时间阻塞的问题。

3.性能提升

  1. 重新设计事务认证队列清理算法。MySQL社区版本中,对事务认证队列清理时采用了类似全表扫描的算法,清理效率较低,性能抖动较大。在GreatSQL版本中,对事务认证队列增加了类似索引机制,并控制每次清理的时间,可以有效解决清理效率低、性能抖动大的问题。
  2. 提升了Secondary节点上大事务并发应用回放的速度。
  3. 增加xcom cache条目,提升了在网络延迟较大或事务应用较慢场景下的性能。

4.bug修复

  1. 修复了在启用dns或hostname的情况下,bind意外失败问题。
  2. 修复了协程调度不合理的问题,该问题可能会造成在大事务时系统错误判断为网络错误。
  3. 修复了新加入节点在追paxos数据时,由于write超时导致连接提前关闭的问题。
  4. 修复了recovering节点被中途停止导致的数据异常问题。
  5. 修复了多主多写模式中,个别情况下可能丢数据的问题。
  6. 修复了在某些特殊场景下,多个节点同时启动一直处于recovering的状态
  7. 修复了applier线程在特殊场景下的诡异问题。
  8. 修复了在高并发情况下由于创建线程失败导致的死循环问题。
  9. 修复了某一个从节点hang住导致整个集群被拖垮的问题。
  10. 修复了单机部署多个节点场景下,tcp self connect导致的诡异问题。
  11. 修复了同时多个异常导致的视图问题。
  12. 修复了5个及以上节点数量同时重启导致的视图问题(某一个节点会一直处于recovering状态)。
  13. 修复了在某些场景下同时添加节点失败的问题。
  14. 修复了在特殊场景下组视图异常的问题。

Enjoy GreatSQL :)

文章推荐:

面向金融级应用的GreatSQL正式开源 https://mp.weixin.qq.com/s/cI_wPKQJuXItVWpOx_yNTg

Changes in GreatSQL 8.0.25 (2021-8-18) https://mp.weixin.qq.com/s/qcn0lmsMoLtaGO9hbpnhVg

MGR及GreatSQL资源汇总 https://mp.weixin.qq.com/s/qXMct_pOVN5FGoLsXSD0MA

GreatSQL MGR FAQ https://mp.weixin.qq.com/s/J6wkUpGXw3YkyEUJXiZ9xA

在Linux下源码编译安装GreatSQL/MySQL https://mp.weixin.qq.com/s/WZZOWKqSaGSy-mpD2GdNcA

关于 GreatSQL

GreatSQL是由万里数据库维护的MySQL分支,专注于提升MGR可靠性及性能,支持InnoDB并行查询特性,是适用于金融级应用的MySQL分支版本。

Gitee:

https://gitee.com/GreatSQL/GreatSQL

GitHub:

https://github.com/GreatSQL/GreatSQL

Bilibili:

https://space.bilibili.com/1363850082/video

微信&QQ群:

可搜索添加GreatSQL社区助手微信好友,发送验证信息“加群”加入GreatSQL/MGR交流微信群

QQ群:533341697

微信小助手:wanlidbc

本文由博客一文多发平台 OpenWrite 发布!

C:\Users\Administrator>sc query wuauserv # 查询服务状态 ERROR: Invalid Option DESCRIPTION: SC is a command line program used for communicating with the Service Control Manager and services. USAGE: sc <server> [command] [service name] <option1> <option2>... The option <server> has the form "\\ServerName" Further help on commands can be obtained by typing: "sc [command]" Commands: query-----------Queries the status for a service, or enumerates the status for types of services. queryex---------Queries the extended status for a service, or enumerates the status for types of services. start-----------Starts a service. pause-----------Sends a PAUSE control request to a service. interrogate-----Sends an INTERROGATE control request to a service. continue--------Sends a CONTINUE control request to a service. stop------------Sends a STOP request to a service. config----------Changes the configuration of a service (persistent). description-----Changes the description of a service. failure---------Changes the actions taken by a service upon failure. failureflag-----Changes the failure actions flag of a service. sidtype---------Changes the service SID type of a service. privs-----------Changes the required privileges of a service. managedaccount--Changes the service to mark the service account password as managed by LSA. qc--------------Queries the configuration information for a service. qdescription----Queries the description for a service. qfailure--------Queries the actions taken by a service upon failure. qfailureflag----Queries the failure actions flag of a service. qsidtype--------Queries the service SID type of a service. qprivs----------Queries the required privileges of a service. qtriggerinfo----Queries the trigger parameters of a service. qpreferrednode--Queries the preferred NUMA node of a service. qmanagedaccount-Queries whether a services uses an account with a password managed by LSA. qprotection-----Queries the process protection level of a service. quserservice----Queries for a local instance of a user service template. delete----------Deletes a service (from the registry). create----------Creates a service. (adds it to the registry). control---------Sends a control to a service. sdshow----------Displays a service's security descriptor. sdset-----------Sets a service's security descriptor. showsid---------Displays the service SID string corresponding to an arbitrary name. triggerinfo-----Configures the trigger parameters of a service. preferrednode---Sets the preferred NUMA node of a service. GetDisplayName--Gets the DisplayName for a service. GetKeyName------Gets the ServiceKeyName for a service. EnumDepend------Enumerates Service Dependencies. The following commands don't require a service name: sc <server> <command> <option> boot------------(ok | bad) Indicates whether the last boot should be saved as the last-known-good boot configuration Lock------------Locks the Service Database QueryLock-------Queries the LockStatus for the SCManager Database EXAMPLE: sc start MyService QUERY and QUERYEX OPTIONS: If the query command is followed by a service name, the status for that service is returned. Further options do not apply in this case. If the query command is followed by nothing or one of the options listed below, the services are enumerated. type= Type of services to enumerate (driver, service, userservice, all) (default = service) state= State of services to enumerate (inactive, all) (default = active) bufsize= The size (in bytes) of the enumeration buffer (default = 4096) ri= The resume index number at which to begin the enumeration (default = 0) group= Service group to enumerate (default = all groups) SYNTAX EXAMPLES sc query - Enumerates status for active services & drivers sc query eventlog - Displays status for the eventlog service sc queryex eventlog - Displays extended status for the eventlog service sc query type= driver - Enumerates only active drivers sc query type= service - Enumerates only Win32 services sc query state= all - Enumerates all services & drivers sc query bufsize= 50 - Enumerates with a 50 byte buffer sc query ri= 14 - Enumerates with resume index = 14 sc queryex group= "" - Enumerates active services not in a group sc query type= interact - Enumerates all interactive services sc query type= driver group= NDIS - Enumerates all NDIS drivers C:\Users\Administrator>sc query UsoSvc # 检查更新协调器 ERROR: Invalid Option DESCRIPTION: SC is a command line program used for communicating with the Service Control Manager and services. USAGE: sc <server> [command] [service name] <option1> <option2>... The option <server> has the form "\\ServerName" Further help on commands can be obtained by typing: "sc [command]" Commands: query-----------Queries the status for a service, or enumerates the status for types of services. queryex---------Queries the extended status for a service, or enumerates the status for types of services. start-----------Starts a service. pause-----------Sends a PAUSE control request to a service. interrogate-----Sends an INTERROGATE control request to a service. continue--------Sends a CONTINUE control request to a service. stop------------Sends a STOP request to a service. config----------Changes the configuration of a service (persistent). description-----Changes the description of a service. failure---------Changes the actions taken by a service upon failure. failureflag-----Changes the failure actions flag of a service. sidtype---------Changes the service SID type of a service. privs-----------Changes the required privileges of a service. managedaccount--Changes the service to mark the service account password as managed by LSA. qc--------------Queries the configuration information for a service. qdescription----Queries the description for a service. qfailure--------Queries the actions taken by a service upon failure. qfailureflag----Queries the failure actions flag of a service. qsidtype--------Queries the service SID type of a service. qprivs----------Queries the required privileges of a service. qtriggerinfo----Queries the trigger parameters of a service. qpreferrednode--Queries the preferred NUMA node of a service. qmanagedaccount-Queries whether a services uses an account with a password managed by LSA. qprotection-----Queries the process protection level of a service. quserservice----Queries for a local instance of a user service template. delete----------Deletes a service (from the registry). create----------Creates a service. (adds it to the registry). control---------Sends a control to a service. sdshow----------Displays a service's security descriptor. sdset-----------Sets a service's security descriptor. showsid---------Displays the service SID string corresponding to an arbitrary name. triggerinfo-----Configures the trigger parameters of a service. preferrednode---Sets the preferred NUMA node of a service. GetDisplayName--Gets the DisplayName for a service. GetKeyName------Gets the ServiceKeyName for a service. EnumDepend------Enumerates Service Dependencies. The following commands don't require a service name: sc <server> <command> <option> boot------------(ok | bad) Indicates whether the last boot should be saved as the last-known-good boot configuration Lock------------Locks the Service Database QueryLock-------Queries the LockStatus for the SCManager Database EXAMPLE: sc start MyService QUERY and QUERYEX OPTIONS: If the query command is followed by a service name, the status for that service is returned. Further options do not apply in this case. If the query command is followed by nothing or one of the options listed below, the services are enumerated. type= Type of services to enumerate (driver, service, userservice, all) (default = service) state= State of services to enumerate (inactive, all) (default = active) bufsize= The size (in bytes) of the enumeration buffer (default = 4096) ri= The resume index number at which to begin the enumeration (default = 0) group= Service group to enumerate (default = all groups) SYNTAX EXAMPLES sc query - Enumerates status for active services & drivers sc query eventlog - Displays status for the eventlog service sc queryex eventlog - Displays extended status for the eventlog service sc query type= driver - Enumerates only active drivers sc query type= service - Enumerates only Win32 services sc query state= all - Enumerates all services & drivers sc query bufsize= 50 - Enumerates with a 50 byte buffer sc query ri= 14 - Enumerates with resume index = 14 sc queryex group= "" - Enumerates active services not in a group sc query type= interact - Enumerates all interactive services sc query type= driver group= NDIS - Enumerates all NDIS drivers
最新发布
08-25
<think>我们正在解决用户关于如何使用sc query命令查询Windows服务状态的问题。用户之前遇到了服务名称无效的错误,现在想检查wuauserv和UsoSvc服务的状态。 根据引用[1],sc命令是用来与服务控制管理器通信的命令行工具。查询服务状态的命令是`sc query`。 步骤: 1. 打开命令提示符(管理员权限)。 2. 使用`sc query`命令后跟服务名称。 具体命令: - 查询wuauserv服务:`sc query wuauserv` - 查询UsoSvc服务:`sc query UsoSvc` 注意:服务名称区分大小写,但Windows服务名称通常不区分大小写。不过,为了准确,建议使用正确的大小写(通常是小写)。 如果服务存在,命令将返回该服务的详细信息,包括状态(运行中、停止等)。如果服务不存在,会返回错误。 另外,引用[2]提到可以使用PowerShell,但用户明确要求使用sc命令,因此我们专注于sc命令。 示例输出: ``` SERVICE_NAME: wuauserv TYPE : 20 WIN32_SHARE_PROCESS STATE : 4 RUNNING (STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN) WIN32_EXIT_CODE : 0 (0x0) SERVICE_EXIT_CODE : 0 (0x0) CHECKPOINT : 0x0 WAIT_HINT : 0x0 ``` 状态代码解释: - STATE: 4 表示运行中,1 表示停止。 如果服务名称错误或不存在,将返回: ``` [SC] EnumQueryServicesStatus:OpenService FAILED 1060: The specified service does not exist as an installed service. ``` 因此,用户可以通过这个命令来确认服务是否存在以及状态。 同时,我们也可以建议用户使用`sc query`命令不带参数来列出所有服务,但输出会很长。 另外,用户可能遇到权限问题,所以务必以管理员身份运行命令提示符(尽管查询状态通常不需要管理员权限,但某些服务可能需要)。 最后,我们根据要求生成相关问题。</think>### 如何正确使用 `sc query` 命令查询 Windows 服务状态 要检查 `wuauserv` 和 `UsoSvc` 服务的状态,请按以下步骤操作: #### 1. **基本查询语法** ```cmd sc query <service_name> ``` - 查询 Windows Update 服务: ```cmd sc query wuauserv ``` - 查询更新协调器服务: ```cmd sc query UsoSvc ``` #### 2. **关键输出字段解析** 执行命令后,重点关注以下字段: ```cmd SERVICE_NAME: wuauserv DISPLAY_NAME: Windows Update STATE : 4 RUNNING # 状态代码 ``` **服务状态代码含义**: - `1`:已停止 (`STOPPED`) - `2`:启动中 (`START_PENDING`) - `3`:停止中 (`STOP_PENDING`) - `4`:运行中 (`RUNNING`) #### 3. **高级查询技巧** - **显示所有服务**(需筛选): ```cmd sc query | findstr /i "SERVICE_NAME STATE" ``` - **检查服务依赖关系**: ```cmd sc qc wuauserv | findstr "DEPENDENCIES" ``` - **持续监控状态**(每2秒刷新): ```cmd sc query wuauserv & timeout /t 2 & cls & goto :loop ``` #### 4. **常见错误处理** - **错误 1060(服务不存在)**: ```cmd [SC] EnumQueryServicesStatus:OpenService FAILED 1060: ``` 表示服务未注册或名称错误,使用 `sc queryex type= service` 验证服务列表[^1]。 - **错误 5(权限不足)**: 以管理员身份运行 CMD 或 PowerShell: ```powershell Start-Process cmd -Verb runAs ``` #### 5. **替代方案(PowerShell)** ```powershell Get-Service -Name wuauserv, UsoSvc | Format-Table Name, Status, StartType ``` 输出示例: ``` Name Status StartType ---- ------ --------- wuauserv Running Automatic UsoSvc Running Manual ``` > **注意**:服务名称严格区分大小写,Windows 系统服务通常为全小写(如 `wuauserv`)[^1]。 --- ### 服务状态检查流程图 ```mermaid graph TD A[启动命令提示符] --> B{管理员权限?} B -->|否| C[以管理员身份运行] B -->|是| D[执行 sc query wuauserv] D --> E{输出STATE代码?} E -->|1-4| F[根据代码判断状态] E -->|错误1060| G[检查服务是否存在] G --> H[使用 sc queryex type=service] F --> I[分析DEPENDENCIES字段] ```
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值