You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/03/03 11:24:33 UTC

[GitHub] [arrow-datafusion] yahoNanJing opened a new pull request #1913: Refactor scheduler state mod

yahoNanJing opened a new pull request #1913:
URL: https://github.com/apache/arrow-datafusion/pull/1913


   # Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   Closes #1910.
   
    # Rationale for this change
   <!--
    Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.  
   -->
   
   Details see #1910.
   
   # What changes are included in this PR?
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   Details see #1910.
   
   # Are there any user-facing changes?
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   <!--
   If there are any breaking changes to public APIs, please add the `api change` label.
   -->
   It's blocked by #1908 and #1909


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow-datafusion] thinkharderdev commented on a change in pull request #1913: Refactor scheduler state mod

Posted by GitBox <gi...@apache.org>.
thinkharderdev commented on a change in pull request #1913:
URL: https://github.com/apache/arrow-datafusion/pull/1913#discussion_r820110604



##########
File path: ballista/rust/scheduler/src/state/persistent_state.rs
##########
@@ -0,0 +1,312 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use log::debug;
+use parking_lot::RwLock;
+use prost::Message;
+use std::any::type_name;
+use std::collections::HashMap;
+use std::sync::Arc;
+
+use ballista_core::error::{BallistaError, Result};
+
+use ballista_core::serde::protobuf::JobStatus;
+
+use crate::state::backend::StateBackendClient;
+use ballista_core::serde::scheduler::ExecutorMetadata;
+use ballista_core::serde::{protobuf, AsExecutionPlan, AsLogicalPlan, BallistaCodec};
+use datafusion::physical_plan::ExecutionPlan;
+use datafusion::prelude::ExecutionContext;
+
+type StageKey = (String, u32);
+
+#[derive(Clone)]
+pub(crate) struct PersistentSchedulerState<
+    T: 'static + AsLogicalPlan,
+    U: 'static + AsExecutionPlan,
+> {
+    // for db
+    config_client: Arc<dyn StateBackendClient>,
+    namespace: String,
+    pub(crate) codec: BallistaCodec<T, U>,
+
+    // for in-memory cache
+    executors_metadata: Arc<RwLock<HashMap<String, ExecutorMetadata>>>,

Review comment:
       Right, that part makes sense. I just am wondering whether it makes sense to, on a scheduler restart, to reload the executor state from persistent storage rather than let the executors re-register. In the latter case, executor metadata could be volatile state. 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow-datafusion] thinkharderdev commented on pull request #1913: Refactor scheduler state mod

Posted by GitBox <gi...@apache.org>.
thinkharderdev commented on pull request #1913:
URL: https://github.com/apache/arrow-datafusion/pull/1913#issuecomment-1063224596


   Sorry, meant to approve earlier. I'm good with this PR. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow-datafusion] yahoNanJing commented on a change in pull request #1913: Refactor scheduler state mod

Posted by GitBox <gi...@apache.org>.
yahoNanJing commented on a change in pull request #1913:
URL: https://github.com/apache/arrow-datafusion/pull/1913#discussion_r820328987



