risingwave_ctl/cmd_impl/meta/
resume_backfill.rs

1// Copyright 2026 RisingWave Labs
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15use anyhow::{Result, anyhow};
16use risingwave_pb::ddl_service::RisectlResumeBackfillRequest;
17use risingwave_pb::ddl_service::risectl_resume_backfill_request::Target;
18use risingwave_pb::id::{FragmentId, JobId};
19
20use crate::CtlContext;
21
22pub async fn resume_backfill(
23    context: &CtlContext,
24    job_id: Option<JobId>,
25    fragment_id: Option<FragmentId>,
26) -> Result<()> {
27    let target = match (job_id, fragment_id) {
28        (Some(job_id), None) => Target::JobId(job_id),
29        (None, Some(fragment_id)) => Target::FragmentId(fragment_id),
30        _ => {
31            return Err(anyhow!(
32                "exactly one of job_id or fragment_id must be provided"
33            ));
34        }
35    };
36
37    let meta_client = context.meta_client().await?;
38    meta_client
39        .risectl_resume_backfill(RisectlResumeBackfillRequest {
40            target: Some(target),
41        })
42        .await?;
43    println!("Done.");
44    Ok(())
45}