Closed gogoout closed 2 years ago
I believe the problem is that I don't think you can use dupSort
on the root database (the unnamed database, which has entries to point to the named databases). Adding a name
to the database options seems to make this work. However, I am not sure why I would have worked in earlier versions. I will do some more testing tomorrow to see if I can reproduce it on earlier versions and maybe bisect the commit. If that is indeed the problem, I will add some checks to enforce this.
emm, interesting, that'll be an easy workaround. Just adding name
to the lmdb.open
should just turn it into a named database?
const db = lmdb.open({
name : "secondary",
path : "/tmp/db-test" + id,
useVersions : false,
encoding : "ordered-binary",
dupSort : true,
cache : false
});
That's correct.
tl;dr: I don't think LMDB fully supports the dupSort mode for the main/unnamed database, but hard to tell if it is intended to be supported in certain situations.
Trying to do this yields a variety of interesting results:
So I think there a couple options:
I think just make that clear should be good enough. The problem is it's not clear dupSort
can't be used in main (null name) database. Basically, you have to go to lmdb's website to discover that behaviour.
Overall, I think just add a several line on the doc and maybe do a check when open the database should be good enough.
I believe this has been addressed with improved documentation and better error handling in v2.2.
Minimal test to reproduce
Using latest version, the result is
Where it should be
I've also tested, seems this bug is introduced since v2.1.3. Originally I think this is caused by concurrent put, but seems it affects everything. Even you wrap the put in the transaction the behaviour is the same. Also change encoding from
ordered-binary
tomsgpack
still produce the same wrong result.