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

Removing planing loop #3913

Merged
merged 3 commits into from
Oct 6, 2023
Merged
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
46 changes: 10 additions & 36 deletions quickwit/quickwit-control-plane/src/control_plane.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,6 @@ pub(crate) const CONTROL_PLAN_LOOP_INTERVAL: Duration = if cfg!(any(test, featur
Duration::from_secs(3)
};

/// Interval between two scheduling of indexing plans. No need to be faster than the
/// control plan loop.
// Note: it's currently not possible to define a const duration with
// `CONTROL_PLAN_LOOP_INTERVAL * number`.
pub(crate) const REFRESH_PLAN_LOOP_INTERVAL: Duration = if cfg!(any(test, feature = "testsuite")) {
Duration::from_secs(3)
} else {
Duration::from_secs(60)
};

#[derive(Debug)]
struct RefreshPlanLoop;

#[derive(Debug)]
struct ControlPlanLoop;

Expand Down Expand Up @@ -134,7 +121,15 @@ impl Actor for ControlPlane {
.await
.context("failed to initialize ingest controller")?;

self.handle(RefreshPlanLoop, ctx).await?;
if let Err(error) = self
.indexing_scheduler
.schedule_indexing_plan_if_needed()
.await
{
// TODO inspect error.
error!("Error when scheduling indexing plan: `{}`.", error);
}

ctx.schedule_self_msg(CONTROL_PLAN_LOOP_INTERVAL, ControlPlanLoop)
.await;

Expand Down Expand Up @@ -218,28 +213,6 @@ impl Handler<DeleteIndexRequest> for ControlPlane {
}
}

#[async_trait]
impl Handler<RefreshPlanLoop> for ControlPlane {
type Reply = ();

async fn handle(
&mut self,
_message: RefreshPlanLoop,
ctx: &ActorContext<Self>,
) -> Result<(), ActorExitStatus> {
if let Err(error) = self
.indexing_scheduler
.schedule_indexing_plan_if_needed()
.await
{
error!("Error when scheduling indexing plan: `{}`.", error);
}
ctx.schedule_self_msg(REFRESH_PLAN_LOOP_INTERVAL, RefreshPlanLoop)
.await;
Ok(())
}
}

#[async_trait]
impl Handler<AddSourceRequest> for ControlPlane {
type Reply = ControlPlaneResult<EmptyResponse>;
Expand Down Expand Up @@ -331,6 +304,7 @@ impl Handler<DeleteSourceRequest> for ControlPlane {

self.ingest_controller
.delete_source(&index_uid, &request.source_id);

self.indexing_scheduler.on_index_change().await?;
let response = EmptyResponse {};
Ok(Ok(response))
Expand Down
6 changes: 3 additions & 3 deletions quickwit/quickwit-control-plane/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ use quickwit_proto::metastore::ListShardsResponse;
use quickwit_proto::NodeId;
use serde_json::json;

use crate::control_plane::{ControlPlane, CONTROL_PLAN_LOOP_INTERVAL, REFRESH_PLAN_LOOP_INTERVAL};
use crate::control_plane::{ControlPlane, CONTROL_PLAN_LOOP_INTERVAL};
use crate::scheduler::MIN_DURATION_BETWEEN_SCHEDULING;
use crate::IndexerNodeInfo;

Expand Down Expand Up @@ -270,9 +270,9 @@ async fn test_scheduler_scheduling_no_indexer() {
assert_eq!(scheduler_state.num_schedule_indexing_plan, 0);
assert!(scheduler_state.last_applied_physical_plan.is_none());

// Wait REFRESH_PLAN_LOOP_INTERVAL * 2, as there is no indexer, we should observe no
// There is no indexer, we should observe no
// scheduling.
universe.sleep(REFRESH_PLAN_LOOP_INTERVAL * 2).await;
universe.sleep(Duration::from_secs(60)).await;
let scheduler_state = scheduler_handler
.process_pending_and_observe()
.await
Expand Down