cberner / redb

An embedded key-value database in pure Rust
https://www.redb.org
Apache License 2.0
3.19k stars 145 forks source link

Panic in RawLeafBuilder::Append #564

Closed lhallam closed 1 year ago

lhallam commented 1 year ago

Hey, just had redb panic while inserting into a Table<u128, &[u8]>.

This was on windows and the last process to access the database had crashed with the database open.

I can't repro anymore -- after restarting the same data should have been inserted in the same order, but I'm not 100% sure on that.


ecc6299db9ec823\redb-0.15.0\src\tree_store\btree_base.rs:780:9
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library\std\src\panicking.rs:575
   1: core::panicking::panic_fmt
             at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library\core\src\panicking.rs:64
   2: core::slice::index::slice_end_index_len_fail_rt
             at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library\core\src\slice\index.rs:77
   3: core::slice::index::slice_end_index_len_fail
             at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library\core\src\slice\index.rs:69
   4: redb::tree_store::btree_base::RawLeafBuilder::append
   5: redb::tree_store::btree_base::LeafBuilder::build
   6: redb::tree_store::btree_mutator::MutateHelper<K,V>::insert_helper
   7: redb::tree_store::btree_mutator::MutateHelper<K,V>::insert_helper
   8: redb::tree_store::btree_mutator::MutateHelper<K,V>::insert_helper
   9: redb::tree_store::btree_mutator::MutateHelper<K,V>::insert_helper
  10: redb::tree_store::btree_mutator::MutateHelper<K,V>::insert
  11: redb::tree_store::btree::BtreeMut<K,V>::insert
  12: <redb::table::Table<u128,&[u8]> as beam::db::EntriesMut>::write_data```
cberner commented 1 year ago

Well that's not good. I'll look around a bit. I've been planning to refractor a bunch of that code. Let me know if you are able to reproduce it. It'll be hard to debug without a repro

cberner commented 1 year ago

Do you use any Durability::None transactions? I found a data corruption issue that could occur, if a crash occurred when using that.

cberner commented 1 year ago

Ah, actually no, I'm pretty sure this was caused by the cache poisoning issue that I fixed in b4fed9a12d29495973b0381f7233b0de4033c3bb