Skip to content

fix: Remove beta table & migrate to gray #13603

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

wqyenjoy
Copy link

What does this PR do?

This PR fixes issue #13538 by restoring the config_info_beta table definition in mysql-schema.sql. This prevents false error logs reporting "master db xxx.xxx.xxx.xxx down" when the table is queried but doesn't exist.

Why are we doing this?

In Nacos 2.5.1, the config_info_beta table was removed from the MySQL schema, but some service implementations like ExternalConfigInfoBetaPersistServiceImpl still attempt to access it. This causes error logs in nacos-persistence.log even though the database is actually working fine.

How to test this PR?

  1. Initialize MySQL with the updated schema file
  2. Start Nacos configured to use the external MySQL
  3. Verify no errors like "master db xxx.xxx.xxx.xxx down" appear in the logs

Special notes for reviewer

This is a temporary solution. A more thorough fix would be to update all database health checks to consistently use config_info_gray instead of config_info_beta. I plan to address this in a follow-up PR.

@CLAassistant
Copy link

CLAassistant commented Jul 11, 2025

CLA assistant check
All committers have signed the CLA.

Copy link

lingma-agents bot commented Jul 11, 2025

修复config_info_beta表缺失导致的错误日志问题

变更概述

问题修复

  • 受影响组件: mysql-schema.sql 数据库表结构
  • 修复内容: 恢复config_info_beta表定义并修正config_info_gray表字段顺序
  • 技术细节:
    • mysql-schema.sql中新增config_info_beta表创建语句(包含iddata_idgroup_id等字段)
    • 调整config_info_gray表字段定义顺序,将tenant_idapp_name字段移至内容字段之前
    • 修正config_info_gray表唯一索引为uk_configinfogray_datagrouptenant(原为包含gray_name的复合索引)
  • 修复目的: 解决因表缺失导致的"master db down"错误日志误报问题
变更文件
文件路径 变更说明
distribution/​conf/​mysql-schema.​sql 新增config_info_beta表定义并调整config_info_gray表结构
时序图
sequenceDiagram
    participant NacosServer
    participant MySQL
    NacosServer->>MySQL: 执行健康检查查询
    MySQL-->>NacosServer: 返回config_info_beta表存在响应
    NacosServer->>NacosServer: 停止生成数据库连接错误日志
Loading

💡 小贴士

与 lingma-agents 交流的方式

📜 直接回复评论
直接回复本条评论,lingma-agents 将自动处理您的请求。例如:

  • 在当前代码中添加详细的注释说明。

  • 请详细介绍一下你说的 LRU 改造方案,并使用伪代码加以说明。

📜 在代码行处标记
在文件的特定位置创建评论并 @lingma-agents。例如:

  • @lingma-agents 分析这个方法的性能瓶颈并提供优化建议。

  • @lingma-agents 对这个方法生成优化代码。

📜 在讨论中提问
在任何讨论中 @lingma-agents 来获取帮助。例如:

  • @lingma-agents 请总结上述讨论并提出解决方案。

  • @lingma-agents 请根据讨论内容生成优化代码。

Copy link

@lingma-agents lingma-agents bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔎 代码评审报告

🎯 评审意见概览
严重度 数量 说明
🔴 Blocker 0 阻断性问题,需立即修复。例如:系统崩溃、关键功能不可用或严重安全漏洞。
🟠 Critical 2 严重问题,高优先级修复。例如:核心功能异常或性能瓶颈影响用户体验。
🟡 Major 1 主要问题,建议修复。例如:非核心功能缺陷或代码维护性较差。
🟢 Minor 0 次要问题,酬情优化。例如:代码格式不规范或注释缺失。

总计: 3 个问题

📋 评审意见详情
💡 代码实现建议
以下是文件级别的代码建议,聚焦于代码的可读性、可维护性和潜在问题。
🛢️ distribution/conf/mysql-schema.sql (3 💬)
🚀 架构设计建议
以下是对代码架构和设计的综合分析,聚焦于跨文件交互、系统一致性和潜在优化空间。
🔍1. 数据库架构不一致性:主键数据类型变更可能引发兼容性问题

在config_info_gray表中,id字段的数据类型从bigint unsigned变更为bigint(20),而其他表(如config_info_beta)仍使用类似定义。这种数据类型变更可能导致跨表数据操作时出现兼容性问题,例如与使用unsigned类型的历史数据交互时可能出现溢出或类型转换错误。建议统一所有自增主键字段的数据类型定义。

📌 关键代码

