Git Product home page Git Product logo

Comments (12)

MeirionHughes avatar MeirionHughes commented on May 18, 2024 1

yeah that seems to do the trick

from subleveldown.

vweevers avatar vweevers commented on May 18, 2024 1

4.1.4

from subleveldown.

MeirionHughes avatar MeirionHughes commented on May 18, 2024 1

cheers: looks like its working well and I have about five sub-levels too. Thanks for the quick fix.

from subleveldown.

MeirionHughes avatar MeirionHughes commented on May 18, 2024

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.

MeirionHughes avatar MeirionHughes commented on May 18, 2024

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.

vweevers avatar vweevers commented on May 18, 2024

@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.

vweevers avatar vweevers commented on May 18, 2024

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.

MeirionHughes avatar MeirionHughes commented on May 18, 2024

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.

vweevers avatar vweevers commented on May 18, 2024

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.

vweevers avatar vweevers commented on May 18, 2024

OK, I'm able to reproduce your issue on master as well.

from subleveldown.

vweevers avatar vweevers commented on May 18, 2024

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):

self.leveldown = reachdown(subdb.db, matchdown, false)

With:

self.leveldown = subdb.leveldown

@MeirionHughes Could you try that out?

from subleveldown.

vweevers avatar vweevers commented on May 18, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.