matrixorigin / matrixone

Hyperconverged cloud-edge native database
https://docs.matrixorigin.cn/en
Apache License 2.0
1.79k stars 277 forks source link

[Bug]: results of count(*) are incorrect and are different for the same table and filter(varchar type) for different times #14623

Closed aressu1985 closed 9 months ago

aressu1985 commented 9 months ago

Is there an existing issue for the same bug?

Branch Name

main

Commit ID

aa9296994ca4244ce70f8ea1f433e742319371ae

Other Environment Information

- Hardware parameters: 64C 129G
- OS type:
- Others:

Actual Behavior

result are different in different times:

mysql> select count() from ecbase_Card ec WHERE ec.vc_code = 'ANZBCNSH434'; +----------+ | count() | +----------+ | 12117934 | +----------+ 1 row in set (0.20 sec)

mysql> select count() from ecbase_Card ec WHERE ec.vc_code = 'ANZBCNSH434'; +----------+ | count() | +----------+ | 15402926 | +----------+ 1 row in set (0.04 sec)

mysql> select count(1) from ecbase_Card ec WHERE ec.vc_code = 'ZBBKCNBZ451'; +----------+ | count(1) | +----------+ | 11649626 | +----------+ 1 row in set (0.18 sec)

mysql> select count(1) from ecbase_Card ec WHERE ec.vc_code = 'ZBBKCNBZ451'; +----------+ | count(1) | +----------+ | 15671898 | +----------+ 1 row in set (0.07 sec)

mysql> select count(1) from ecbase_Card ec WHERE ec.vc_code = 'ZBBKCNBZ435'; +----------+ | count(1) | +----------+ | 12304984 | +----------+ 1 row in set (0.39 sec)

mysql> select count(1) from ecbase_Card ec WHERE ec.vc_code = 'ZBBKCNBZ435'; +----------+ | count(1) | +----------+ | 15663704 | +----------+ 1 row in set (0.08 sec)

result are not consistent: mysql> select count() from ecbase_card ec WHERE ec.vc_code in ('ZBBKCNBZ451','ANZBCNSH434','ZBBKCNBZ435'); +----------+ | count() | +----------+ | 962 | +----------+ 1 row in set (0.13 sec)

mysql> select count() from ecbase_card ec WHERE ec.vc_code = 'ZBBKCNBZ451'; +----------+ | count() | +----------+ | 15671898 | +----------+ 1 row in set (0.09 sec)

mysql> select count() from ecbase_card ec WHERE ec.vc_code = 'ANZBCNSH434'; +----------+ | count() | +----------+ | 12117934 | +----------+ 1 row in set (0.17 sec)

mysql> select count() from ecbase_card ec WHERE ec.vc_code = 'ZBBKCNBZ435'; +----------+ | count() | +----------+ | 12304984 | +----------+ 1 row in set (0.17 sec)

mo-log: mo-service-count-error.tar.gz

Expected Behavior

No response

Steps to Reproduce

