diff --git a/libsql-server/src/http/admin/mod.rs b/libsql-server/src/http/admin/mod.rs index 1bb50229d8..0a51d440b3 100644 --- a/libsql-server/src/http/admin/mod.rs +++ b/libsql-server/src/http/admin/mod.rs @@ -4,7 +4,7 @@ use axum::extract::{FromRef, Path, State}; use axum::middleware::Next; use axum::routing::delete; use axum::Json; -use chrono::{DateTime, Utc}; +use chrono::NaiveDateTime; use futures::{SinkExt, StreamExt, TryStreamExt}; use hyper::{Body, Request, StatusCode}; use metrics_exporter_prometheus::{PrometheusBuilder, PrometheusHandle}; @@ -427,7 +427,7 @@ async fn handle_create_namespace( #[derive(Debug, Deserialize)] struct ForkNamespaceReq { - timestamp: DateTime, + timestamp: NaiveDateTime, } async fn handle_fork_namespace( diff --git a/libsql-server/src/namespace/configurator/libsql_primary.rs b/libsql-server/src/namespace/configurator/libsql_primary.rs index 3d5a054698..7a368c79a0 100644 --- a/libsql-server/src/namespace/configurator/libsql_primary.rs +++ b/libsql-server/src/namespace/configurator/libsql_primary.rs @@ -3,7 +3,6 @@ use std::pin::Pin; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Arc; -use chrono::{DateTime, Utc}; use futures::prelude::Future; use libsql_sys::name::NamespaceResolver; use libsql_sys::wal::either::Either; @@ -270,7 +269,7 @@ impl ConfigureNamespace for LibsqlPrimaryConfigurator { _from_config: MetaStoreHandle, _to_ns: NamespaceName, _to_config: MetaStoreHandle, - timestamp: Option>, + timestamp: Option, _store: NamespaceStore, ) -> Pin> + Send + 'a>> { Box::pin(async move { @@ -284,7 +283,9 @@ impl ConfigureNamespace for LibsqlPrimaryConfigurator { .find_segment( &s.backend().default_config(), &ns, - libsql_wal::storage::backend::FindSegmentReq::Timestamp(ts), + libsql_wal::storage::backend::FindSegmentReq::Timestamp( + ts.and_utc(), + ), ) .await .unwrap(); diff --git a/libsql-server/src/namespace/configurator/libsql_replica.rs b/libsql-server/src/namespace/configurator/libsql_replica.rs index 8456482b4b..d460924dff 100644 --- a/libsql-server/src/namespace/configurator/libsql_replica.rs +++ b/libsql-server/src/namespace/configurator/libsql_replica.rs @@ -2,7 +2,6 @@ use std::future::Future; use std::pin::Pin; use std::sync::Arc; -use chrono::{DateTime, Utc}; use hyper::Uri; use libsql_replication::injector::LibsqlInjector; use libsql_replication::replicator::Replicator; @@ -266,7 +265,7 @@ impl ConfigureNamespace for LibsqlReplicaConfigurator { _from_config: MetaStoreHandle, _to_ns: NamespaceName, _to_config: MetaStoreHandle, - _timestamp: Option>, + _timestamp: Option, _store: NamespaceStore, ) -> Pin> + Send + 'a>> { Box::pin(std::future::ready(Err(crate::Error::Fork( diff --git a/libsql-server/src/namespace/configurator/libsql_schema.rs b/libsql-server/src/namespace/configurator/libsql_schema.rs index 8ee246fe84..190f4eb80f 100644 --- a/libsql-server/src/namespace/configurator/libsql_schema.rs +++ b/libsql-server/src/namespace/configurator/libsql_schema.rs @@ -1,7 +1,6 @@ use std::path::Path; use std::sync::Arc; -use chrono::{DateTime, Utc}; use futures::prelude::Future; use libsql_sys::name::NamespaceResolver; use libsql_wal::io::StdIO; @@ -160,13 +159,22 @@ impl ConfigureNamespace for LibsqlSchemaConfigurator { fn fork<'a>( &'a self, - _from_ns: &'a Namespace, - _from_config: MetaStoreHandle, - _to_ns: NamespaceName, - _to_config: MetaStoreHandle, - _timestamp: Option>, - _store: NamespaceStore, + from_ns: &'a Namespace, + from_config: MetaStoreHandle, + to_ns: NamespaceName, + to_config: MetaStoreHandle, + timestamp: Option, + store: NamespaceStore, ) -> std::pin::Pin> + Send + 'a>> { - todo!() + Box::pin(super::fork::fork( + from_ns, + from_config, + to_ns, + to_config, + timestamp, + store, + &self.primary_config, + self.base.base_path.clone(), + )) } } diff --git a/libsql-server/src/namespace/configurator/mod.rs b/libsql-server/src/namespace/configurator/mod.rs index a29d2315ca..bfcad5a02e 100644 --- a/libsql-server/src/namespace/configurator/mod.rs +++ b/libsql-server/src/namespace/configurator/mod.rs @@ -3,7 +3,7 @@ use std::pin::Pin; use std::sync::Arc; use std::time::Duration; -use chrono::{DateTime, Utc}; +use chrono::NaiveDateTime; use futures::Future; use libsql_sys::EncryptionConfig; use tokio::sync::Semaphore; @@ -139,7 +139,7 @@ pub trait ConfigureNamespace { from_config: MetaStoreHandle, to_ns: NamespaceName, to_config: MetaStoreHandle, - timestamp: Option>, + timestamp: Option, store: NamespaceStore, ) -> Pin> + Send + 'a>>; } diff --git a/libsql-server/src/namespace/configurator/primary.rs b/libsql-server/src/namespace/configurator/primary.rs index 487602417c..f68405fad6 100644 --- a/libsql-server/src/namespace/configurator/primary.rs +++ b/libsql-server/src/namespace/configurator/primary.rs @@ -3,7 +3,6 @@ use std::pin::Pin; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Arc; -use chrono::{DateTime, Utc}; use futures::prelude::Future; use libsql_sys::EncryptionConfig; use tokio::task::JoinSet; @@ -185,7 +184,7 @@ impl ConfigureNamespace for PrimaryConfigurator { from_config: MetaStoreHandle, to_ns: NamespaceName, to_config: MetaStoreHandle, - timestamp: Option>, + timestamp: Option, store: NamespaceStore, ) -> Pin> + Send + 'a>> { Box::pin(super::fork::fork( @@ -193,7 +192,7 @@ impl ConfigureNamespace for PrimaryConfigurator { from_config, to_ns, to_config, - timestamp.map(|d| d.naive_utc()), + timestamp, store, &self.primary_config, self.base.base_path.clone(), diff --git a/libsql-server/src/namespace/configurator/replica.rs b/libsql-server/src/namespace/configurator/replica.rs index 92ad8c5255..b4b67a027d 100644 --- a/libsql-server/src/namespace/configurator/replica.rs +++ b/libsql-server/src/namespace/configurator/replica.rs @@ -2,7 +2,6 @@ use std::pin::Pin; use std::sync::atomic::AtomicBool; use std::sync::Arc; -use chrono::{DateTime, Utc}; use futures::Future; use hyper::Uri; use libsql_replication::rpc::replication::log_offset::WalFlavor; @@ -256,7 +255,7 @@ impl ConfigureNamespace for ReplicaConfigurator { _from_config: MetaStoreHandle, _to_ns: NamespaceName, _to_config: MetaStoreHandle, - _timestamp: Option>, + _timestamp: Option, _store: NamespaceStore, ) -> Pin> + Send + 'a>> { Box::pin(std::future::ready(Err(crate::Error::Fork( diff --git a/libsql-server/src/namespace/configurator/schema.rs b/libsql-server/src/namespace/configurator/schema.rs index 3eb27082b6..275fd71e93 100644 --- a/libsql-server/src/namespace/configurator/schema.rs +++ b/libsql-server/src/namespace/configurator/schema.rs @@ -1,6 +1,5 @@ use std::sync::{atomic::AtomicBool, Arc}; -use chrono::{DateTime, Utc}; use futures::prelude::Future; use tokio::task::JoinSet; @@ -121,7 +120,7 @@ impl ConfigureNamespace for SchemaConfigurator { from_config: MetaStoreHandle, to_ns: NamespaceName, to_config: MetaStoreHandle, - timestamp: Option>, + timestamp: Option, store: NamespaceStore, ) -> std::pin::Pin> + Send + 'a>> { Box::pin(super::fork::fork( @@ -129,7 +128,7 @@ impl ConfigureNamespace for SchemaConfigurator { from_config, to_ns, to_config, - timestamp.map(|ts| ts.naive_utc()), + timestamp, store, &self.primary_config, self.base.base_path.clone(), diff --git a/libsql-server/src/namespace/store.rs b/libsql-server/src/namespace/store.rs index c3cbd5f010..f9f614fc77 100644 --- a/libsql-server/src/namespace/store.rs +++ b/libsql-server/src/namespace/store.rs @@ -2,7 +2,7 @@ use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Arc; use async_lock::RwLock; -use chrono::{DateTime, Utc}; +use chrono::NaiveDateTime; use futures::TryFutureExt; use moka::future::Cache; use once_cell::sync::OnceCell; @@ -219,7 +219,7 @@ impl NamespaceStore { from: NamespaceName, to: NamespaceName, to_config: DatabaseConfig, - timestamp: Option>, + timestamp: Option, ) -> crate::Result<()> { if self.inner.has_shutdown.load(Ordering::Relaxed) { return Err(Error::NamespaceStoreShutdown);