rocksdb-native 3.5.1 → 3.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/batch.js +11 -12
- package/lib/state.js +8 -0
- package/package.json +2 -1
package/lib/batch.js
CHANGED
|
@@ -101,12 +101,6 @@ class RocksDBBatch {
|
|
|
101
101
|
if (this._request) throw new Error('Request in progress')
|
|
102
102
|
if (this._destroyed) throw new Error('Batch is destroyed')
|
|
103
103
|
|
|
104
|
-
const state = this._db._state
|
|
105
|
-
|
|
106
|
-
if (state._suspending || state._suspended) {
|
|
107
|
-
throw new Error('Database is suspended')
|
|
108
|
-
}
|
|
109
|
-
|
|
110
104
|
this._request = new Promise((resolve, reject) => {
|
|
111
105
|
this._resolve = resolve
|
|
112
106
|
this._reject = reject
|
|
@@ -121,19 +115,22 @@ class RocksDBBatch {
|
|
|
121
115
|
if (this._request) throw new Error('Request in progress')
|
|
122
116
|
if (this._destroyed) throw new Error('Batch is destroyed')
|
|
123
117
|
|
|
124
|
-
const state = this._db._state
|
|
125
|
-
|
|
126
|
-
if (state._suspending || state._suspended) {
|
|
127
|
-
throw new Error('Database is suspended')
|
|
128
|
-
}
|
|
129
|
-
|
|
130
118
|
this._request = resolved
|
|
131
119
|
|
|
132
120
|
this._flush()
|
|
133
121
|
}
|
|
134
122
|
|
|
135
123
|
async _flush() {
|
|
124
|
+
const state = this._db._state
|
|
125
|
+
|
|
136
126
|
if (this._handle === null) await this.ready()
|
|
127
|
+
if (state.resumed !== null) await state.resumed.promise
|
|
128
|
+
|
|
129
|
+
if ((state._suspending || state._suspended) && !this._destroyed) {
|
|
130
|
+
this._destroyed = true
|
|
131
|
+
this._abort()
|
|
132
|
+
this._db._unrefBatch()
|
|
133
|
+
}
|
|
137
134
|
}
|
|
138
135
|
|
|
139
136
|
_enqueuePromise(resolve, reject) {
|
|
@@ -173,6 +170,7 @@ exports.ReadBatch = class RocksDBReadBatch extends RocksDBBatch {
|
|
|
173
170
|
|
|
174
171
|
async _flush() {
|
|
175
172
|
await super._flush()
|
|
173
|
+
if (this._destroyed) return
|
|
176
174
|
|
|
177
175
|
binding.read(
|
|
178
176
|
this._db._state._handle,
|
|
@@ -240,6 +238,7 @@ exports.WriteBatch = class RocksDBWriteBatch extends RocksDBBatch {
|
|
|
240
238
|
|
|
241
239
|
async _flush() {
|
|
242
240
|
await super._flush()
|
|
241
|
+
if (this._destroyed) return
|
|
243
242
|
|
|
244
243
|
binding.write(
|
|
245
244
|
this._db._state._handle,
|
package/lib/state.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const ReadyResource = require('ready-resource')
|
|
2
2
|
const RefCounter = require('refcounter')
|
|
3
|
+
const rrp = require('resolve-reject-promise')
|
|
3
4
|
const { ReadBatch, WriteBatch } = require('./batch')
|
|
4
5
|
const ColumnFamily = require('./column-family')
|
|
5
6
|
const binding = require('../binding')
|
|
@@ -29,6 +30,7 @@ module.exports = class RocksDBState extends ReadyResource {
|
|
|
29
30
|
this.sessions = []
|
|
30
31
|
this.columnFamilies = [columnFamily]
|
|
31
32
|
this.deferSnapshotInit = true
|
|
33
|
+
this.resumed = null
|
|
32
34
|
|
|
33
35
|
this._suspended = false
|
|
34
36
|
this._suspending = null
|
|
@@ -155,6 +157,7 @@ module.exports = class RocksDBState extends ReadyResource {
|
|
|
155
157
|
}
|
|
156
158
|
|
|
157
159
|
async _close() {
|
|
160
|
+
if (this.resumed) this.resumed.resolve(false)
|
|
158
161
|
while (!this.activity.isIdle()) await this.activity.idle()
|
|
159
162
|
|
|
160
163
|
while (this.sessions.length > 0)
|
|
@@ -215,6 +218,7 @@ module.exports = class RocksDBState extends ReadyResource {
|
|
|
215
218
|
if (this.opened === false) await this.ready()
|
|
216
219
|
|
|
217
220
|
while (!this.activeBatches.isIdle()) await this.activeBatches.idle()
|
|
221
|
+
this.resumed = rrp()
|
|
218
222
|
|
|
219
223
|
const req = { resolve: null, reject: null, handle: null }
|
|
220
224
|
|
|
@@ -266,6 +270,10 @@ module.exports = class RocksDBState extends ReadyResource {
|
|
|
266
270
|
this._resuming = null
|
|
267
271
|
}
|
|
268
272
|
|
|
273
|
+
const resumed = this.resumed
|
|
274
|
+
this.resumed = null
|
|
275
|
+
resumed.resolve(true)
|
|
276
|
+
|
|
269
277
|
function onresume(err) {
|
|
270
278
|
if (err) req.reject(new Error(err))
|
|
271
279
|
else req.resolve()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rocksdb-native",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.2",
|
|
4
4
|
"description": "librocksdb bindings for JavaScript",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./index.js",
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"ready-resource": "^1.0.0",
|
|
41
41
|
"refcounter": "^1.0.0",
|
|
42
42
|
"require-addon": "^1.0.2",
|
|
43
|
+
"resolve-reject-promise": "^1.1.0",
|
|
43
44
|
"streamx": "^2.16.1"
|
|
44
45
|
},
|
|
45
46
|
"devDependencies": {
|