物化视图异步刷新时,报错: com.starrocks.common.UserException: Bad page: checksum mismatch

背景:创建异步物化视图后刷新失败,查看errormsg为:

com.starrocks.common.UserException: Bad page: checksum mismatch (actual=1411277864 vs expect=2922535458), file=/data/emr/starrocks/be/storage/data/524/2452185/1119514271/020000000017c064b042fcc077703d196a7cda02d4f10192_0.dat

################################################################################
base table 1 ddl

CREATE TABLE `interactions` (
  `address` varchar(100) NOT NULL COMMENT "",
  `hash` varchar(100) NOT NULL COMMENT "",
  `index` int(11) NOT NULL COMMENT "",
  `internal_index` varchar(50) NOT NULL COMMENT "",
  `block_timestamp` datetime NOT NULL COMMENT "",
  `flow_type` varchar(10) NOT NULL COMMENT "",
  `block_number` int(11) NOT NULL COMMENT "",
  `contract_method_id` varchar(100) NULL COMMENT "",
  `interact_address` varchar(100) NULL COMMENT "",
  `amount_raw` varchar(100) NULL COMMENT "",
  `token_symbol` varchar(100) NULL COMMENT ""
) ENGINE=OLAP 
UNIQUE KEY(`address`, `hash`, `index`, `internal_index`, `block_timestamp`, `flow_type`)
COMMENT "OLAP"
DISTRIBUTED BY HASH(`address`) BUCKETS 3000

base table 2 ddl

CREATE TABLE `asset_flow` (
  `address` varchar(100) NOT NULL COMMENT "",
  `hash` varchar(100) NOT NULL COMMENT "",
  `index` int(11) NOT NULL COMMENT "",
  `internal_index` varchar(50) NOT NULL COMMENT "",
  `block_timestamp` datetime NOT NULL COMMENT "",
  `asset_address` varchar(100) NOT NULL COMMENT "",
  `flow_type` varchar(10) NOT NULL COMMENT "",
  `block_number` int(11) NOT NULL COMMENT "",
  `interact_address` varchar(100) NULL COMMENT "",
  `nft_token_id` varchar(100) NULL COMMENT "",
  `amount_raw` varchar(100) NULL COMMENT "",
  INDEX asset_address (`asset_address`) USING BITMAP COMMENT ''
) ENGINE=OLAP 
UNIQUE KEY(`address`, `hash`, `index`, `internal_index`, `block_timestamp`, `asset_address`, `flow_type`)
COMMENT "OLAP"
DISTRIBUTED BY HASH(`address`) BUCKETS 3000

物化视图查询如下:

with source_asset_flow as (
select
a.*,
b.protocol_slug 
from asset_flow a
inner join contract_info b
on a.address = b.address
where a.timestamp >= date_sub(CURRENT_TIMESTAMP(), INTERVAL 30 day)
)
, source_intercations as (
select
a.*
from interactions a
inner join contract_info b
on a.address = b.address
where a.timestamp >= date_sub(CURRENT_TIMESTAMP(), INTERVAL 30 day)
)
, one_day_volume as (
 select
  protocol_slug,
  sum(amount_raw) as value
 from source_asset_flow
 where timestamp >= date_sub(CURRENT_TIMESTAMP(), INTERVAL 1 day)
)
, one_month_volume as (
 select
  protocol_slug,
  sum(amount_raw) as value
 from source_asset_flow
 where timestamp >= date_sub(CURRENT_TIMESTAMP(), INTERVAL 30 day)
)
, one_day_interaction as (
 select
  protocol_slug,
  count(distinct hash) as num_of_tx,
  count(distinct intercat_address) as num_of_users
 from source_intercations
 where timestamp >= date_sub(CURRENT_TIMESTAMP(), INTERVAL 1 day)
)
, one_month_interaction as (
 select
  protocol_slug,
  count(distinct hash) as num_of_tx,
  count(distinct intercat_address) as num_of_users
 from source_intercations
 where timestamp >= date_sub(CURRENT_TIMESTAMP(), INTERVAL 30 day)
)
select
a.*,
b.value,
c.value,
d.num_of_tx,
d.num_of_users,
e.num_of_tx,
e.num_of_users
from contract_info a
left join one_day_volume b 
on a.protocol_slug = b.protocol_slug
left join one_month_volume c
on a.protocol_slug = c.protocol_slug
left join one_day_interaction d
on a.protocol_slug = d.protocol_slug
left join one_month_interaction e
on a.protocol_slug = e.protocol_slug

已解决
原因:base table (asset_flow) 某个tablet文件损坏导致checksum和预期不合。
解决方法:

  1. 根据文件路径确定损坏tablet所在be位置,确定tablet_id和backendId
  2. show tablet ${tablet_id}查看detail
  3. 设置异常backendid下的副本 status=bad,如: ADMIN SET REPLICA STATUS PROPERTIES ("tablet_id" = "44232","backend_id"="10005", "status" = "bad") 等sr修复
1赞