Repository: tikv/tikv
File: components/cdc/src/service.rs (Rust)

Code before:
        request: ChangeDataRequest,
        conn_id: ConnId,
    ) -> Result<(), String> {
        match request.request {
            None | Some(ChangeDataRequest_oneof_request::Register(_)) => {
                Self::handle_register(scheduler, peer, request, conn_id)
            }
            Some(ChangeDataRequest_oneof_request::Deregister(_)) => {
                Self::handle_deregister(scheduler, request, conn_id)
            }
            _ => unreachable!(),
        }
    }

    fn handle_register(
        scheduler: &Scheduler<Task>,
        peer: &str,
        request: ChangeDataRequest,
        conn_id: ConnId,
    ) -> Result<(), String> {
        let observed_range = ObservedRange::new(request.start_key.clone(), request.end_key.clone())
            .unwrap_or_else(|e| {
                warn!(
                    "cdc invalid observed start key or end key version";
                    "downstream" => ?peer, "region_id" => request.region_id, "request_id" => request.region_id,
                    "error" => ?e, "start_key" => ?request.start_key, "end_key" => ?request.end_key,
                );
                ObservedRange::default()
            });
        let downstream = Downstream::new(
            peer.to_owned(),
            request.get_region_epoch().clone(),
            RequestId(request.request_id),
            conn_id,
            request.kv_api,
            request.filter_loop,
            observed_range,
        );
        let task = Task::Register {
            request,
            downstream,
        };
        scheduler.schedule(task).map_err(|e| format!("{:?}", e))
    }

    fn handle_deregister(
        scheduler: &Scheduler<Task>,
        request: ChangeDataRequest,
        conn_id: ConnId,
    ) -> Result<(), String> {
        let task = if request.region_id != 0 {

Review comment (suggestion):
```suggestion
                    "downstream" => ?peer,
                    "region_id" => request.region_id,
                    "request_id" => request.region_id,
                    "error" => ?e,
                    "start_key" => ?request.start_key,
                    "end_key" => ?request.end_key,
```

Code after:
        request: ChangeDataRequest,
        conn_id: ConnId,
    ) -> Result<(), String> {
        match request.request {
            None | Some(ChangeDataRequest_oneof_request::Register(_)) => {
                Self::handle_register(scheduler, peer, request, conn_id)
            }
            Some(ChangeDataRequest_oneof_request::Deregister(_)) => {
                Self::handle_deregister(scheduler, request, conn_id)
            }
            _ => unreachable!(),
        }
    }

    fn handle_register(
        scheduler: &Scheduler<Task>,
        peer: &str,
        request: ChangeDataRequest,
        conn_id: ConnId,
    ) -> Result<(), String> {
        let observed_range = ObservedRange::new(request.start_key.clone(), request.end_key.clone())
            .unwrap_or_else(|e| {
                warn!(
                    "cdc invalid observed start key or end key version";
                    "downstream" => ?peer,
                    "region_id" => request.region_id,
                    "request_id" => request.region_id,
                    "error" => ?e,
                    "start_key" => log_wrappers::Value::key(&request.start_key),
                    "end_key" => log_wrappers::Value::key(&request.end_key),
                );
                ObservedRange::default()
            });
        let downstream = Downstream::new(
            peer.to_owned(),
            request.get_region_epoch().clone(),
            RequestId(request.request_id),
            conn_id,
            request.kv_api,
            request.filter_loop,
            observed_range,
        );
        let task = Task::Register {
            request,
            downstream,
        };
        scheduler.schedule(task).map_err(|e| format!("{:?}", e))
    }

    fn handle_deregister(
        scheduler: &Scheduler<Task>,