MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / shared_write_buffer_manager

Function shared_write_buffer_manager

src/rocksdb/tests/basic.rs:313–412  ·  view source on GitHub ↗

unsupported operation: can't call foreign function `rocksdb_create_default_env` on OS `linux`

()

Source from the content-addressed store, hash-verified

311#[mz_ore::test(tokio::test)]
312#[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `rocksdb_create_default_env` on OS `linux`
313async fn shared_write_buffer_manager() -> Result<(), anyhow::Error> {
314 // If the test aborts, this may not be cleaned up.
315 let t = tempfile::tempdir()?;
316
317 let write_buffer_memory_bytes = 10000;
318
319 let shared_write_buffer_manager: SharedWriteBufferManager = SharedWriteBufferManager::default();
320 let mut tuning_parameters: RocksDBTuningParameters = RocksDBTuningParameters {
321 write_buffer_manager_memory_bytes: Some(write_buffer_memory_bytes),
322 ..Default::default()
323 };
324 let mut rocksdb_config = RocksDBConfig::new(shared_write_buffer_manager.clone(), None);
325 rocksdb_config.apply(tuning_parameters.clone());
326
327 let instance1 = RocksDBInstance::<String, String>::new(
328 t.path().join("1").as_path(),
329 InstanceOptions::<bincode::DefaultOptions, String, StubMergeOperator<String>>::new(
330 rocksdb::Env::new()?,
331 2,
332 None,
333 bincode::DefaultOptions::new(),
334 ),
335 rocksdb_config.clone(),
336 shared_metrics_for_tests()?,
337 instance_metrics_for_tests()?,
338 )?;
339
340 // this is a no-op, but it won't return until instance1 has started
341 instance1.manual_compaction().await?;
342
343 {
344 // Arc will be dropped by the end of this scope
345 let buf = shared_write_buffer_manager.get().unwrap();
346 assert!(buf.enabled());
347 assert_eq!(write_buffer_memory_bytes, buf.get_buffer_size());
348 }
349
350 let updated_bytes = 20000;
351 tuning_parameters.write_buffer_manager_memory_bytes = Some(updated_bytes);
352 rocksdb_config.apply(tuning_parameters);
353
354 let instance2 = RocksDBInstance::<String, String>::new(
355 t.path().join("2").as_path(),
356 InstanceOptions::<bincode::DefaultOptions, String, StubMergeOperator<String>>::new(
357 rocksdb::Env::new()?,
358 2,
359 None,
360 bincode::DefaultOptions::new(),
361 ),
362 rocksdb_config.clone(),
363 shared_metrics_for_tests()?,
364 instance_metrics_for_tests()?,
365 )?;
366
367 // this is a no-op, but it won't return until instance2 has started
368 instance2.manual_compaction().await?;
369
370 instance1.close().await?;

Callers

nothing calls this directly

Calls 10

shared_metrics_for_testsFunction · 0.85
manual_compactionMethod · 0.80
unwrapMethod · 0.80
cloneMethod · 0.45
applyMethod · 0.45
joinMethod · 0.45
pathMethod · 0.45
getMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected