Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: flow refill time window after reboot #5238

Draft
wants to merge 22 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions src/cmd/src/flownode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use clap::Parser;
use client::client_manager::NodeClients;
use common_base::Plugins;
use common_config::Configurable;
use common_error::ext::BoxedError;
use common_grpc::channel_manager::ChannelConfig;
use common_meta::cache::{CacheRegistryBuilder, LayeredCacheRegistryBuilder};
use common_meta::heartbeat::handler::invalidate_table_cache::InvalidateCacheHandler;
Expand All @@ -38,8 +39,8 @@ use snafu::{OptionExt, ResultExt};
use tracing_appender::non_blocking::WorkerGuard;

use crate::error::{
BuildCacheRegistrySnafu, InitMetadataSnafu, LoadLayeredConfigSnafu, MetaClientInitSnafu,
MissingConfigSnafu, Result, ShutdownFlownodeSnafu, StartFlownodeSnafu,
BuildCacheRegistrySnafu, BuildCliSnafu, InitMetadataSnafu, LoadLayeredConfigSnafu,
MetaClientInitSnafu, MissingConfigSnafu, Result, ShutdownFlownodeSnafu, StartFlownodeSnafu,
};
use crate::options::{GlobalOptions, GreptimeOptions};
use crate::{log_versions, App};
Expand Down Expand Up @@ -301,7 +302,7 @@ impl StartCommand {
Plugins::new(),
table_metadata_manager,
catalog_manager.clone(),
flow_metadata_manager,
flow_metadata_manager.clone(),
)
.with_heartbeat_task(heartbeat_task);

Expand All @@ -316,7 +317,7 @@ impl StartCommand {
let client = Arc::new(NodeClients::new(channel_config));

let invoker = FrontendInvoker::build_from(
flownode.flow_worker_manager().clone(),
None,
catalog_manager.clone(),
cached_meta_backend.clone(),
layered_cache_registry.clone(),
Expand All @@ -330,6 +331,16 @@ impl StartCommand {
.set_frontend_invoker(invoker)
.await;

if let Err(err) = flownode
.flow_worker_manager()
.create_and_start_refill_flow_tasks(&flow_metadata_manager, &(catalog_manager as _))
.await
.map_err(BoxedError::new)
.context(BuildCliSnafu)
{
common_telemetry::error!(?err, "Failed to create and start refill flow tasks");
}

Ok(Instance::new(flownode, guard))
}
}
21 changes: 15 additions & 6 deletions src/cmd/src/standalone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ use tokio::sync::{broadcast, RwLock};
use tracing_appender::non_blocking::WorkerGuard;

use crate::error::{
BuildCacheRegistrySnafu, CreateDirSnafu, IllegalConfigSnafu, InitDdlManagerSnafu,
InitMetadataSnafu, InitTimezoneSnafu, LoadLayeredConfigSnafu, OtherSnafu, Result,
ShutdownDatanodeSnafu, ShutdownFlownodeSnafu, ShutdownFrontendSnafu, StartDatanodeSnafu,
StartFlownodeSnafu, StartFrontendSnafu, StartProcedureManagerSnafu,
BuildCacheRegistrySnafu, BuildCliSnafu, CreateDirSnafu, IllegalConfigSnafu,
InitDdlManagerSnafu, InitMetadataSnafu, InitTimezoneSnafu, LoadLayeredConfigSnafu, OtherSnafu,
Result, ShutdownDatanodeSnafu, ShutdownFlownodeSnafu, ShutdownFrontendSnafu,
StartDatanodeSnafu, StartFlownodeSnafu, StartFrontendSnafu, StartProcedureManagerSnafu,
StartWalOptionsAllocatorSnafu, StopProcedureManagerSnafu,
};
use crate::options::{GlobalOptions, GreptimeOptions};
Expand Down Expand Up @@ -580,7 +580,7 @@ impl StartCommand {
layered_cache_registry.clone(),
table_metadata_manager,
table_meta_allocator,
flow_metadata_manager,
flow_metadata_manager.clone(),
flow_meta_allocator,
)
.await?;
Expand All @@ -602,7 +602,7 @@ impl StartCommand {
let flow_worker_manager = flownode.flow_worker_manager();
// flow server need to be able to use frontend to write insert requests back
let invoker = FrontendInvoker::build_from(
flow_worker_manager.clone(),
Some(frontend.query_engine()),
catalog_manager.clone(),
kv_backend.clone(),
layered_cache_registry.clone(),
Expand All @@ -613,6 +613,15 @@ impl StartCommand {
.context(StartFlownodeSnafu)?;
flow_worker_manager.set_frontend_invoker(invoker).await;

if let Err(err) = flow_worker_manager
.create_and_start_refill_flow_tasks(&flow_metadata_manager, &(catalog_manager as _))
.await
.map_err(BoxedError::new)
.context(BuildCliSnafu)
{
common_telemetry::error!(err; "failed to refill flow");
}

let (tx, _rx) = broadcast::channel(1);

let servers = Services::new(opts, Arc::new(frontend.clone()), plugins)
Expand Down
Loading
Loading