@nxtedition/rocksdb 7.0.58 → 7.0.61

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.
@@ -366,7 +366,7 @@ Status WalManager::RetainProbableWalFiles(VectorLogPtr& all_logs,
366
366
  }
367
367
  }
368
368
  // end could be -ve.
369
- size_t start_index = static_cast<size_t>(std::max(static_cast<int64_t>(0), end - 1));
369
+ size_t start_index = static_cast<size_t>(std::max(static_cast<int64_t>(0), end));
370
370
  // The last wal file is always included
371
371
  all_logs.erase(all_logs.begin(), all_logs.begin() + start_index);
372
372
  return Status::OK();
package/index.js CHANGED
@@ -11,6 +11,7 @@ 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')
14
15
 
15
16
  const kContext = Symbol('context')
16
17
  const kColumns = Symbol('columns')
@@ -349,8 +350,11 @@ class RocksLevel extends AbstractLevel {
349
350
  for await (const update of db[kUpdates](options)) {
350
351
  if (first) {
351
352
  if (update.sequence > options.since) {
352
- db.emit('warning', `Invalid sequence ${update.sequence} > ${options.since}. Starting from 0.`)
353
- first = null
353
+ // HACK
354
+ db.emit('warning', `Invalid update sequence ${update.sequence} > ${options.since}. Starting from 0.`)
355
+ for await (const update of db[kUpdates]({ ...options, since: 0 })) {
356
+ yield update
357
+ }
354
358
  break
355
359
  } else {
356
360
  first = false
@@ -358,17 +362,13 @@ class RocksLevel extends AbstractLevel {
358
362
  }
359
363
  yield update
360
364
  }
361
-
362
- if (first === null) {
363
- for await (const update of db[kUpdates]({ ...options, since: 0 })) {
364
- yield update
365
- }
366
- }
367
365
  }
368
366
 
369
367
  try {
370
368
  let since = options.since
371
- while (true) {
369
+ for (let retryCount = 0; true; retryCount++) {
370
+ assert(retryCount < 8)
371
+
372
372
  const buffer = new Readable({
373
373
  signal: ac.signal,
374
374
  objectMode: true,
@@ -408,6 +408,7 @@ class RocksLevel extends AbstractLevel {
408
408
  if (update.sequence >= since) {
409
409
  yield update
410
410
  since = update.sequence + update.count
411
+ retryCount = 0
411
412
  }
412
413
  }
413
414
  }
@@ -421,10 +422,20 @@ class RocksLevel extends AbstractLevel {
421
422
  return
422
423
  }
423
424
 
425
+ let first = true
424
426
  for await (const update of buffer) {
427
+ if (first) {
428
+ if (update.sequence > since) {
429
+ // HACK
430
+ db.emit('warning', `Invalid batch sequence. Restarting.`)
431
+ break
432
+ }
433
+ first = false
434
+ }
425
435
  if (update.sequence >= since) {
426
436
  yield update
427
437
  since = update.sequence + update.count
438
+ retryCount = 0
428
439
  }
429
440
  }
430
441
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/rocksdb",
3
- "version": "7.0.58",
3
+ "version": "7.0.61",
4
4
  "description": "A low-level Node.js RocksDB binding",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
Binary file