`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',

⚠️ 潜在风险

与历史数据或关联表操作时可能引发类型不匹配错误,导致查询或写入失败

🔍2. 唯一键约束变更破坏数据完整性

config_info_gray表的唯一键从uk_configinfogray_datagrouptenantgray(包含gray_name字段)变更为uk_configinfogray_datagrouptenant(移除了gray_name)。若业务逻辑依赖原唯一键的约束条件,则可能导致重复数据插入。需确认上游业务代码是否适配了该约束变更。

📌 关键代码

UNIQUE KEY `uk_configinfogray_datagrouptenant` (`data_id`,`group_id`,`tenant_id`)

⚠️ 潜在风险

可能产生不符合业务预期的重复数据,导致功能异常

🔍3. 字符集与校对规则不一致

新增的config_info_beta表使用utf8_bin校对规则,而其他表(如config_info_gray)使用默认的utf8校对规则。这种不一致可能导致跨表查询时出现字符比较不一致问题,特别是在多语言环境下可能引发数据检索错误。

📌 关键代码

) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='config_info_beta';

⚠️ 潜在风险

跨表查询时可能出现数据匹配错误,影响业务逻辑准确性

🔍4. 时间精度丢失风险未全局评估

config_info_gray表的gmt_create/gmt_modified字段移除了微秒精度(从datetime(3)改为datetime),但未确认其他依赖时间精度的表是否也同步调整。若系统存在依赖毫秒级时间戳的业务场景(如审计日志),可能导致时间记录精度丢失。

📌 关键代码

`gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间'

⚠️ 潜在风险

关键业务操作的时间记录精度下降,影响故障排查与合规审计

🔍5. 新增字段缺乏统一加密策略

config_info_beta表新增的encrypted_data_key字段默认值设为空字符串,但未与现有加密字段(如config_info表的encrypted_data_key)保持策略一致。若加密逻辑分散在多个表中,可能增加密钥管理复杂度和安全风险。

📌 关键代码

`encrypted_data_key` varchar(1024) NOT NULL DEFAULT '' COMMENT '密钥',

⚠️ 潜在风险

密钥管理策略不统一可能导致安全漏洞或维护成本增加

审查详情
📒 文件清单 (1 个文件)
📝 变更: 1 个文件

📝 变更文件:

  • distribution/conf/mysql-schema.sql

💡 小贴士

与 lingma-agents 交流的方式

📜 直接回复评论
直接回复本条评论,lingma-agents 将自动处理您的请求。例如:

  • 在当前代码中添加详细的注释说明。

  • 请详细介绍一下你说的 LRU 改造方案,并使用伪代码加以说明。

📜 在代码行处标记
在文件的特定位置创建评论并 @lingma-agents。例如:

  • @lingma-agents 分析这个方法的性能瓶颈并提供优化建议。

  • @lingma-agents 对这个方法生成优化代码。

📜 在讨论中提问
在任何讨论中 @lingma-agents 来获取帮助。例如:

  • @lingma-agents 请总结上述讨论并提出解决方案。

  • @lingma-agents 请根据讨论内容生成优化代码。

Copy link

Thanks for your this PR. 🙏
Please check again for your PR changes whether contains any usage/api/configuration change such as Add new API , Add new configuration, Change default value of configuration.
If so, please add or update documents(markdown type) in docs/next/ for repository nacos-group/nacos-group.github.io


感谢您提交的PR。 🙏
请再次查看您的PR内容,确认是否包含任何使用方式/API/配置参数的变更,如:新增API新增配置参数修改默认配置等操作。
如果是,请确保在提交之前,在仓库nacos-group/nacos-group.github.io中的docs/next/目录下添加或更新文档(markdown格式)。

@wqyenjoy wqyenjoy force-pushed the fix-config-info-beta-table branch from 5b1d4ac to e3976fd Compare July 13, 2025 01:35
@KomachiSion
Copy link
Collaborator

@wqyenjoy

This PR seems contain john's commit so that CLA check can't pass.

I suggest you close this PR and resubmit a new one without john's commit .

@wqyenjoy
Copy link
Author

@wqyenjoy

This PR seems contain john's commit so that CLA check can't pass.

I suggest you close this PR and resubmit a new one without john's commit .

ok,i will try it again

@wqyenjoy wqyenjoy force-pushed the fix-config-info-beta-table branch 2 times, most recently from 42660db to ad64abc Compare July 17, 2025 15:41
@wqyenjoy
Copy link
Author

@wqyenjoy

This PR seems contain john's commit so that CLA check can't pass.

I suggest you close this PR and resubmit a new one without john's commit .

fianlly,get it done.

@wqyenjoy
Copy link
Author

  • config_info_beta

finally,remove the onfig_info_beta table,and change the health check sql,and add some test case.

@wqyenjoy wqyenjoy changed the title fix: restore config_info_beta table in mysql-schema.sql to fix false … fix: Remove beta table & migrate to gray Jul 17, 2025
@KomachiSion
Copy link
Collaborator

  • config_info_beta

finally,remove the onfig_info_beta table,and change the health check sql,and add some test case.

The Indent problem still not fix

@wqyenjoy wqyenjoy force-pushed the fix-config-info-beta-table branch from ad64abc to 56cc1cd Compare July 18, 2025 08:30
@wqyenjoy
Copy link
Author

finally,pass ,result @KomachiSion 检查完成。
You have 0 Checkstyle violations.

@KomachiSion
Copy link
Collaborator

finally,pass ,result @KomachiSion 检查完成。 You have 0 Checkstyle violations.

OK, I will rerun the CI.

@KomachiSion
Copy link
Collaborator

@wqyenjoy It seems some problem in compile

@wqyenjoy
Copy link
Author

wqyenjoy commented Jul 21, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants