V5.15.0升级到最新的V6.ga8后不断报数据库错误

Viewed 54

这是alerting_engines的表结构
image.png

5月 31 09:48:24 nightingale n9e[5547]: 2023/05/31 09:48:24 /home/runner/work/nightingale/nightingale/models/alerting_engine.go:157 Error 1062: Duplicate entry '192.168.99.27:443' for key 'instance'
5月 31 09:48:24 nightingale n9e[5547]: [22.548ms] [rows:0] INSERT INTO `alerting_engines` (`instance`,`engine_cluster`,`datasource_id`,`clock`) VALUES ('192.168.99.27:443','default',100000,1685497704)
2 Answers

你是先升级到 5.15,然后又升级的v6么?通过 show create table alerting_engines\G 可以看到表结构。可以和github上最新的 表结构 做个对比,看起来是 unique 索引问题

删除
instance的索引就正常了

show create table alerting_engines\G; 
Create Table: CREATE TABLE `alerting_engines` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `instance` varchar(128) NOT NULL DEFAULT '' COMMENT 'instance identification, e.g. 10.9.0.9:9090',
  `engine_cluster` varchar(128) NOT NULL DEFAULT '' COMMENT 'n9e-alert cluster',
  `clock` bigint(20) NOT NULL,
  `datasource_id` bigint(20) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  UNIQUE KEY `instance` (`instance`)
) ENGINE=InnoDB AUTO_INCREMENT=8676 DEFAULT CHARSET=utf8mb4

n9e.sql
CREATE TABLE `alerting_engines`
(
    `id` int unsigned NOT NULL AUTO_INCREMENT,
    `instance` varchar(128) not null default '' comment 'instance identification, e.g. 10.9.0.9:9090',
    `datasource_id` bigint not null default 0 comment 'datasource id',
    `engine_cluster` varchar(128) not null default '' comment 'n9e-alert cluster',
    `clock` bigint not null,
    PRIMARY KEY (`id`)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4;

很不一样!!!