redb icon indicating copy to clipboard operation
redb copied to clipboard

BUG: Allocated a page that is still referenced

Open akiradeveloper opened this issue 1 year ago • 1 comments

I am using redb in my library and I see an error message below in my tests occasionally.

thread '<unnamed>' panicked at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/redb-2.1.4/src/tree_store/page_store/page_manager.rs:820:13:
Allocated a page that is still referenced! r0.6/0
thread 'ND45467>' panicked at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/redb-2.1.4/src/tree_store/page_store/page_manager.rs:749:39:
called `Result::unwrap()` on an `Err` value: PoisonError { .. }

Regarding writes, there is no concurrent transaction: insertions are queued and batched in one transaction. However, a transaction normally mixes write to multiple tables. The actual code is below. Is this a valid usage?

        let tx = self.db.begin_write()?;
        {
            let mut tbl = tx.open_table(table_def(&head.space))?;
            tbl.insert(head.index, value::ser(head.inner))?;
            notifiers.push(head.notifier);
        }
        for e in tail {
            let mut tbl = tx.open_table(table_def(&e.space))?;
            tbl.insert(e.index, value::ser(e.inner))?;
            notifiers.push(e.notifier);
        }
        tx.commit()?;

Since there is no conflicting transactions, I can't believe such a naive error could happen. Do you know some existing issue that's close to my problem? FYI, I am using memory backend for tests.

akiradeveloper avatar Oct 24 '24 04:10 akiradeveloper

Hmm, ya that looks like very normal usage. Do you have a simple way to reproduce it? If you have a minimal reproduction I can run, I can take a look at what's going on

cberner avatar Oct 25 '24 02:10 cberner