diff --git a/tx_service/include/cc/cc_request.h b/tx_service/include/cc/cc_request.h index 6b266621..50c78175 100644 --- a/tx_service/include/cc/cc_request.h +++ b/tx_service/include/cc/cc_request.h @@ -4342,6 +4342,8 @@ struct RangePartitionDataSyncScanCc : public CcRequestBase bool IsSlicePinned(uint16_t core_id) const { + assert(export_base_table_item_ || + curr_slice_index_[core_id] < slices_to_scan_.size()); return export_base_table_item_ ? true : slices_to_scan_[curr_slice_index_[core_id]].second; diff --git a/tx_service/include/cc/template_cc_map.h b/tx_service/include/cc/template_cc_map.h index d32c8e32..6af998f4 100644 --- a/tx_service/include/cc/template_cc_map.h +++ b/tx_service/include/cc/template_cc_map.h @@ -5610,7 +5610,11 @@ class TemplateCcMap : public CcMap recycle_ts = shard_->GlobalMinSiTxStartTs(); } - bool slice_pinned = req.IsSlicePinned(shard_->core_id_); + // If reach to the batch end, it means there are no slices that need to + // be scanned. + bool slice_pinned = req.TheBatchEnd(shard_->core_id_) + ? false + : req.IsSlicePinned(shard_->core_id_); // The following flag is used to mark the behavior of one slice. // Only need to export the key if the key is already persisted, this // will happen when the slice need to split, and should export all the @@ -5718,7 +5722,11 @@ class TemplateCcMap : public CcMap std::tie(key_it, slice_end_it, slice_end_key) = find_non_empty_slice(*search_start_key); - slice_pinned = req.IsSlicePinned(shard_->core_id_); + // If reach to the batch end, it means there are no slices + // that need to be scanned. + slice_pinned = req.TheBatchEnd(shard_->core_id_) + ? false + : req.IsSlicePinned(shard_->core_id_); export_persisted_key_only = !req.export_base_table_item_ && slice_pinned; }