@harperfast/harper-pro 5.0.13 → 5.0.15

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.
@@ -291,7 +291,7 @@ function openRocksDb(path: string, options: RocksDatabaseOptions & { dupSort?: b
291
291
  }
292
292
  let db;
293
293
  if (options.dupSort) {
294
- db = RocksDatabase.open(new RocksIndexStore(path, options));
294
+ db = new RocksIndexStore(path, options).open();
295
295
  } else {
296
296
  db = RocksDatabase.open(path, options);
297
297
  db.encoder.name = options.name;
@@ -309,8 +309,10 @@ export async function migrateOnStart() {
309
309
  updateConfigValue(CONFIG_PARAMS.STORAGE_MIGRATEONSTART, false);
310
310
 
311
311
  try {
312
- for (const databaseName in databases) {
313
- if (databaseName === 'system') continue;
312
+ let databaseNames = Object.keys(databases);
313
+ // system is a dontenum property, so we have to manually add it
314
+ if (!databaseNames.includes('system')) databaseNames.push('system');
315
+ for (const databaseName of databaseNames) {
314
316
  if (databaseName.endsWith('-copy')) continue;
315
317
  let rootStore;
316
318
  for (const tableName in databases[databaseName]) {
package/core/bin/run.js CHANGED
@@ -24,6 +24,7 @@ const minimist = require('minimist');
24
24
  const keys = require('../security/keys.js');
25
25
  const { startHTTPThreads } = require('../server/threads/socketRouter.ts');
26
26
  const hdbInfoController = require('../dataLayer/hdbInfoController.js');
27
+ const { getThisNodeName } = require('../server/nodeName.ts');
27
28
  const hdbTerms = require('../utility/hdbTerms.ts');
28
29
  const { getHdbPid, isProcessRunning } = require('../utility/processManagement/processManagement.js');
29
30
  const { PACKAGE_ROOT } = require('../utility/packageUtils');
@@ -255,7 +256,7 @@ function startupLog(portResolutions) {
255
256
  const pad = (param) => param.padEnd(padding);
256
257
  let logMsg = '\n';
257
258
 
258
- logMsg += `${pad('Hostname:')}${env.get(CONFIG_PARAMS.NODE_HOSTNAME)}\n`;
259
+ logMsg += `${pad('Hostname:')}${getThisNodeName()}\n`;
259
260
 
260
261
  logMsg += `${pad('Worker Threads:')}${env.get(CONFIG_PARAMS.THREADS_COUNT)}\n`;
261
262
 
@@ -295,20 +296,14 @@ function startupLog(portResolutions) {
295
296
  }`;
296
297
  logMsg += `, unix socket: ${configUtils.getConfigPath(CONFIG_PARAMS.OPERATIONSAPI_NETWORK_DOMAINSOCKET)}\n`;
297
298
  if (env.get(CONFIG_PARAMS.OPERATIONSAPI_NETWORK_PORT)) {
298
- logMsg +=
299
- pad('') +
300
- 'http://' +
301
- env.get(CONFIG_PARAMS.NODE_HOSTNAME) +
302
- ':' +
303
- env.get(CONFIG_PARAMS.OPERATIONSAPI_NETWORK_PORT) +
304
- '/\n';
299
+ logMsg += pad('') + 'http://' + getThisNodeName() + ':' + env.get(CONFIG_PARAMS.OPERATIONSAPI_NETWORK_PORT) + '/\n';
305
300
  }
306
301
  if (env.get(CONFIG_PARAMS.OPERATIONSAPI_NETWORK_SECUREPORT)) {
307
302
  logMsg +=
308
303
  '\n' +
309
304
  pad('') +
310
305
  'https://' +
311
- env.get(CONFIG_PARAMS.NODE_HOSTNAME) +
306
+ getThisNodeName() +
312
307
  ':' +
313
308
  env.get(CONFIG_PARAMS.OPERATIONSAPI_NETWORK_SECUREPORT) +
314
309
  '/\n';
@@ -363,7 +358,7 @@ function startupLog(portResolutions) {
363
358
  if (!restLog.includes(pair) && name === 'rest') {
364
359
  restLog += pair;
365
360
  if (value.protocol_name === 'HTTP' || value.protocol_name === 'HTTPS') {
366
- restHostnames.push(`${value.protocol_name.toLowerCase()}://${env.get(CONFIG_PARAMS.NODE_HOSTNAME)}:${key}/`);
361
+ restHostnames.push(`${value.protocol_name.toLowerCase()}://${getThisNodeName()}:${key}/`);
367
362
  }
368
363
  }
369
364
 
@@ -7,6 +7,8 @@ const { configValidator } = require('../validation/configValidator.js');
7
7
  const fs = require('fs-extra');
8
8
  const YAML = require('yaml');
9
9
  const path = require('path');
10
+ const { threadId } = require('node:worker_threads');
11
+ const { randomBytes } = require('node:crypto');
10
12
  const isNumber = require('is-number');
11
13
  const PropertiesReader = require('properties-reader');
12
14
  const _ = require('lodash');
@@ -89,9 +91,11 @@ function getConfigPath(param) {
89
91
  return path.resolve(rootPath, value);
90
92
  }
91
93
 
92
- // Write atomically via temp file + rename so readers don't observe a truncated/empty file
94
+ // Write atomically via temp file + rename so readers don't observe a truncated/empty file.
95
+ // Temp path includes randomness so two worker threads in the same process (same pid) writing
96
+ // in the same millisecond can't collide on the temp name and then race the rename.
93
97
  function atomicWriteFile(filePath, content) {
94
- const tempPath = `${filePath}.${process.pid}.${Date.now()}.tmp`;
98
+ const tempPath = `${filePath}.${process.pid}.${threadId}.${randomBytes(4).toString('hex')}.tmp`;
95
99
  fs.writeFileSync(tempPath, content);
96
100
  fs.renameSync(tempPath, filePath);
97
101
  }