##########
File path: ballista/rust/scheduler/src/state/persistent_state.rs
##########
@@ -0,0 +1,312 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use log::debug;
+use parking_lot::RwLock;
+use prost::Message;
+use std::any::type_name;
+use std::collections::HashMap;
+use std::sync::Arc;
+
+use ballista_core::error::{BallistaError, Result};
+
+use ballista_core::serde::protobuf::JobStatus;
+
+use crate::state::backend::StateBackendClient;
+use ballista_core::serde::scheduler::ExecutorMetadata;
+use ballista_core::serde::{protobuf, AsExecutionPlan, AsLogicalPlan, BallistaCodec};
+use datafusion::physical_plan::ExecutionPlan;
+use datafusion::prelude::ExecutionContext;
+
+type StageKey = (String, u32);
+
+#[derive(Clone)]
+pub(crate) struct PersistentSchedulerState<
+    T: 'static + AsLogicalPlan,
+    U: 'static + AsExecutionPlan,
+> {
+    // for db
+    config_client: Arc<dyn StateBackendClient>,
+    namespace: String,
+    pub(crate) codec: BallistaCodec<T, U>,
+
+    // for in-memory cache
+    executors_metadata: Arc<RwLock<HashMap<String, ExecutorMetadata>>>,

Review comment:
       Suppose there's a cluster deployed on k8s in a standalone mode and we want to redeploy the scheduler. It would be better for the scheduler to reload the topology info from persistent storage. Whether the executor metadata be overdue or not, it should be managed by the executor heartbeat.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow-datafusion] yahoNanJing commented on a change in pull request #1913: Refactor scheduler state mod

Posted by GitBox <gi...@apache.org>.
yahoNanJing commented on a change in pull request #1913:
URL: https://github.com/apache/arrow-datafusion/pull/1913#discussion_r819972373



##########
File path: ballista/rust/scheduler/src/state/persistent_state.rs
##########
@@ -0,0 +1,312 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use log::debug;
+use parking_lot::RwLock;
+use prost::Message;
+use std::any::type_name;
+use std::collections::HashMap;
+use std::sync::Arc;
+
+use ballista_core::error::{BallistaError, Result};
+
+use ballista_core::serde::protobuf::JobStatus;
+
+use crate::state::backend::StateBackendClient;
+use ballista_core::serde::scheduler::ExecutorMetadata;
+use ballista_core::serde::{protobuf, AsExecutionPlan, AsLogicalPlan, BallistaCodec};
+use datafusion::physical_plan::ExecutionPlan;
+use datafusion::prelude::ExecutionContext;
+
+type StageKey = (String, u32);
+
+#[derive(Clone)]
+pub(crate) struct PersistentSchedulerState<
+    T: 'static + AsLogicalPlan,
+    U: 'static + AsExecutionPlan,
+> {
+    // for db
+    config_client: Arc<dyn StateBackendClient>,
+    namespace: String,
+    pub(crate) codec: BallistaCodec<T, U>,
+
+    // for in-memory cache
+    executors_metadata: Arc<RwLock<HashMap<String, ExecutorMetadata>>>,

Review comment:
       Thanks @thinkharderdev for reviewing this PR. Actually the executor metadata is persistent to some backend storage. However, for fast reading, they are cached in memory. For all of those states in *PersistentSchedulerState*, firstly they will be persistent. Then they will be cached in memory.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow-datafusion] thinkharderdev commented on a change in pull request #1913: Refactor scheduler state mod

Posted by GitBox <gi...@apache.org>.
thinkharderdev commented on a change in pull request #1913:
URL: https://github.com/apache/arrow-datafusion/pull/1913#discussion_r819907547



##########
File path: ballista/rust/scheduler/src/state/persistent_state.rs
##########
@@ -0,0 +1,312 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use log::debug;
+use parking_lot::RwLock;
+use prost::Message;
+use std::any::type_name;
+use std::collections::HashMap;
+use std::sync::Arc;
+
+use ballista_core::error::{BallistaError, Result};
+
+use ballista_core::serde::protobuf::JobStatus;
+
+use crate::state::backend::StateBackendClient;
+use ballista_core::serde::scheduler::ExecutorMetadata;
+use ballista_core::serde::{protobuf, AsExecutionPlan, AsLogicalPlan, BallistaCodec};
+use datafusion::physical_plan::ExecutionPlan;
+use datafusion::prelude::ExecutionContext;
+
+type StageKey = (String, u32);
+
+#[derive(Clone)]
+pub(crate) struct PersistentSchedulerState<
+    T: 'static + AsLogicalPlan,
+    U: 'static + AsExecutionPlan,
+> {
+    // for db
+    config_client: Arc<dyn StateBackendClient>,
+    namespace: String,
+    pub(crate) codec: BallistaCodec<T, U>,
+
+    // for in-memory cache
+    executors_metadata: Arc<RwLock<HashMap<String, ExecutorMetadata>>>,

Review comment:
       Should executor metadata be persistent? Seems like it could be useful to speed up a scheduler restart since it would have to wait for executors to re-register but it seems like in the case of push-based scheduling we need to wait for heartbeats anyway and in the poll-based scheduling we wouldn't schedule work until the executor registers. 
   




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow-datafusion] alamb merged pull request #1913: Refactor scheduler state mod

Posted by GitBox <gi...@apache.org>.
alamb merged pull request #1913:
URL: https://github.com/apache/arrow-datafusion/pull/1913


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow-datafusion] alamb commented on pull request #1913: Refactor scheduler state mod

Posted by GitBox <gi...@apache.org>.
alamb commented on pull request #1913:
URL: https://github.com/apache/arrow-datafusion/pull/1913#issuecomment-1061165151


   Let's try and get https://github.com/apache/arrow-datafusion/issues/1909 merged as soon as possible so you don't have to manage a large chain of PRs 
   
   The work going into Ballista these days is pretty exciting!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow-datafusion] alamb commented on pull request #1913: Refactor scheduler state mod

Posted by GitBox <gi...@apache.org>.
alamb commented on pull request #1913:
URL: https://github.com/apache/arrow-datafusion/pull/1913#issuecomment-1064110846


   This seems like it is moving code around and thus largely unobjectionable. Merging it to keep things moving. 
   
   Thanks @yahoNanJing  and @thinkharderdev 
   
   cc @liukun4515 @realno @mingmwang


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow-datafusion] yahoNanJing commented on pull request #1913: Refactor scheduler state mod

Posted by GitBox <gi...@apache.org>.
yahoNanJing commented on pull request #1913:
URL: https://github.com/apache/arrow-datafusion/pull/1913#issuecomment-1063069190


   Hi @alamb and @thinkharderdev, could you help review this PR?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org