首批通过分布式安全可靠测评,为关键业务系统打造
insert ignore 导致正确性问题
更新时间:2024-01-16 11:56
问题现象
insert ignore 场景下,如果遇到语句内写入回滚+语句内触发了写日志(大事务),会出现正确性问题。该问题发生后,OBServer 日志中事务层可能会报错 replay checksum error,如果此时发生 OBServer 重启,事务层 checksum 校验的 error 有可能导致 OBServer 无法启动。该问题也有可能会进一步造成 OBServer 日志存储层 checksum 报错。
```shell
ERROR [CLOG] is_reconfirm_role_change_or_sync_timeout_ (ob_log_state_mgr.cpp:1953) [19204][0][xxx-xxx-xxx-xxx] [lt=5] [dc=0] is_reconfirm_role_change_or_sync_timeout_(partition_key={tid:xxxxx, partition_id:0, part_cnt:0}, role=1, now=xxxxx, last_check_start_id_time_=xxxxx, max_log_id=198126, start_id=198127, is_wait_replay=true) BACKTRACE:0xc0dc777 0x3ca0c62 0x3cf1091 0x3cf172e 0x6f4ce1b 0x6f4d157 0x6f5a875 0x6f5c040 0x6a250d7 0x6a18e20 0x3c423ae 0x5acbdca 0xbf77554 0xbf77102 0xbf6e2df
ERROR [STORAGE.REPLAY] pre_check_ (ob_log_replay_engine.cpp:1989) [18311][0][xxx-xxx-xxx-xxx] [lt=9] [dc=0] replay has encount fatal error(replay_status={ref_cnt_:3, replay_err_info_:{task_info_:{log_id_:197819, log_type_:4}, err_ts_:xxxxx, err_ret_:-4103}, last_task_info_:{log_id_:197819, log_type_:4}, post_barrier_status_:1, pending_task_count_:1, pending_abort_task_count_:0, pending_task_mutator_size_:0, eagain_count_:0, eagain_start_ts_:-1, total_submitted_task_num_:6484, total_replayed_task_num_:6483, is_enabled_:true, is_pending_:false, can_receive_log_:true, offline_partition_log_id_:xxxxx, offline_partition_task_submitted_:false, submit_log_task_:{ObReplayTask:{type_:1, enqueue_ts_:xxxxx, replay_status_:0x7f8a12432b40, fail_info_:{has_encount_fatal_error_:false, table_version_:0, fail_ts_:0, log_id_:0, log_type_:0, ret_code_:0}}, storage_log_type_:0, accum_checksum_:559957201, get_next_submit_log_id():197820, get_next_submit_log_ts():xxxxxx, get_last_slide_out_log_id():198127, get_last_slide_out_log_ts():xxxxx}}, task={ObReplayTask:{type_:2, enqueue_ts_:xxxxxx, replay_status_:0x7f8a12432b40, fail_info_:
```
问题原因
OBServer 从 V3.x 版本开始依赖回滚写日志来处理大事务。但是 insert ignore 的实现无法产生回滚日志(不支持语句内回滚),若在写完数据日志以后发生回滚,就可能产生在主库上回滚掉了数据,日志里却存在的情况, 这就会导致备库上回放出被回滚的数据, 导致不一致问题。
问题的风险及影响
leader follower 上数据不一致,OBServer 启动失败。
影响的版本
OceanBase 数据库企业版本 V3.1.2 BP10 (oceanbase-3.1.2-110000022022092714) 之前的版本、V3.2.3 (oceanbase-3.2.3.0-20220418212020) 之前的版本、V3.2.4 (oceanbase-3.2.4.0-100000072022102819) 之前的版本。
OceanBase 数据库社区版 V3.1.4_CE_BP3 (oceanbase-ce-3.1.4-103000102023020719) 之前的版本。
解决方法及规避方式
解决方法:
升级至问题已修复版本,目前已修复如下版本:
- OceanBase 数据库企业版 V3.1.2 BP10 (oceanbase-3.1.2-110000022022092714) 及之后版本、V3.2.3 (oceanbase-3.2.3.0-20220418212020) 及之后版本、V3.2.4 (oceanbase-3.2.4.0-100000072022102819) 修复版本。
- OceanBase 数据库社区版 V3.1.4_CE_BP3 (oceanbase-ce-3.1.4-103000102023020719) 及之后版本。
无法重启报
replay checksum error错误提示,可修改参数。ALTER SYSTEM SET ignore_replay_checksum_error=true;
ignore_replay_checksum_error用于设置是否忽略回放事务日志时发生的校验和错误,默认为 False。insert ignore导致存储层 checksum 报错,确定数据不一致的原因。建议联系 OceanBase 技术支持保障。