Skip to content

Commit

Permalink
fix: await after gc spawn blocking
Browse files Browse the repository at this point in the history
  • Loading branch information
marvin-j97 committed Jan 26, 2024
1 parent f9f0240 commit cacc45e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/src/content/docs/reference/env.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ HTTP port to listen to.

*Default: 9876*

##### `SMOLTABLE_WRITE_BUFFER_SIZE`
##### `SMOLTABLE_WRITE_BUFFER_SIZE_MB`

Global write buffer size, shared by all tables, locality groups, metrics tables and internal tables.

Expand Down
6 changes: 3 additions & 3 deletions server/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ pub fn metrics_cap_mb() -> u16 {
}

/// Global write buffer size
pub fn write_buffer_size() -> u32 {
let port = std::env::var("SMOLTABLE_WRITE_BUFFER_SIZE").unwrap_or("67108864".into());
pub fn write_buffer_size() -> u16 {
let port = std::env::var("SMOLTABLE_WRITE_BUFFER_SIZE_MB").unwrap_or("64".into());

port.parse::<u32>().expect("invalid metrics cap MB setting")
port.parse::<u16>().expect("invalid metrics cap MB setting")
}
8 changes: 7 additions & 1 deletion server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ async fn main() -> smoltable::Result<()> {

let keyspace = fjall::Config::new(data_folder())
.block_cache(block_cache.clone())
.max_write_buffer_size(u64::from(write_buffer_size()))
.max_write_buffer_size(u64::from(write_buffer_size()) * 1_024 * 1_024)
.open()?;

let manifest_table = ManifestTable::open(keyspace.clone())?;
Expand Down Expand Up @@ -119,9 +119,15 @@ async fn main() -> smoltable::Result<()> {
.allowed_header("*")
.max_age(3600);

// custom `Json` extractor configuration
let json_cfg = web::JsonConfig::default()
// limit request payload size
.limit(10 * 1_024 * 1_024);

App::new()
.wrap(cors)
.wrap(Logger::new("%r %s - %{User-Agent}i"))
.app_data(json_cfg)
.app_data(app_state.clone())
.route("/", web::get().to(render_dashboard))
.route("/index.html", web::get().to(render_dashboard))
Expand Down
4 changes: 3 additions & 1 deletion server/src/worker/gc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ pub async fn start(tables: Arc<RwLock<HashMap<String, MonitoredSmoltable>>>) {
}
};
}
});
})
.await
.expect("should join");

log::info!("TTL worker done");
tokio::time::sleep(Duration::from_secs(/* 24 hours*/ 21_600 * 4)).await;
Expand Down

0 comments on commit cacc45e

Please sign in to comment.