Skip to content
This repository was archived by the owner on Oct 18, 2023. It is now read-only.

lmdb meta storage #546

Merged
merged 2 commits into from
Jul 24, 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
162 changes: 103 additions & 59 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion libsqlx-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@ async-trait = "0.1.71"
axum = "0.6.18"
base64 = "0.21.2"
bincode = "1.3.3"
bytemuck = { version = "1.13.1", features = ["derive"] }
bytes = { version = "1.4.0", features = ["serde"] }
bytesize = { version = "1.2.0", features = ["serde"] }
clap = { version = "4.3.11", features = ["derive"] }
color-eyre = "0.6.2"
either = "1.8.1"
futures = "0.3.28"
heed = { version = "0.20.0-alpha.3", features = ["serde-bincode"] }
heed-types = "0.20.0-alpha.3"
hmac = "0.12.1"
humantime = "2.1.0"
hyper = { version = "0.14.27", features = ["h2", "server"] }
Expand All @@ -31,7 +34,6 @@ serde = { version = "1.0.166", features = ["derive", "rc"] }
serde_json = "1.0.100"
sha2 = "0.10.7"
sha3 = "0.10.8"
sled = "0.34.7"
tempfile = "3.6.0"
thiserror = "1.0.43"
tokio = { version = "1.29.1", features = ["full"] }
Expand Down
1 change: 0 additions & 1 deletion libsqlx-server/src/http/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ async fn list_allocs(
.handler()
.store()
.list_allocs()
.await
.into_iter()
.map(|cfg| AllocView { id: cfg.db_name })
.collect();
Expand Down
9 changes: 8 additions & 1 deletion libsqlx-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,14 @@ async fn main() -> Result<()> {

let mut join_set = JoinSet::new();

let store = Arc::new(Store::new(&config.db_path));

let meta_path = config.db_path.join("meta");
tokio::fs::create_dir_all(&meta_path).await?;
let env = heed::EnvOpenOptions::new()
.max_dbs(1000)
.map_size(100 * 1024 * 1024)
.open(meta_path)?;
let store = Arc::new(Store::new(env.clone()));
let manager = Arc::new(Manager::new(config.db_path.clone(), store.clone(), 100));
let bus = Arc::new(Bus::new(config.cluster.id, manager.clone()));

Expand Down
6 changes: 3 additions & 3 deletions libsqlx-server/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl Manager {
return Some(sender.clone());
}

if let Some(config) = self.meta_store.meta(&database_id).await {
if let Some(config) = self.meta_store.meta(&database_id) {
let path = self.db_path.join("dbs").join(database_id.to_string());
tokio::fs::create_dir_all(&path).await.unwrap();
let (alloc_sender, inbox) = mpsc::channel(MAX_ALLOC_MESSAGE_QUEUE_LEN);
Expand Down Expand Up @@ -73,12 +73,12 @@ impl Manager {
meta: &AllocConfig,
dispatcher: Arc<dyn Dispatch>,
) {
self.store().allocate(database_id, meta).await;
self.store().allocate(&database_id, meta);
self.schedule(database_id, dispatcher).await;
}

pub async fn deallocate(&self, database_id: DatabaseId) {
self.meta_store.deallocate(database_id).await;
self.meta_store.deallocate(&database_id);
self.cache.remove(&database_id).await;
let db_path = self.db_path.join("dbs").join(database_id.to_string());
tokio::fs::remove_dir_all(db_path).await.unwrap();
Expand Down
Loading