Skip to content

Commit

Permalink
Initial WiredTiger tasks DB implementation
Browse files Browse the repository at this point in the history
Successfully persists stored tasks, and reconstitutes them on load.

Caveats:

* Design problem when reconstituting... these tasks need a Session
  that isn't NoopSession if they do background `notify` events. But how
  to get one? Some re-thinking and refactoring of session management
  has to be worked through, to separate the notion of "my" session
  created out of a connection event, a from "background" session --
  still attached to the same daemon/RpcServer, and to make it possible
  to go in and update these suspended tasks to have the latter.
* Implementation is for WiredTiger only, no Relbox yet
* No task loading from textdump yet.
  • Loading branch information
rdaum committed Jul 1, 2024
1 parent 87da385 commit 70c5141
Show file tree
Hide file tree
Showing 8 changed files with 565 additions and 44 deletions.
25 changes: 24 additions & 1 deletion crates/daemon/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ use crate::rpc_server::zmq_loop;

#[cfg(feature = "relbox")]
use moor_db_relbox::RelBoxDatabaseBuilder;
#[cfg(feature = "relbox")]
use moor_kernel::tasks::NoopTasksDb;
use moor_kernel::tasks::TasksDb;

mod connections;

Expand All @@ -45,6 +47,7 @@ mod connections_rb;
mod connections_wt;
mod rpc_server;
mod rpc_session;
mod tasks_wt;

#[macro_export]
macro_rules! clap_enum_variants {
Expand Down Expand Up @@ -84,6 +87,16 @@ struct Args {
)]
connections_file: PathBuf,

#[arg(
short = 'x',
long,
value_name = "tasks-db",
help = "Path to persistent tasks database to use or create",
value_hint = ValueHint::FilePath,
default_value = "tasks.db"
)]
tasks_db: PathBuf,

#[arg(
long,
value_name = "rpc-listen",
Expand Down Expand Up @@ -271,7 +284,17 @@ fn main() -> Result<(), Report> {
textdump_output: args.textdump_out,
};

let tasks_db = Box::new(NoopTasksDb {});
let tasks_db: Box<dyn TasksDb> = match args.db_flavour {
DatabaseFlavour::WiredTiger => {
let (tasks_db, _) = tasks_wt::WiredTigerTasksDb::open(Some(&args.tasks_db));
Box::new(tasks_db)
}
#[cfg(feature = "relbox")]
DatabaseFlavour::RelBox => {
warn!("RelBox does not support tasks persistence yet. Using a no-op tasks database. Suspended tasks will not resume on restart.");
Box::new(NoopTasksDb {})
}
};

// The pieces from core we're going to use:
// Our DB.
Expand Down
Loading

0 comments on commit 70c5141

Please sign in to comment.