Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breaking: parent db must support deferredOpen #89

Merged
merged 1 commit into from
Apr 5, 2020
Merged

Conversation

vweevers
Copy link
Member

@vweevers vweevers commented Apr 4, 2020

Parent database must support deferredOpen

By parent we mean:

var parent = require('level')('db')
var sublevel = require('subleveldown')(parent, 'a')

By deferredOpen we mean that the db opens itself and defers operations until it's open. Currently that's only supported by levelup (and levelup factories like level). Previously, subleveldown would also accept abstract-leveldown db's that were not wrapped in levelup.

Better isolation

Opening and closing a sublevel no longer opens or closes the parent db. The sublevel does wait for the parent to open (which in the case of levelup already happens automatically) but never initiates
a state change on the parent.

If one closes the parent but not the sublevel, subsequent operations on the sublevel (like get and put) will yield an error, to prevent segmentation faults from underlying stores.

Drops support of old modules

  • memdb (use level-mem instead)
  • deferred-leveldown < 2.0.0 (and thus levelup < 2.0.0)
  • abstract-leveldown < 2.4.0

Rejects new sublevels on a closing or closed database

db.close(function (err) {
  subdb(db, 'example').on('error', function (err) {
    throw err // Error: Parent database is not open
  })
})
subdb(db, 'example').on('error', (err) => {
  throw err // Error: Parent database is not open
})

db.close(function () {})

Closes #84, closes #83, closes #60 and paves the way for Level/community#83.

@vweevers vweevers added the semver-major Changes that break backward compatibility label Apr 4, 2020
DeferredOpen means that the db opens itself and defers operations
until it's open. Currently that's only supported by levelup (and
levelup factories like level). Previously, subleveldown would also
accept abstract-leveldown db's that were not wrapped in levelup.

Opening and closing a sublevel no longer opens or closes the parent
db. The sublevel does wait for the parent to open (which in the
case of levelup already happens automatically) but never initiates
a state change.

If one closes the parent but not the sublevel, subsequent
operations (like get and put) on the sublevel will yield an error,
to prevent segmentation faults from underlying stores.

Drops support of old modules:

- memdb (use level-mem instead)
- deferred-leveldown < 2.0.0 (and thus levelup < 2.0.0)
- abstract-leveldown < 2.4.0

Closes #84, #83 and #60.
@vweevers
Copy link
Member Author

vweevers commented Apr 5, 2020

FYI @bcomnes @christianbundy @noffle

vweevers added a commit to Level/multileveldown that referenced this pull request Apr 5, 2020
vweevers added a commit to Level/party that referenced this pull request Apr 5, 2020
@vweevers vweevers merged commit 6e3f446 into master Apr 5, 2020
@vweevers vweevers deleted the refactor-open-2 branch April 5, 2020 19:11
@vweevers
Copy link
Member Author

vweevers commented Apr 5, 2020

5.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver-major Changes that break backward compatibility
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Require deferredOpen support Drop support of memdb Segfault with subleveldown
1 participant