@harperfast/rocksdb-js 2.7.0 → 2.7.1

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/README.md CHANGED
@@ -57,6 +57,18 @@ Creates a new database instance.
57
57
  - `enableStats: boolean` When `true` and the database is open, RocksDB will captures stats that
58
58
  are retrieved by calling `db.getStats()`. Enabling statistics imposes 5-10% in overhead.
59
59
  Defaults to `false`.
60
+ - `infoLogLevel: number` The verbosity of RocksDB's informational logging (`LOG` /
61
+ `LOG.old.*`): `0` (debug), `1` (info), `2` (warn), `3` (error), `4` (fatal), or `5`
62
+ (header-only). Omit to leave RocksDB's own default (`INFO_LEVEL` in a release build of the
63
+ linked RocksDB library). See [`db.logOptions`](#dblogoptions-maxlogfilesize-number-infologlevel-number).
64
+ - `maxLogFileSize: number` The per-file size cap, in bytes, for informational log files (`LOG` /
65
+ `LOG.old.*`). RocksDB retains up to 5 of these files, so the total informational-log footprint
66
+ is bounded at roughly `5 * maxLogFileSize`. Defaults to 16 MB (an 80 MB bound), which stops
67
+ purely informational logging from growing without bound. A value of `0` is RocksDB's special
68
+ "single unbounded log file" mode — it **disables size-based rotation entirely**, so the log
69
+ can grow without limit; only set `0` if you deliberately want that (it forgoes the bounded
70
+ footprint this option otherwise provides). See
71
+ [`db.logOptions`](#dblogoptions-maxlogfilesize-number-infologlevel-number).
60
72
  - `maxOpenFiles: number` The maximum number of table files RocksDB keeps open. `0` (the default)
61
73
  derives a budget from the effective per-process open-file limit (an eighth of the limit —
62
74
  several databases can share one process — clamped to `[1024, 262144]`); `-1` holds every table
@@ -134,6 +146,18 @@ const db = RocksDatabase.open('path/to/db', {
134
146
  console.log(db.compression); // { algorithm: 'zstd', level: 3 }
135
147
  ```
136
148
 
149
+ ### `db.logOptions: { maxLogFileSize: number, infoLogLevel: number }`
150
+
151
+ Returns the informational-log settings currently in effect for this database, read live from
152
+ RocksDB. These are database-wide settings (not per-column-family). `maxLogFileSize` is the
153
+ per-file size cap for informational log files (`LOG` / `LOG.old.*`); `infoLogLevel` is the logging
154
+ verbosity. The database must be open.
155
+
156
+ ```typescript
157
+ const db = RocksDatabase.open('path/to/db', { maxLogFileSize: 4 * 1024 * 1024 });
158
+ console.log(db.logOptions); // { maxLogFileSize: 4194304, infoLogLevel: 1 }
159
+ ```
160
+
137
161
  ### `db.config(options)`
138
162
 
139
163
  Sets global database settings.
package/dist/index.cjs CHANGED
@@ -1336,6 +1336,11 @@ var Store = class {
1336
1336
  */
1337
1337
  freezeData;
1338
1338
  /**
1339
+ * Verbosity of RocksDB's informational logging (`info_log_level`). Omit to
1340
+ * leave RocksDB's own default.
1341
+ */
1342
+ infoLogLevel;
1343
+ /**
1339
1344
  * Reusable buffer for encoding keys.
1340
1345
  */
1341
1346
  keyBuffer;
@@ -1348,6 +1353,16 @@ var Store = class {
1348
1353
  */
1349
1354
  maxKeySize;
1350
1355
  /**
1356
+ * Per-file size cap (bytes) for informational log files (`LOG` /
1357
+ * `LOG.old.*`). Bounds total informational-log footprint to roughly `5 *
1358
+ * maxLogFileSize` (RocksDB retains up to 5 of these files). A value of `0`
1359
+ * is RocksDB's "single unbounded log file" mode: it disables size-based
1360
+ * rotation, so the log can grow without limit — set it only if you want that.
1361
+ *
1362
+ * @default 16777216 (16MB)
1363
+ */
1364
+ maxLogFileSize;
1365
+ /**
1351
1366
  * The maximum number of table files RocksDB keeps open. `0` (the default)
1352
1367
  * derives a budget from the effective per-process open-file limit (an
1353
1368
  * eighth of the limit — several databases can share one process — clamped
@@ -1366,13 +1381,26 @@ var Store = class {
1366
1381
  /**
1367
1382
  * The bytes of recent memtable history to retain in memory for transaction
1368
1383
  * conflict checking. `-1` derives the value from
1369
- * `maxWriteBufferNumber * writeBufferSize`.
1384
+ * `maxWriteBufferNumber * writeBufferSize`, except under a stalling
1385
+ * `writeBufferManager`, where it derives `0`: retained history is charged to
1386
+ * that manager and is only trimmable down to this target, so a target the
1387
+ * budget cannot hold stalls writes permanently. Set a number to size it
1388
+ * yourself against the budget and the column-family count.
1370
1389
  */
1371
1390
  maxWriteBufferSizeToMaintain;
1372
1391
  /**
1373
1392
  * The total memtable budget in bytes across all column families. When the
1374
- * sum of memtables reaches this size, RocksDB flushes the largest one. `0`
1375
- * disables the global trigger so per-CF `writeBufferSize` drives flushing.
1393
+ * sum of memtables reaches this size, RocksDB flushes the largest one.
1394
+ * Defaults to `0`, which disables the global trigger so per-CF
1395
+ * `writeBufferSize` drives flushing.
1396
+ *
1397
+ * Set this only if you know your column-family count: it is one budget split
1398
+ * across all of them, so a value that suits a few families starves many. To
1399
+ * bound total memtable memory instead, configure a WriteBufferManager.
1400
+ *
1401
+ * Database-wide, so it binds when the path is first opened in this process:
1402
+ * a later open of the same path — including from another worker thread —
1403
+ * keeps the first opener's value rather than overriding or rejecting it.
1376
1404
  */
1377
1405
  dbWriteBufferSize;
1378
1406
  /**
@@ -1477,9 +1505,11 @@ var Store = class {
1477
1505
  this.encoder = options?.encoder ?? null;
1478
1506
  this.encoding = options?.encoding ?? null;
1479
1507
  this.freezeData = options?.freezeData ?? false;
1508
+ this.infoLogLevel = options?.infoLogLevel;
1480
1509
  this.keyBuffer = KEY_BUFFER;
1481
1510
  this.keyEncoding = keyEncoding;
1482
1511
  this.maxKeySize = options?.maxKeySize ?? MAX_KEY_SIZE;
1512
+ this.maxLogFileSize = options?.maxLogFileSize;
1483
1513
  this.maxOpenFiles = options?.maxOpenFiles;
1484
1514
  this.maxWriteBufferNumber = options?.maxWriteBufferNumber;
1485
1515
  this.maxWriteBufferSizeToMaintain = options?.maxWriteBufferSizeToMaintain;
@@ -1787,6 +1817,8 @@ var Store = class {
1787
1817
  dbWriteBufferSize: this.dbWriteBufferSize,
1788
1818
  disableWAL: this.disableWAL,
1789
1819
  enableStats: this.enableStats,
1820
+ infoLogLevel: this.infoLogLevel,
1821
+ maxLogFileSize: this.maxLogFileSize,
1790
1822
  maxOpenFiles: this.maxOpenFiles,
1791
1823
  maxWriteBufferNumber: this.maxWriteBufferNumber,
1792
1824
  maxWriteBufferSizeToMaintain: this.maxWriteBufferSizeToMaintain,
@@ -2231,6 +2263,24 @@ var RocksDatabase = class RocksDatabase extends DBI {
2231
2263
  return this.store.db.getCompression();
2232
2264
  }
2233
2265
  /**
2266
+ * The informational-log settings currently in effect for this database,
2267
+ * read live from RocksDB, as `{ maxLogFileSize, infoLogLevel }`. These are
2268
+ * database-wide settings (not per-column-family): `maxLogFileSize` bounds
2269
+ * each retained `LOG` / `LOG.old.*` file's size (defaults to 16MB, so with
2270
+ * RocksDB's `keep_log_file_num = 5` the total footprint is bounded at
2271
+ * roughly 80MB); `infoLogLevel` is the logging verbosity. The database must
2272
+ * be open.
2273
+ *
2274
+ * @example
2275
+ * ```typescript
2276
+ * const db = RocksDatabase.open('/path/to/db', { maxLogFileSize: 4 * 1024 * 1024 });
2277
+ * db.logOptions; // { maxLogFileSize: 4194304, infoLogLevel: 1 }
2278
+ * ```
2279
+ */
2280
+ get logOptions() {
2281
+ return this.store.db.getLogOptions();
2282
+ }
2283
+ /**
2234
2284
  * Set global database settings.
2235
2285
  *
2236
2286
  * @param options - The options for the database.
@@ -3060,7 +3110,7 @@ function loadLastPosition(transactionLog, readUncommitted) {
3060
3110
  //#region src/index.ts
3061
3111
  const versions = {
3062
3112
  rocksdb: version,
3063
- "rocksdb-js": "2.7.0"
3113
+ "rocksdb-js": "2.7.1"
3064
3114
  };
3065
3115
 
3066
3116
  //#endregion