@nxtedition/rocksdb 7.0.62 → 7.0.63

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.
Files changed (3) hide show
  1. package/binding.cc +2 -1
  2. package/index.js +19 -11
  3. package/package.json +1 -1
package/binding.cc CHANGED
@@ -407,7 +407,6 @@ struct BatchIterator : public rocksdb::WriteBatch::Handler {
407
407
  valueAsBuffer_(valueAsBuffer) {}
408
408
 
409
409
  napi_status Iterate(napi_env env, const rocksdb::WriteBatch& batch, napi_value* result) {
410
- cache_.clear();
411
410
  cache_.reserve(batch.Count());
412
411
 
413
412
  batch.Iterate(this); // TODO (fix): Handle error?
@@ -457,6 +456,8 @@ struct BatchIterator : public rocksdb::WriteBatch::Handler {
457
456
  NAPI_STATUS_RETURN(napi_set_element(env, *result, n * 4 + 3, nullVal));
458
457
  }
459
458
 
459
+ cache_.clear();
460
+
460
461
  return napi_ok;
461
462
  }
462
463
 
package/index.js CHANGED
@@ -11,7 +11,6 @@ const { Iterator } = require('./iterator')
11
11
  const { Readable } = require('readable-stream')
12
12
  const os = require('os')
13
13
  const AbortController = require('abort-controller')
14
- const assert = require('assert')
15
14
 
16
15
  const kContext = Symbol('context')
17
16
  const kColumns = Symbol('columns')
@@ -348,7 +347,6 @@ class RocksLevel extends AbstractLevel {
348
347
 
349
348
  const db = this
350
349
 
351
- // HACK: https://github.com/facebook/rocksdb/issues/10476
352
350
  async function * _updates (options) {
353
351
  let first = true
354
352
  for await (const update of db[kUpdates]({ ...options, since: Math.max(0, options.since - 1024) })) {
@@ -374,9 +372,7 @@ class RocksLevel extends AbstractLevel {
374
372
 
375
373
  try {
376
374
  let since = options.since
377
- for (let retryCount = 0; true; retryCount++) {
378
- assert(retryCount < 8)
379
-
375
+ while (true) {
380
376
  const buffer = new Readable({
381
377
  signal: ac.signal,
382
378
  objectMode: true,
@@ -404,15 +400,26 @@ class RocksLevel extends AbstractLevel {
404
400
 
405
401
  try {
406
402
  if (since <= db.sequence) {
407
- for await (const update of _updates(options)) {
403
+ let first = true
404
+ for await (const update of _updates({
405
+ ...options,
406
+ // HACK: https://github.com/facebook/rocksdb/issues/10476
407
+ since: Math.max(0, options.since - 2048)
408
+ })) {
408
409
  if (ac.signal.aborted) {
409
410
  throw new AbortError()
410
411
  }
411
412
 
413
+ if (first) {
414
+ if (update.sequence > since) {
415
+ db.emit('warning', `Invalid updates sequence ${update.sequence} > ${options.since}.`)
416
+ }
417
+ first = false
418
+ }
419
+
412
420
  if (update.sequence >= since) {
413
421
  yield update
414
422
  since = update.sequence + update.count
415
- retryCount = 0
416
423
  }
417
424
  }
418
425
  }
@@ -428,18 +435,19 @@ class RocksLevel extends AbstractLevel {
428
435
 
429
436
  let first = true
430
437
  for await (const update of buffer) {
438
+ if (ac.signal.aborted) {
439
+ throw new AbortError()
440
+ }
441
+
431
442
  if (first) {
432
443
  if (update.sequence > since) {
433
- // HACK
434
- db.emit('warning', `Invalid batch sequence ${update.sequence} > ${options.since}. Starting from ${since}.`)
435
- break
444
+ db.emit('warning', `Invalid batch sequence ${update.sequence} > ${options.since}.`)
436
445
  }
437
446
  first = false
438
447
  }
439
448
  if (update.sequence >= since) {
440
449
  yield update
441
450
  since = update.sequence + update.count
442
- retryCount = 0
443
451
  }
444
452
  }
445
453
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/rocksdb",
3
- "version": "7.0.62",
3
+ "version": "7.0.63",
4
4
  "description": "A low-level Node.js RocksDB binding",
5
5
  "license": "MIT",
6
6
  "main": "index.js",