Comments (12)
yeah that seems to do the trick
from subleveldown.
4.1.4
from subleveldown.
cheers: looks like its working well and I have about five sub-levels too. Thanks for the quick fix.
from subleveldown.
yeah I've got this too. 4.1.0 was fine, but on 4.1.1 I get prefix duplication.
I'm trying to replicate it, but its proving troublesome as if I straight up make the subs it works. In practice my code is creating subs "on the fly" then caching a helper class that manages the subdb.
from subleveldown.
I've managed to duplicate it:
let db = levelup(encoding(memdown()));
let fooDb = sub(db, "foo");
let barDb = sub(fooDb, "bar");
let rayDb = sub(barDb, "ray");
await fooDb.put("def", "one")
await barDb.put("def", "two")
await rayDb.put("123", "hello world");
await rayDb.put("124", "hello world");
await rayDb.put("125", "hello world");
result with with [email protected]:
!foo!!bar!def
!foo!!foo!!bar!!ray!123
!foo!!foo!!bar!!ray!124
!foo!!foo!!bar!!ray!125
!foo!def
while with [email protected]:
!foo!!bar!!ray!123
!foo!!bar!!ray!124
!foo!!bar!!ray!125
!foo!!bar!def
!foo!def
from subleveldown.
@MeirionHughes We've already got a test for it. And 4.0.0 and 4.1.0 were broken (in other ways), so while it may seem 4.1.1 has the issue, it actually revealed it, and it has been here since 3.0.0.
from subleveldown.
Although... wait. The issue you're describing is a separate one (not about re- opening) that we might be able to fix on a shorter term. It's probably a race issue between the different sublevels all wanting to open the db.
Simple workaround is to do:
let db = levelup(encoding(memdown()))
db.on('open', function () {
// create your sublevels now
})
from subleveldown.
I've already tried with:
let db = levelup(encoding(memdown()));
await db.open();
let fooDb = sub(db, "foo");
await fooDb.open();
let barDb = sub(fooDb, "bar");
await barDb.open();
let rayDb = sub(barDb, "ray");
await rayDb.open();
and I get the same.
I was going to see what difference this really has on this 3-layer nesting.
from subleveldown.
I was going to see what difference this really has on this 3-layer nesting.
That's been replaced in a later version
from subleveldown.
OK, I'm able to reproduce your issue on master as well.
from subleveldown.
Possible fix is to replace this (which can land on subdown rather than leveldown, so we end up wrapping subdown with subdown, hence the double prefix):
Line 92 in 279ac43
With:
self.leveldown = subdb.leveldown
@MeirionHughes Could you try that out?
from subleveldown.
We could release that fix as semver-patch, but consumers can in theory lose access to already stored data (with a double prefix)... does that make it a breaking change? Yolo.
from subleveldown.
Related Issues (20)
- How to get the exception `Inner database is not open`? HOT 2
- Support buffer/Uint8Array prefixes HOT 7
- A way to get a deeply nested sublevel in one-go HOT 5
- Release v3.0.0 HOT 1
- Streams are ignoring fillCache option HOT 2
- Segfault with subleveldown HOT 27
- bytewise key-encoding on sub-level causes not found on other level HOT 20
- Adding _seek to SubIterator HOT 4
- Disable `clear()` HOT 2
- Take advantage of manifests and the squash down HOT 1
- An in-range update of abstract-leveldown is breaking the build 🚨 HOT 3
- An in-range update of levelup is breaking the build 🚨 HOT 2
- Remove unnecessary condition HOT 1
- Drop support of memdb
- Require deferredOpen support HOT 1
- Support "deep" option in clear() & iterator() HOT 10
- Possible issue with buffer keys HOT 10
- Decoder Err ! HOT 3
- Should the `createReadStream` method be scoped to the subs? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from subleveldown.