use redb::{Database, TableDefinition};
fn main() {
example();
example();
}
fn example() {
let mut db = Database::create("example.db").unwrap();
let write_tx = db.begin_write().unwrap();
let read_tx = db.begin_read().unwrap();
let mut write_table = write_tx
.open_table::<&str, &str>(TableDefinition::new("example"))
.unwrap();
write_table.insert("example", "example").unwrap();
// drop(read_tx);
drop(write_table);
write_tx.commit().unwrap();
db.compact().unwrap();
}
After running that with cargo r, I get the output:
thread 'main' panicked at /home/fluid/.cargo/registry/src/index.crates.io-6f17d22bba15001f/redb-2.1.0/src/db.rs:427:9:
assertion failed: self.mem.get_freed_root().is_none()
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
To fix that, uncomment the line dropping a read transaction. Note that I execute example() twice, the panic doesn't present at the first compaction, only at subsequent ones.
After running that with
cargo r
, I get the output:To fix that, uncomment the line dropping a read transaction. Note that I execute
example()
twice, the panic doesn't present at the first compaction, only at subsequent ones.System info: