mozilla / rkv

A simple, humane, typed key-value storage solution.
https://crates.io/crates/rkv
Apache License 2.0
310 stars 53 forks source link

writer.delete by key and value fails #96

Closed rrichardson closed 5 years ago

rrichardson commented 5 years ago

When deleting a single record in a DUP_SORTdb, the result is always LmdbError::NotFound.

Upon tracing the lmdb-rs-sys put and delete code, the key and value passed into both has an identical set of bytes, so I'm not sure what the hangup is. I've created a unit test that demonstrates this: https://github.com/mozilla/rkv/pull/93/files#diff-06aeb1dbfcf2eb1e00a4f7fe0edab250R488

Still not yet sure why it's failing. I guess I need to read up on LMDB docs.

rrichardson commented 5 years ago

Here is the output from lmdb Transaction::delete

---- env::tests::test_multi_put_get_del stdout ----
put [115, 116, 114, 49] [7, 8, 0, 0, 0, 0, 0, 0, 0, 115, 116, 114, 49, 32, 102, 111, 111]
put [115, 116, 114, 49] [7, 8, 0, 0, 0, 0, 0, 0, 0, 115, 116, 114, 49, 32, 98, 97, 114]
put [115, 116, 114, 50] [7, 8, 0, 0, 0, 0, 0, 0, 0, 115, 116, 114, 50, 32, 102, 111, 111]
put [115, 116, 114, 50] [7, 8, 0, 0, 0, 0, 0, 0, 0, 115, 116, 114, 50, 32, 98, 97, 114]
put [115, 116, 114, 51] [7, 8, 0, 0, 0, 0, 0, 0, 0, 115, 116, 114, 51, 32, 102, 111, 111]
put [115, 116, 114, 51] [7, 8, 0, 0, 0, 0, 0, 0, 0, 115, 116, 114, 51, 32, 98, 97, 114]

del [115, 116, 114, 49] [7, 8, 0, 0, 0, 0, 0, 0, 0, 115, 116, 114, 49, 32, 102, 111, 111]

thread 'env::tests::test_multi_put_get_del' panicked at 'called `Result::unwrap()` on an `Err` value: LmdbError(NotFound)', src/libcore/result.rs:1009:5
rrichardson commented 5 years ago

Replicated this in lmdb-rs and created a test and issue in lmdb-rs for this. https://github.com/mozilla/lmdb-rs/issues/17

rrichardson commented 5 years ago

This test now passes using https://github.com/mozilla/lmdb-rs/pull/18

rrichardson commented 5 years ago

This is fixed. @rrichardson - push this change to the upstream lmdb-rs