DDL:
CREATE TABLE `ecbase_card` (
`id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '自增主键',
`company_id` BIGINT NOT NULL COMMENT '所属企业Id,作为分区字段,与自增长id作为联合主键',
`code` VARCHAR(32) DEFAULT null COMMENT '车企编码 kafak导入',
`platform_id` VARCHAR(64) DEFAULT null COMMENT '平台ID',
`subs_id` VARCHAR(32) DEFAULT null COMMENT '用户id kafak导入',
`uuid` VARCHAR(64) NOT NULL COMMENT '唯一标识',
`create_time` DATETIME NOT NULL COMMENT '创建时间',
`create_by` VARCHAR(255) DEFAULT null COMMENT '创建者',
`update_time` DATETIME DEFAULT null COMMENT '更新时间',
`update_by` VARCHAR(255) DEFAULT null COMMENT '更新者',
`iccid` VARCHAR(32) NOT NULL COMMENT 'ICCID',
`imsi` VARCHAR(32) DEFAULT null COMMENT 'IMSI kafak导入',
`msisdn` VARCHAR(32) DEFAULT null COMMENT 'IMSI kafak导入',
`carrier` INT NOT NULL COMMENT '所属运营商',
`imei` VARCHAR(32) DEFAULT null COMMENT 'IMEI',
`vin` VARCHAR(32) DEFAULT null COMMENT '车辆VIN码',
`open_time` DATETIME DEFAULT null COMMENT '开户日期',
`active_date` DATETIME DEFAULT null COMMENT '激活日期',
`network_type` VARCHAR(8) DEFAULT null COMMENT '网络类型(字典项编码)',
`card_type` VARCHAR(8) DEFAULT null COMMENT '卡片物理类型(字典项编码)',
`belong_place` VARCHAR(32) DEFAULT null COMMENT '归属地',
`remark` VARCHAR(255) DEFAULT null COMMENT '备注',
`card_status` VARCHAR(8) DEFAULT null COMMENT '卡状态字典项编码,根据平台区分 kafak导入',
`status_time` DATETIME DEFAULT null COMMENT '卡号状态变更时间',
`vehicle_status` INT DEFAULT null COMMENT '车辆状态',
`vehicle_out_factory_time` DATETIME DEFAULT null COMMENT '车辆出厂时间',
`realname_status` INT DEFAULT '0' COMMENT '实名状态:0-初始化未实名,1-受理成功处理中,2-实名登记成功,3-实名注销成功',
`realname_status_t1` INT DEFAULT null COMMENT 't1实名状态:1:已实名,2:未实名',
`pay_account_id` VARCHAR(32) DEFAULT null COMMENT '付费账户id',
`pay_account_name` VARCHAR(64) DEFAULT null COMMENT '付费账户名称',
`plat_type` VARCHAR(8) DEFAULT null COMMENT '平台类型2:pb 3:ct',
`cust_id` VARCHAR(32) DEFAULT null COMMENT '客户id kafak导入',
`cust_name` VARCHAR(32) DEFAULT null COMMENT '客户名称',
`cust_type` VARCHAR(32) DEFAULT null COMMENT '客户类型 一般为C客户类型',
`be_id` VARCHAR(32) DEFAULT null COMMENT '省份编码',
`region_id` VARCHAR(32) DEFAULT null COMMENT '归属地编码',
`group_id` VARCHAR(128) DEFAULT null COMMENT '归属群组id',
`group_member_status` VARCHAR(128) DEFAULT null COMMENT '归属群组中成员状态',
`group_pool_data_usage` BIGINT DEFAULT null COMMENT '归属群组中本月池内用量',
`cust_code` VARCHAR(255) DEFAULT null COMMENT '客户集团编码',
`sync_time` DATETIME DEFAULT null COMMENT '通过kafka入库时,每次必须更新的字段,其他入口不用变动',
`boss` INT NOT NULL COMMENT '运营商BOSS系统,1-移动CT,2-移动PB,3-电信DCP,4-电信M2M,5-联通jasper,6-联通CMP,7-中国电信5GCMP平台',
`account_id` BIGINT DEFAULT null COMMENT 'BOSS系统账号id',
`vc_code` VARCHAR(32) DEFAULT null COMMENT '车企vc_code',
`source_create_time` DATETIME DEFAULT null COMMENT '源端数据创建时间',
`source_modify_time` DATETIME DEFAULT null COMMENT '源端数据修改时间',
`device_num` VARCHAR(32) DEFAULT null COMMENT '设备号',
PRIMARY KEY (`id`,`company_id`),
UNIQUE KEY `uk_ecbase_card_uuid` (`uuid`),
UNIQUE KEY `uk_ecbase_card_vc_code_iccid` (`vc_code`,`iccid`) COMMENT '20231021新增',
KEY `ecbase_card_ecbase_company_id_fk` (`company_id`),
KEY `idx_ecbase_card_create_time` (`create_time`),
KEY `idx_account_id` (`account_id`),
KEY `ecbase_card_subs_id` (`subs_id`) COMMENT '20230529新增',
KEY `idx_ecbase_card_msisdn` (`msisdn`),
KEY `ecbase_card_vc_code_carrier_card_status_idx` (`vc_code`,`carrier`,`card_status`),
KEY `ecbase_card_vc_code_vehicle_status_idx` (`vc_code`,`vehicle_status`),
KEY `ecbase_card_vc_code_realname_status_idx` (`vc_code`,`realname_status`),
KEY `ecbase_card_vin_idx` (`vin`),
KEY `ecbase_card_iccid` (`iccid`) COMMENT '2310.7新增'
) COMMENT='卡信息表';

the table data in on 129 svc, pwd: /data1/sudong/mock-data-generator/data/oneiov

SQL:
select count(*) from ecbase_Card ec WHERE ec.vc_code = 'ANZBCNSH434';
select count(1) from ecbase_Card ec WHERE ec.vc_code = 'ZBBKCNBZ451';

Additional information

No response

XuPeng-SH commented 9 months ago

similar to #14624

w-zr commented 9 months ago

already fixed by #14602

aressu1985 commented 9 months ago

fixed