Closed ghost closed 8 years ago
You say that the database is empty and you only call txn.Put() once? If that's the case then it doesn't seem like you should get that error (were that to happen, it would be a bug in the C library). So I wonder if something is wrong with your test, and if you are putting more items in than you realize.
You can check how many entries are in a db using txn.Stat(). Then you could, in fact, verify that the database is empty before your call to txn.Put() is made (by ensuring the stat's Entries field is 0).
As far as the key encoding goes -- it looks like they are supposed to be unsigned integers. Right? In that case you don't need a custom comparison function as long as you use binary.BigEndian to encode your keys. A big-endian encoding for uint64 will result in keys being sorted in increasing order, which appears to be what you want. If you use a little-endian encoding then the resulting keys would not sort in a desirable order.
Thank you @bmatsuo, you are right, I checked, and found I passed a wrong env.
I call
Got error:
mdb_put: MDB_KEYEXIST: Key/data pair already exists
Below is my code, the qp.partition type is lmdb.DBI, inited before I call push
The loop is only once, and I delete db everytime before I run this test, also set the key to a sepcial key,
So It cann't EXIST in db.
I don't know how to debug this.