@harperfast/harper 5.3.0-alpha.1 → 5.3.0-beta.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/bin/cliOperations.ts +12 -0
- package/bin/restart.ts +66 -6
- package/components/Application.ts +1134 -112
- package/components/DESIGN.md +421 -0
- package/components/OptionsWatcher.ts +368 -102
- package/components/Scope.ts +20 -1
- package/components/componentLoader.ts +43 -4
- package/components/deploymentOperations.ts +4 -1
- package/components/deploymentRecorder.ts +9 -2
- package/components/mcp/DESIGN.md +109 -0
- package/components/mcp/audit.ts +21 -17
- package/components/operations.js +284 -52
- package/components/operationsValidation.js +49 -2
- package/components/packageComponent.ts +25 -1
- package/components/requestRestart.ts +11 -0
- package/config/DESIGN.md +306 -0
- package/config/RootConfigWatcher.ts +191 -37
- package/config/configReadRetry.ts +62 -0
- package/config/configUtils.ts +78 -26
- package/config/parseConfigFile.ts +34 -0
- package/config/readConfigFileSync.ts +44 -0
- package/config/watcherArming.ts +59 -0
- package/config-root.schema.json +4 -0
- package/dataLayer/DESIGN.md +179 -0
- package/dataLayer/harperBridge/ResourceBridge.ts +28 -2
- package/dataLayer/restoreMarker.ts +92 -25
- package/dist/bin/cliOperations.js +13 -0
- package/dist/bin/cliOperations.js.map +1 -1
- package/dist/bin/restart.js +42 -6
- package/dist/bin/restart.js.map +1 -1
- package/dist/components/Application.d.ts +104 -9
- package/dist/components/Application.js +954 -102
- package/dist/components/Application.js.map +1 -1
- package/dist/components/OptionsWatcher.d.ts +4 -1
- package/dist/components/OptionsWatcher.js +378 -104
- package/dist/components/OptionsWatcher.js.map +1 -1
- package/dist/components/Scope.js +15 -1
- package/dist/components/Scope.js.map +1 -1
- package/dist/components/componentLoader.js +35 -3
- package/dist/components/componentLoader.js.map +1 -1
- package/dist/components/deploymentOperations.js +4 -1
- package/dist/components/deploymentOperations.js.map +1 -1
- package/dist/components/deploymentRecorder.d.ts +4 -2
- package/dist/components/deploymentRecorder.js +1 -0
- package/dist/components/deploymentRecorder.js.map +1 -1
- package/dist/components/mcp/audit.d.ts +2 -1
- package/dist/components/mcp/audit.js +21 -17
- package/dist/components/mcp/audit.js.map +1 -1
- package/dist/components/operations.d.ts +28 -0
- package/dist/components/operations.js +263 -54
- package/dist/components/operations.js.map +1 -1
- package/dist/components/operationsValidation.js +48 -2
- package/dist/components/operationsValidation.js.map +1 -1
- package/dist/components/packageComponent.js +24 -0
- package/dist/components/packageComponent.js.map +1 -1
- package/dist/components/requestRestart.d.ts +1 -0
- package/dist/components/requestRestart.js +7 -0
- package/dist/components/requestRestart.js.map +1 -1
- package/dist/config/RootConfigWatcher.d.ts +2 -0
- package/dist/config/RootConfigWatcher.js +189 -35
- package/dist/config/RootConfigWatcher.js.map +1 -1
- package/dist/config/configReadRetry.d.ts +8 -0
- package/dist/config/configReadRetry.js +62 -0
- package/dist/config/configReadRetry.js.map +1 -0
- package/dist/config/configUtils.d.ts +10 -9
- package/dist/config/configUtils.js +63 -27
- package/dist/config/configUtils.js.map +1 -1
- package/dist/config/parseConfigFile.d.ts +4 -0
- package/dist/config/parseConfigFile.js +35 -0
- package/dist/config/parseConfigFile.js.map +1 -0
- package/dist/config/readConfigFileSync.d.ts +1 -0
- package/dist/config/readConfigFileSync.js +47 -0
- package/dist/config/readConfigFileSync.js.map +1 -0
- package/dist/config/watcherArming.d.ts +15 -0
- package/dist/config/watcherArming.js +59 -0
- package/dist/config/watcherArming.js.map +1 -0
- package/dist/dataLayer/harperBridge/ResourceBridge.js +21 -2
- package/dist/dataLayer/harperBridge/ResourceBridge.js.map +1 -1
- package/dist/dataLayer/restoreMarker.d.ts +21 -8
- package/dist/dataLayer/restoreMarker.js +94 -27
- package/dist/dataLayer/restoreMarker.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/dist/json/systemSchema.json +3 -0
- package/dist/resources/DatabaseTransaction.d.ts +25 -0
- package/dist/resources/DatabaseTransaction.js +224 -18
- package/dist/resources/DatabaseTransaction.js.map +1 -1
- package/dist/resources/LMDBTransaction.d.ts +2 -1
- package/dist/resources/LMDBTransaction.js +22 -3
- package/dist/resources/LMDBTransaction.js.map +1 -1
- package/dist/resources/PrimaryRocksDatabase.js +22 -6
- package/dist/resources/PrimaryRocksDatabase.js.map +1 -1
- package/dist/resources/RecordEncoder.d.ts +1 -1
- package/dist/resources/RecordEncoder.js +46 -10
- package/dist/resources/RecordEncoder.js.map +1 -1
- package/dist/resources/Resource.js +97 -13
- package/dist/resources/Resource.js.map +1 -1
- package/dist/resources/ResourceInterface.d.ts +8 -0
- package/dist/resources/RocksIndexStore.js +2 -1
- package/dist/resources/RocksIndexStore.js.map +1 -1
- package/dist/resources/RocksTransactionLogStore.d.ts +10 -0
- package/dist/resources/RocksTransactionLogStore.js +104 -33
- package/dist/resources/RocksTransactionLogStore.js.map +1 -1
- package/dist/resources/Table.d.ts +58 -7
- package/dist/resources/Table.js +1143 -348
- package/dist/resources/Table.js.map +1 -1
- package/dist/resources/analytics/write.d.ts +3 -0
- package/dist/resources/analytics/write.js +49 -16
- package/dist/resources/analytics/write.js.map +1 -1
- package/dist/resources/auditStore.d.ts +170 -0
- package/dist/resources/auditStore.js +457 -11
- package/dist/resources/auditStore.js.map +1 -1
- package/dist/resources/crdt.d.ts +10 -0
- package/dist/resources/crdt.js +22 -0
- package/dist/resources/crdt.js.map +1 -1
- package/dist/resources/dataLoader.js +3 -4
- package/dist/resources/dataLoader.js.map +1 -1
- package/dist/resources/databases.d.ts +16 -13
- package/dist/resources/databases.js +625 -177
- package/dist/resources/databases.js.map +1 -1
- package/dist/resources/derivedIndexRegistry.d.ts +5 -0
- package/dist/resources/derivedIndexRegistry.js +68 -0
- package/dist/resources/derivedIndexRegistry.js.map +1 -0
- package/dist/resources/derivedIndexRuntime.d.ts +215 -0
- package/dist/resources/derivedIndexRuntime.js +2027 -0
- package/dist/resources/derivedIndexRuntime.js.map +1 -0
- package/dist/resources/graphql.js +3 -2
- package/dist/resources/graphql.js.map +1 -1
- package/dist/resources/indexes/HierarchicalNavigableSmallWorld.d.ts +102 -9
- package/dist/resources/indexes/HierarchicalNavigableSmallWorld.js +867 -39
- package/dist/resources/indexes/HierarchicalNavigableSmallWorld.js.map +1 -1
- package/dist/resources/indexes/fullTextDerivedIndex.d.ts +81 -0
- package/dist/resources/indexes/fullTextDerivedIndex.js +1004 -0
- package/dist/resources/indexes/fullTextDerivedIndex.js.map +1 -0
- package/dist/resources/indexes/fullTextNativeBinding.d.ts +78 -0
- package/dist/resources/indexes/fullTextNativeBinding.js +85 -0
- package/dist/resources/indexes/fullTextNativeBinding.js.map +1 -0
- package/dist/resources/indexes/hnswDerivedIndex.d.ts +67 -0
- package/dist/resources/indexes/hnswDerivedIndex.js +464 -0
- package/dist/resources/indexes/hnswDerivedIndex.js.map +1 -0
- package/dist/resources/indexes/hnswPlaneBinding.d.ts +65 -0
- package/dist/resources/indexes/hnswPlaneBinding.js +91 -0
- package/dist/resources/indexes/hnswPlaneBinding.js.map +1 -0
- package/dist/resources/indexes/nativeFullTextDerivedIndexLifecycle.d.ts +24 -0
- package/dist/resources/indexes/nativeFullTextDerivedIndexLifecycle.js +149 -0
- package/dist/resources/indexes/nativeFullTextDerivedIndexLifecycle.js.map +1 -0
- package/dist/resources/nodeIdMapping.d.ts +5 -0
- package/dist/resources/nodeIdMapping.js +49 -0
- package/dist/resources/nodeIdMapping.js.map +1 -1
- package/dist/resources/recordLock.d.ts +47 -4
- package/dist/resources/recordLock.js +138 -7
- package/dist/resources/recordLock.js.map +1 -1
- package/dist/resources/recordLockCoordinator.d.ts +557 -0
- package/dist/resources/recordLockCoordinator.js +2597 -0
- package/dist/resources/recordLockCoordinator.js.map +1 -0
- package/dist/resources/replayLogs.js +5 -0
- package/dist/resources/replayLogs.js.map +1 -1
- package/dist/resources/replicatedApplyFailure.d.ts +16 -0
- package/dist/resources/replicatedApplyFailure.js +63 -0
- package/dist/resources/replicatedApplyFailure.js.map +1 -0
- package/dist/resources/scheduler/scheduler.js +3 -3
- package/dist/resources/scheduler/scheduler.js.map +1 -1
- package/dist/resources/search.d.ts +10 -4
- package/dist/resources/search.js +160 -40
- package/dist/resources/search.js.map +1 -1
- package/dist/resources/tracked.d.ts +5 -1
- package/dist/resources/tracked.js +74 -23
- package/dist/resources/tracked.js.map +1 -1
- package/dist/resources/transactionBroadcast.js +4 -6
- package/dist/resources/transactionBroadcast.js.map +1 -1
- package/dist/security/auth.js +59 -23
- package/dist/security/auth.js.map +1 -1
- package/dist/security/deferredAuthentication.d.ts +11 -0
- package/dist/security/deferredAuthentication.js +25 -3
- package/dist/security/deferredAuthentication.js.map +1 -1
- package/dist/security/jsLoader.js +9 -4
- package/dist/security/jsLoader.js.map +1 -1
- package/dist/server/REST.js +39 -5
- package/dist/server/REST.js.map +1 -1
- package/dist/server/http.d.ts +5 -1
- package/dist/server/http.js +34 -2
- package/dist/server/http.js.map +1 -1
- package/dist/server/mqtt.js +5 -1
- package/dist/server/mqtt.js.map +1 -1
- package/dist/server/serverHelpers/Headers.d.ts +2 -0
- package/dist/server/serverHelpers/Headers.js +6 -0
- package/dist/server/serverHelpers/Headers.js.map +1 -1
- package/dist/server/serverHelpers/NodeAdapterResponse.d.ts +48 -0
- package/dist/server/serverHelpers/NodeAdapterResponse.js +220 -0
- package/dist/server/serverHelpers/NodeAdapterResponse.js.map +1 -0
- package/dist/server/serverHelpers/Request.d.ts +5 -10
- package/dist/server/serverHelpers/Request.js +38 -136
- package/dist/server/serverHelpers/Request.js.map +1 -1
- package/dist/server/serverHelpers/contentTypes.d.ts +2 -0
- package/dist/server/serverHelpers/contentTypes.js +189 -15
- package/dist/server/serverHelpers/contentTypes.js.map +1 -1
- package/dist/server/serverHelpers/serverUtilities.d.ts +3 -3
- package/dist/server/serverHelpers/serverUtilities.js +110 -20
- package/dist/server/serverHelpers/serverUtilities.js.map +1 -1
- package/dist/server/serverHelpers/uwsServer.js +4 -1
- package/dist/server/serverHelpers/uwsServer.js.map +1 -1
- package/dist/server/serverHelpers/webSocketCloseReason.d.ts +2 -0
- package/dist/server/serverHelpers/webSocketCloseReason.js +29 -0
- package/dist/server/serverHelpers/webSocketCloseReason.js.map +1 -0
- package/dist/server/storageReclamation.js +1 -1
- package/dist/server/storageReclamation.js.map +1 -1
- package/dist/server/threads/isolatedApplications.d.ts +47 -0
- package/dist/server/threads/isolatedApplications.js +171 -0
- package/dist/server/threads/isolatedApplications.js.map +1 -0
- package/dist/server/threads/logRotationTransport.d.ts +1 -0
- package/dist/server/threads/logRotationTransport.js +33 -0
- package/dist/server/threads/logRotationTransport.js.map +1 -0
- package/dist/server/threads/manageThreads.d.ts +64 -6
- package/dist/server/threads/manageThreads.js +261 -12
- package/dist/server/threads/manageThreads.js.map +1 -1
- package/dist/server/threads/socketRouter.d.ts +1 -0
- package/dist/server/threads/socketRouter.js +196 -13
- package/dist/server/threads/socketRouter.js.map +1 -1
- package/dist/server/threads/threadServer.js +30 -7
- package/dist/server/threads/threadServer.js.map +1 -1
- package/dist/utility/errors/hdbError.d.ts +24 -0
- package/dist/utility/errors/hdbError.js +58 -1
- package/dist/utility/errors/hdbError.js.map +1 -1
- package/dist/utility/hdbTerms.d.ts +2 -0
- package/dist/utility/hdbTerms.js +2 -0
- package/dist/utility/hdbTerms.js.map +1 -1
- package/dist/utility/logging/harper_logger.js +218 -38
- package/dist/utility/logging/harper_logger.js.map +1 -1
- package/dist/utility/logging/logGenerationCoordinator.d.ts +35 -0
- package/dist/utility/logging/logGenerationCoordinator.js +184 -0
- package/dist/utility/logging/logGenerationCoordinator.js.map +1 -0
- package/dist/utility/logging/logRotation.d.ts +46 -0
- package/dist/utility/logging/logRotation.js +365 -0
- package/dist/utility/logging/logRotation.js.map +1 -0
- package/dist/utility/logging/logRotator.d.ts +1 -1
- package/dist/utility/logging/logRotator.js +172 -92
- package/dist/utility/logging/logRotator.js.map +1 -1
- package/dist/utility/npmUtilities.js +6 -4
- package/dist/utility/npmUtilities.js.map +1 -1
- package/dist/utility/watcherFallback.d.ts +0 -45
- package/dist/utility/watcherFallback.js +1 -125
- package/dist/utility/watcherFallback.js.map +1 -1
- package/dist/validation/configValidator.js +6 -3
- package/dist/validation/configValidator.js.map +1 -1
- package/index.ts +9 -0
- package/json/systemSchema.json +3 -0
- package/npm-shrinkwrap.json +177 -87
- package/package.json +13 -5
- package/resources/DESIGN.md +689 -19
- package/resources/DatabaseTransaction.ts +230 -17
- package/resources/LMDBTransaction.ts +21 -3
- package/resources/PrimaryRocksDatabase.ts +20 -7
- package/resources/RecordEncoder.ts +52 -10
- package/resources/Resource.ts +97 -13
- package/resources/ResourceInterface.ts +8 -0
- package/resources/RocksIndexStore.ts +2 -1
- package/resources/RocksTransactionLogStore.ts +111 -31
- package/resources/Table.ts +1273 -396
- package/resources/analytics/DESIGN.md +38 -0
- package/resources/analytics/write.ts +50 -17
- package/resources/auditStore.ts +460 -11
- package/resources/crdt.ts +22 -0
- package/resources/dataLoader.ts +3 -4
- package/resources/databases.ts +611 -147
- package/resources/derivedIndexRegistry.ts +56 -0
- package/resources/derivedIndexRuntime.ts +2292 -0
- package/resources/graphql.ts +3 -2
- package/resources/indexes/DESIGN.md +833 -0
- package/resources/indexes/HierarchicalNavigableSmallWorld.ts +924 -46
- package/resources/indexes/fullTextDerivedIndex.ts +1165 -0
- package/resources/indexes/fullTextNativeBinding.ts +146 -0
- package/resources/indexes/hnswDerivedIndex.ts +531 -0
- package/resources/indexes/hnswPlaneBinding.ts +174 -0
- package/resources/indexes/nativeFullTextDerivedIndexLifecycle.ts +181 -0
- package/resources/nodeIdMapping.ts +50 -0
- package/resources/record-locks.md +1407 -0
- package/resources/recordLock.ts +173 -7
- package/resources/recordLockCoordinator.ts +3082 -0
- package/resources/replayLogs.ts +5 -0
- package/resources/replicatedApplyFailure.ts +77 -0
- package/resources/scheduler/DESIGN.md +40 -0
- package/resources/scheduler/scheduler.ts +4 -4
- package/resources/search.ts +169 -49
- package/resources/tracked.ts +73 -22
- package/resources/transactionBroadcast.ts +4 -4
- package/security/DESIGN.md +175 -0
- package/security/auth.ts +53 -24
- package/security/deferredAuthentication.ts +24 -2
- package/security/jsLoader.ts +9 -4
- package/server/DESIGN.md +275 -0
- package/server/REST.ts +42 -6
- package/server/http.ts +34 -2
- package/server/mqtt.ts +6 -4
- package/server/serverHelpers/Headers.ts +5 -1
- package/server/serverHelpers/NodeAdapterResponse.ts +221 -0
- package/server/serverHelpers/Request.ts +33 -131
- package/server/serverHelpers/contentTypes.ts +188 -15
- package/server/serverHelpers/serverUtilities.ts +157 -27
- package/server/serverHelpers/uwsServer.ts +4 -1
- package/server/serverHelpers/webSocketCloseReason.ts +25 -0
- package/server/storageReclamation.ts +2 -2
- package/server/threads/isolatedApplications.ts +157 -0
- package/server/threads/logRotationTransport.ts +40 -0
- package/server/threads/manageThreads.js +254 -12
- package/server/threads/socketRouter.ts +217 -11
- package/server/threads/threadServer.js +30 -7
- package/studio/web/assets/{Chat-BnCBegQz.js → Chat-DADFFGe_.js} +1 -1
- package/studio/web/assets/{FloatingChat-CoDW1ySS.js → FloatingChat-D_mI-rZ7.js} +3 -3
- package/studio/web/assets/{apiToken-Bwk5BLXW.js → apiToken-c2NiSDHa.js} +1 -1
- package/studio/web/assets/{applications-DHxGi7JH.js → applications-DktUqh7G.js} +1 -1
- package/studio/web/assets/{cssMode-s0cWI-_M.js → cssMode-Cs_75Xhw.js} +1 -1
- package/studio/web/assets/{editor-DNcRHK54.js → editor-19b-Y1IN.js} +1 -1
- package/studio/web/assets/{html-Bdssedlg.js → html-DiYEQMpB.js} +1 -1
- package/studio/web/assets/{htmlMode-CoDlJ3fw.js → htmlMode-CmR0y7P_.js} +1 -1
- package/studio/web/assets/{index-D6sxmFLR.js → index-Dm0rfkJ7.js} +5 -5
- package/studio/web/assets/{index.lazy-tmU5BS8s.js → index.lazy-7vqt2CC3.js} +1 -1
- package/studio/web/assets/{javascript-B8meVSTH.js → javascript-BWtCFuOt.js} +1 -1
- package/studio/web/assets/{jsonMode-DpIPd35T.js → jsonMode-Buzzbv9y.js} +1 -1
- package/studio/web/assets/{languageServices-C_5FMJzQ.js → languageServices-SqsFWfTM.js} +1 -1
- package/studio/web/assets/{lspLanguageFeatures-BIzNBzPK.js → lspLanguageFeatures-EMV5cmjo.js} +1 -1
- package/studio/web/assets/{notifications-CvZivSbh.js → notifications-CAB-LZWT.js} +1 -1
- package/studio/web/assets/{notifications-CQf18QKb.js → notifications-DRzmSRxM.js} +1 -1
- package/studio/web/assets/{profile-DdOwtntb.js → profile-BNKAl79n.js} +1 -1
- package/studio/web/assets/{regions-n69fwagr.js → regions-CUow_Zw2.js} +1 -1
- package/studio/web/assets/{register-PfWTCXWB.js → register-Dkt3WUMp.js} +2 -2
- package/studio/web/assets/{setComponentFile-Bg6O7X0S.js → setComponentFile-BZRfMD0N.js} +1 -1
- package/studio/web/assets/{setup-CUx_aUDl.js → setup-D_yiEPO2.js} +2 -2
- package/studio/web/assets/{status-D7BVKqX9.js → status-DhHh1Ge-.js} +1 -1
- package/studio/web/assets/{toggleHighContrast-DBSyXzMr.js → toggleHighContrast-D7L1PDtV.js} +1 -1
- package/studio/web/assets/{tsMode-BByKCjBS.js → tsMode-CCwLk1YS.js} +1 -1
- package/studio/web/assets/{typescript-DDLnLpw9.js → typescript-BP1j1mjn.js} +1 -1
- package/studio/web/assets/{useEntityRestURL-31CHGaHk.js → useEntityRestURL-D7bnYxLw.js} +1 -1
- package/studio/web/assets/{workers-pR3jRY9D.js → workers-tOuCNT17.js} +1 -1
- package/studio/web/assets/{xml-2iRnMhQO.js → xml-BSG_3mQT.js} +1 -1
- package/studio/web/assets/{yaml-Bf92gJpd.js → yaml-DxiLprBB.js} +1 -1
- package/studio/web/index.html +1 -1
- package/utility/DESIGN.md +55 -0
- package/utility/errors/hdbError.ts +54 -0
- package/utility/hdbTerms.ts +2 -0
- package/utility/logging/harper_logger.ts +210 -30
- package/utility/logging/logGenerationCoordinator.ts +196 -0
- package/utility/logging/logRotation.ts +367 -0
- package/utility/logging/logRotator.ts +196 -91
- package/utility/npmUtilities.ts +6 -4
- package/utility/watcherFallback.ts +0 -122
- package/validation/configValidator.ts +6 -3
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { FullTextDerivedIndexBackend, type FullTextDerivedIndexBackendOptions, type FullTextDerivedIndexEngine, type FullTextDerivedIndexInspection } from './fullTextDerivedIndex.ts';
|
|
2
|
+
import { type NativeFullTextIndexConfiguration, type NativeFullTextModule } from './fullTextNativeBinding.ts';
|
|
3
|
+
export type NativeFullTextDerivedIndexLifecycleOptions = NativeFullTextIndexConfiguration & {
|
|
4
|
+
storePath: string;
|
|
5
|
+
storeName: string;
|
|
6
|
+
indexId: string;
|
|
7
|
+
sourceGeneration: string;
|
|
8
|
+
binding?: NativeFullTextModule | (() => Promise<NativeFullTextModule>);
|
|
9
|
+
};
|
|
10
|
+
export type NativeFullTextDerivedIndexBackendOptions = Omit<FullTextDerivedIndexBackendOptions, 'lifecycle'> & Omit<NativeFullTextDerivedIndexLifecycleOptions, 'indexId'>;
|
|
11
|
+
export declare class NativeFullTextDerivedIndexLifecycle {
|
|
12
|
+
#private;
|
|
13
|
+
constructor(options: NativeFullTextDerivedIndexLifecycleOptions);
|
|
14
|
+
get path(): string;
|
|
15
|
+
initialize(options?: {
|
|
16
|
+
reclaimRetired?: boolean;
|
|
17
|
+
}): Promise<void>;
|
|
18
|
+
startRetiredStorageReclamation(): void;
|
|
19
|
+
get maxCommitPayloadBytes(): number;
|
|
20
|
+
inspect(): FullTextDerivedIndexInspection;
|
|
21
|
+
open(): Promise<FullTextDerivedIndexEngine>;
|
|
22
|
+
reset(): Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
export declare function createNativeFullTextDerivedIndexBackend(options: NativeFullTextDerivedIndexBackendOptions): Promise<FullTextDerivedIndexBackend>;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NativeFullTextDerivedIndexLifecycle = void 0;
|
|
4
|
+
exports.createNativeFullTextDerivedIndexBackend = createNativeFullTextDerivedIndexBackend;
|
|
5
|
+
const node_crypto_1 = require("node:crypto");
|
|
6
|
+
const node_path_1 = require("node:path");
|
|
7
|
+
const logger_ts_1 = require("../../utility/logging/logger.js");
|
|
8
|
+
const fullTextDerivedIndex_ts_1 = require("./fullTextDerivedIndex.js");
|
|
9
|
+
const fullTextNativeBinding_ts_1 = require("./fullTextNativeBinding.js");
|
|
10
|
+
const logger = (0, logger_ts_1.loggerWithTag)('fulltext-derived-index');
|
|
11
|
+
class NativeFullTextDerivedIndexLifecycle {
|
|
12
|
+
#options;
|
|
13
|
+
#path;
|
|
14
|
+
#generation;
|
|
15
|
+
#binding;
|
|
16
|
+
#maxCommitPayloadBytes;
|
|
17
|
+
#reclaimOperation = Promise.resolve();
|
|
18
|
+
constructor(options) {
|
|
19
|
+
if (!(0, node_path_1.isAbsolute)(options.storePath))
|
|
20
|
+
throw new TypeError('Full-text storePath must be absolute');
|
|
21
|
+
if (!options.storeName)
|
|
22
|
+
throw new TypeError('Full-text storeName is required');
|
|
23
|
+
if (!options.indexId)
|
|
24
|
+
throw new TypeError('Full-text indexId is required');
|
|
25
|
+
if (!options.sourceGeneration)
|
|
26
|
+
throw new TypeError('Full-text sourceGeneration is required');
|
|
27
|
+
this.#options = {
|
|
28
|
+
...options,
|
|
29
|
+
fields: options.fields.map((field) => ({ ...field })),
|
|
30
|
+
limits: { ...options.limits },
|
|
31
|
+
};
|
|
32
|
+
// Hashing bounds filenames for arbitrary store names; the index id remains in native metadata and logs.
|
|
33
|
+
this.#path = (0, node_path_1.join)((0, node_path_1.resolve)(options.storePath), `${digest(options.storeName)}.fulltext`);
|
|
34
|
+
this.#generation = digest(options.sourceGeneration);
|
|
35
|
+
}
|
|
36
|
+
get path() {
|
|
37
|
+
return this.#path;
|
|
38
|
+
}
|
|
39
|
+
async initialize(options = {}) {
|
|
40
|
+
const binding = await this.#getBinding();
|
|
41
|
+
binding.validateNativeFullTextIndexOptions({
|
|
42
|
+
...this.#nativeOptions(),
|
|
43
|
+
limits: this.#options.limits,
|
|
44
|
+
});
|
|
45
|
+
this.#maxCommitPayloadBytes = (0, fullTextNativeBinding_ts_1.getValidatedFullTextRuntimeInfo)(binding).limits.maxCommitPayloadBytes;
|
|
46
|
+
if (options.reclaimRetired !== false)
|
|
47
|
+
this.#queueReclaimRetired();
|
|
48
|
+
}
|
|
49
|
+
startRetiredStorageReclamation() {
|
|
50
|
+
this.#requireBinding();
|
|
51
|
+
// Fulltext publishes unique retired paths and removes them with force, so workers may sweep concurrently.
|
|
52
|
+
this.#queueReclaimRetired();
|
|
53
|
+
}
|
|
54
|
+
get maxCommitPayloadBytes() {
|
|
55
|
+
if (this.#maxCommitPayloadBytes === undefined)
|
|
56
|
+
throw new Error('Full-text lifecycle has not been initialized');
|
|
57
|
+
return this.#maxCommitPayloadBytes;
|
|
58
|
+
}
|
|
59
|
+
inspect() {
|
|
60
|
+
return this.#requireBinding().inspectNativeFullTextIndex(this.#nativeOptions());
|
|
61
|
+
}
|
|
62
|
+
async open() {
|
|
63
|
+
return this.#requireBinding().openNativeFullTextIndex({
|
|
64
|
+
...this.#nativeOptions(),
|
|
65
|
+
limits: this.#options.limits,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
async reset() {
|
|
69
|
+
const result = await this.#requireBinding().resetNativeFullTextIndex({
|
|
70
|
+
path: this.#path,
|
|
71
|
+
indexId: this.#options.indexId,
|
|
72
|
+
});
|
|
73
|
+
this.#queueReclaimRetired(result.state === 'reset' ? result.retiredPath : undefined);
|
|
74
|
+
}
|
|
75
|
+
#queueReclaimRetired(retiredPath) {
|
|
76
|
+
const reclaim = () => this.#reclaimRetired(retiredPath);
|
|
77
|
+
this.#reclaimOperation = this.#reclaimOperation.then(reclaim, reclaim).catch((error) => {
|
|
78
|
+
logWarning(`Could not complete reclamation for full-text index '${this.#options.indexId}'`, error);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
async #reclaimRetired(retiredPath) {
|
|
82
|
+
try {
|
|
83
|
+
const result = await this.#requireBinding().reclaimRetiredNativeFullTextIndexes({
|
|
84
|
+
path: this.#path,
|
|
85
|
+
retiredPath,
|
|
86
|
+
});
|
|
87
|
+
if (result.failed > 0)
|
|
88
|
+
logWarning(`Could not remove ${result.failed} retired paths for full-text index '${this.#options.indexId}'`);
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
logWarning(`Could not reclaim retired paths for full-text index '${this.#options.indexId}'`, error);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
#nativeOptions() {
|
|
95
|
+
return {
|
|
96
|
+
path: this.#path,
|
|
97
|
+
indexId: this.#options.indexId,
|
|
98
|
+
generation: this.#generation,
|
|
99
|
+
fields: this.#options.fields,
|
|
100
|
+
analyzer: this.#options.analyzer,
|
|
101
|
+
stopWords: this.#options.stopWords,
|
|
102
|
+
positions: this.#options.positions,
|
|
103
|
+
surfaceTerms: this.#options.surfaceTerms,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
async #getBinding() {
|
|
107
|
+
if (this.#binding)
|
|
108
|
+
return this.#binding;
|
|
109
|
+
const configured = this.#options.binding;
|
|
110
|
+
this.#binding = configured
|
|
111
|
+
? await (0, fullTextNativeBinding_ts_1.validateFullTextNativeBinding)(typeof configured === 'function' ? await configured() : configured)
|
|
112
|
+
: await (0, fullTextNativeBinding_ts_1.loadFullTextNativeBinding)();
|
|
113
|
+
return this.#binding;
|
|
114
|
+
}
|
|
115
|
+
#requireBinding() {
|
|
116
|
+
if (!this.#binding)
|
|
117
|
+
throw new Error('Full-text native binding has not been initialized');
|
|
118
|
+
return this.#binding;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
exports.NativeFullTextDerivedIndexLifecycle = NativeFullTextDerivedIndexLifecycle;
|
|
122
|
+
async function createNativeFullTextDerivedIndexBackend(options) {
|
|
123
|
+
const maxCursorPayloadBytes = options.maxCursorPayloadBytes ?? fullTextDerivedIndex_ts_1.HARPER_FULLTEXT_MAX_CURSOR_PAYLOAD_BYTES;
|
|
124
|
+
if (maxCursorPayloadBytes > fullTextDerivedIndex_ts_1.HARPER_FULLTEXT_MAX_CURSOR_PAYLOAD_BYTES)
|
|
125
|
+
throw new RangeError(`Full-text maxCursorPayloadBytes must not exceed ${fullTextDerivedIndex_ts_1.HARPER_FULLTEXT_MAX_CURSOR_PAYLOAD_BYTES}`);
|
|
126
|
+
const lifecycle = new NativeFullTextDerivedIndexLifecycle({ ...options, indexId: options.id });
|
|
127
|
+
await lifecycle.initialize({ reclaimRetired: false });
|
|
128
|
+
if (maxCursorPayloadBytes > lifecycle.maxCommitPayloadBytes)
|
|
129
|
+
throw new RangeError('Full-text maxCursorPayloadBytes exceeds the native commit payload capacity');
|
|
130
|
+
const backend = new fullTextDerivedIndex_ts_1.FullTextDerivedIndexBackend({
|
|
131
|
+
...options,
|
|
132
|
+
id: options.id,
|
|
133
|
+
lifecycle,
|
|
134
|
+
maxCursorPayloadBytes,
|
|
135
|
+
});
|
|
136
|
+
lifecycle.startRetiredStorageReclamation();
|
|
137
|
+
return backend;
|
|
138
|
+
}
|
|
139
|
+
function digest(value) {
|
|
140
|
+
return (0, node_crypto_1.createHash)('sha256').update(value).digest('hex');
|
|
141
|
+
}
|
|
142
|
+
function logWarning(message, error) {
|
|
143
|
+
const code = error && typeof error === 'object' && 'code' in error && typeof error.code === 'string' ? error.code : undefined;
|
|
144
|
+
try {
|
|
145
|
+
logger.warn?.(`${message}${code ? ` (${code})` : ''}`);
|
|
146
|
+
}
|
|
147
|
+
catch { }
|
|
148
|
+
}
|
|
149
|
+
//# sourceMappingURL=nativeFullTextDerivedIndexLifecycle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nativeFullTextDerivedIndexLifecycle.js","sourceRoot":"","sources":["../../../resources/indexes/nativeFullTextDerivedIndexLifecycle.ts"],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,KAAK,EAAE,CAAC,CAAC;IACtD,IAAI,qBAAqB,GAAG,SAAS,CAAC,qBAAqB;QAC1D,MAAM,IAAI,UAAU,CAAC,4EAA4E,CAAC,CAAC;IACpG,MAAM,OAAO,GAAG,IAAI,qDAA2B,CAAC;QAC/C,GAAG,OAAO;QACV,EAAE,EAAE,OAAO,CAAC,EAAE;QACd,SAAS;QACT,qBAAqB;KACrB,CAAC,CAAC;IACH,SAAS,CAAC,8BAA8B,EAAE,CAAC;IAC3C,OAAO,OAAO,CAAC;AAChB,CAAC;AAED,SAAS,MAAM,CAAC,KAAa;IAC5B,OAAO,IAAA,wBAAU,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACzD,CAAC;AAED,SAAS,UAAU,CAAC,OAAe,EAAE,KAAe;IACnD,MAAM,IAAI,GACT,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,IAAI,KAAK,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;IAClH,IAAI,CAAC;QACJ,MAAM,CAAC,IAAI,EAAE,CAAC,GAAG,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACxD,CAAC;IAAC,MAAM,CAAC,CAAA,CAAC;AACX,CAAC"}
|
|
@@ -11,3 +11,8 @@ export declare function getIdOfRemoteNode(remoteNodeName: any, auditStore: any):
|
|
|
11
11
|
*/
|
|
12
12
|
export declare function lastTimeInAuditStore(auditStore: Database): import("lmdb").Key;
|
|
13
13
|
export declare function getThisNodeId(auditStore: any): any;
|
|
14
|
+
/**
|
|
15
|
+
* The node name a local short id refers to. Callers that must attribute a replicated entry to its
|
|
16
|
+
* origin node need the globally stable name, not the id, which is assigned per node.
|
|
17
|
+
*/
|
|
18
|
+
export declare function getNodeNameForId(auditStore: any, nodeId: number | undefined, rebuildOnMiss?: boolean): string | undefined;
|
|
@@ -5,6 +5,7 @@ exports.remoteToLocalNodeId = remoteToLocalNodeId;
|
|
|
5
5
|
exports.getIdOfRemoteNode = getIdOfRemoteNode;
|
|
6
6
|
exports.lastTimeInAuditStore = lastTimeInAuditStore;
|
|
7
7
|
exports.getThisNodeId = getThisNodeId;
|
|
8
|
+
exports.getNodeNameForId = getNodeNameForId;
|
|
8
9
|
/**
|
|
9
10
|
* This module is responsible for managing the mapping of node/host names to node ids.
|
|
10
11
|
*/
|
|
@@ -56,6 +57,7 @@ function getIdMappingRecord(auditStore) {
|
|
|
56
57
|
// now we can take over the local node id
|
|
57
58
|
nameToId[node_name] = 0;
|
|
58
59
|
auditStore.putSync(REMOTE_NODE_IDS, (0, msgpackr_1.pack)(idMappingRecord));
|
|
60
|
+
invalidateNodeNames(auditStore);
|
|
59
61
|
}
|
|
60
62
|
return idMappingRecord;
|
|
61
63
|
}
|
|
@@ -89,6 +91,7 @@ function remoteToLocalNodeId(remoteMapping, auditStore) {
|
|
|
89
91
|
}
|
|
90
92
|
if (hasChanges) {
|
|
91
93
|
auditStore.putSync(REMOTE_NODE_IDS, (0, msgpackr_1.pack)(idMappingRecord));
|
|
94
|
+
invalidateNodeNames(auditStore);
|
|
92
95
|
}
|
|
93
96
|
return remoteToLocalId;
|
|
94
97
|
}
|
|
@@ -107,6 +110,7 @@ function getIdOfRemoteNode(remoteNodeName, auditStore) {
|
|
|
107
110
|
id = lastId + 1;
|
|
108
111
|
nameToId[remoteNodeName] = id;
|
|
109
112
|
auditStore.putSync(REMOTE_NODE_IDS, (0, msgpackr_1.pack)(idMappingRecord));
|
|
113
|
+
invalidateNodeNames(auditStore);
|
|
110
114
|
}
|
|
111
115
|
logger_ts_1.logger.trace?.('The remote node name map', remoteNodeName, nameToId, id);
|
|
112
116
|
return id;
|
|
@@ -126,4 +130,49 @@ function lastTimeInAuditStore(auditStore) {
|
|
|
126
130
|
function getThisNodeId(auditStore) {
|
|
127
131
|
return exportIdMapping(auditStore)?.[Server_ts_1.server.hostname];
|
|
128
132
|
}
|
|
133
|
+
// Inverted id -> name map. exportIdMapping() re-reads and unpacks the mapping record on every call,
|
|
134
|
+
// which is far too much per replicated entry on the apply thread; ids are stable once minted, so the
|
|
135
|
+
// inversion is cached and dropped wherever nameToId is written. Keyed per audit store because short
|
|
136
|
+
// ids are minted per database in first-seen order — id 1 names a different node in each one.
|
|
137
|
+
// Refresh window for a MISS. A hit is always trusted, but a miss cannot be: ids are minted by
|
|
138
|
+
// whichever worker first talks to a peer, and invalidation only reaches that worker's own copy — so
|
|
139
|
+
// a newly admitted node is absent from every other worker's map until it is rebuilt. Rebuilding on
|
|
140
|
+
// every miss would put a store read and unpack back on the apply thread for each unmapped entry, so
|
|
141
|
+
// misses re-read at most this often — short enough that a joining node loses at most a stray entry,
|
|
142
|
+
// long enough that a burst of unmapped ids cannot drive the store. `onMiss` records whether the
|
|
143
|
+
// cached map was built by a `rebuildOnMiss` caller, which is what bounds that caller to one read per
|
|
144
|
+
// window too rather than exempting it from the interval entirely.
|
|
145
|
+
const NODE_NAME_REFRESH_MS = 50;
|
|
146
|
+
const idToNodeName = new WeakMap();
|
|
147
|
+
function invalidateNodeNames(auditStore) {
|
|
148
|
+
idToNodeName.delete(auditStore);
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* The node name a local short id refers to. Callers that must attribute a replicated entry to its
|
|
152
|
+
* origin node need the globally stable name, not the id, which is assigned per node.
|
|
153
|
+
*/
|
|
154
|
+
function getNodeNameForId(auditStore, nodeId, rebuildOnMiss = false) {
|
|
155
|
+
if (typeof nodeId !== 'number' || !auditStore)
|
|
156
|
+
return undefined;
|
|
157
|
+
const cached = idToNodeName.get(auditStore);
|
|
158
|
+
const hit = cached?.names.get(nodeId);
|
|
159
|
+
if (hit !== undefined)
|
|
160
|
+
return hit;
|
|
161
|
+
const now = Date.now();
|
|
162
|
+
// `rebuildOnMiss` is for entry classes whose loss costs more than the read: a dropped record lock
|
|
163
|
+
// release leaves the home holding a grant until its own deadline, so a just-minted id is worth one
|
|
164
|
+
// store read rather than up to `NODE_NAME_REFRESH_MS` of dropped entries. ONE read, though, not one
|
|
165
|
+
// per entry — an id this map will never resolve (a node whose mapping was purged, an origin
|
|
166
|
+
// relayed from a database that never minted one) is exactly the burst the interval exists to keep
|
|
167
|
+
// off the apply thread, and a rebuild inside the window is not stale: a write to the mapping drops
|
|
168
|
+
// this entry outright (`invalidateNodeNames`).
|
|
169
|
+
if (cached && now - cached.refreshedAt < NODE_NAME_REFRESH_MS && (!rebuildOnMiss || cached.onMiss))
|
|
170
|
+
return undefined;
|
|
171
|
+
const nameToId = exportIdMapping(auditStore);
|
|
172
|
+
const names = new Map();
|
|
173
|
+
for (const name in nameToId)
|
|
174
|
+
names.set(nameToId[name], name);
|
|
175
|
+
idToNodeName.set(auditStore, { names, refreshedAt: now, onMiss: rebuildOnMiss });
|
|
176
|
+
return names.get(nodeId);
|
|
177
|
+
}
|
|
129
178
|
//# sourceMappingURL=nodeIdMapping.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeIdMapping.js","sourceRoot":"","sources":["../../resources/nodeIdMapping.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"nodeIdMapping.js","sourceRoot":"","sources":["../../resources/nodeIdMapping.ts"],"names":[],"mappings":";;AAwDA,0CAEC;AAKD,kDA2BC;AAED,8CAmBC;AAMD,oDAOC;AACD,sCAEC;AAwBD,4CAuBC;AA9KD;;GAEG;AACH,4DAAsD;AACtD,uDAAwD;AACxD,uCAAwC;AAExC,mDAA6C;AAE7C,MAAM,eAAe,GAAG,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;AACjD,SAAS,kBAAkB,CAAC,UAAU;IACrC,MAAM,qBAAqB,GAAG,UAAU,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;IACpE,I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;IAC/C,IAAI,MAAM,IAAI,GAAG,GAAG,MAAM,CAAC,WAAW,GAAG,oBAAoB,IAAI,CAAC,CAAC,aAAa,IAAI,MAAM,CAAC,MAAM,CAAC;QAAE,OAAO,SAAS,CAAC;IACrH,MAAM,QAAQ,GAAG,eAAe,CAAC,UAAU,CAAC,CAAC;IAC7C,MAAM,KAAK,GAAG,IAAI,GAAG,EAAkB,CAAC;IACxC,KAAK,MAAM,IAAI,IAAI,QAAQ;QAAE,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC;IAC7D,YAAY,CAAC,GAAG,CAAC,UAAU,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC,CAAC;IACjF,OAAO,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import { ClientError } from '../utility/errors/hdbError.ts';
|
|
2
2
|
/**
|
|
3
|
-
* Exclusive per-record locks (harper#483
|
|
3
|
+
* Exclusive per-record locks (harper#483).
|
|
4
4
|
*
|
|
5
|
-
* The
|
|
6
|
-
* shared by every worker thread's handle.
|
|
7
|
-
*
|
|
5
|
+
* The intra-node authority is the rocksdb-js process-wide key lock: one `locks` map per DBDescriptor
|
|
6
|
+
* shared by every worker thread's handle. Acquiring and releasing it write nothing to the store, and
|
|
7
|
+
* the record's version and bytes are unchanged.
|
|
8
|
+
*
|
|
9
|
+
* Phase 1 layers cluster-wide exclusion on top without changing that: once the native key is held,
|
|
10
|
+
* `Table.lock()` obtains a delegation for the key from its home node (see `recordLockCoordinator.ts`)
|
|
11
|
+
* and calls `joinClusterRound()` on the handle. A live delegation serves repeat locks with no cluster
|
|
12
|
+
* message at all. A node-scoped lock (`{ scope: 'node' }`), or any lock on a database with no
|
|
13
|
+
* transport registered, skips the cluster step entirely and behaves exactly as it did in Phase 0.
|
|
8
14
|
*/
|
|
9
15
|
export declare const DEFAULT_LOCK_LEASE_MS = 30000;
|
|
10
16
|
/** Below this a generation can expire before the caller's work completes, handing back a lock already lost. */
|
|
@@ -19,11 +25,19 @@ export interface RecordLockOptions {
|
|
|
19
25
|
timeout?: number;
|
|
20
26
|
/** A held lock outlives the acquiring transaction; it is released by `unlock()` or by its lease */
|
|
21
27
|
hold?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* `'cluster'` (default) is exclusive across every participating node; `'node'` keeps Phase 0
|
|
30
|
+
* semantics and is exclusive only across this node's worker threads.
|
|
31
|
+
*/
|
|
32
|
+
scope?: 'cluster' | 'node';
|
|
22
33
|
}
|
|
23
34
|
export interface ResolvedRecordLockOptions {
|
|
24
35
|
lease: number;
|
|
25
36
|
timeout: number;
|
|
26
37
|
hold: boolean;
|
|
38
|
+
scope: 'cluster' | 'node';
|
|
39
|
+
/** True when the caller named `scope` explicitly, which makes `'cluster'` fail-closed. */
|
|
40
|
+
scopeRequested: boolean;
|
|
27
41
|
}
|
|
28
42
|
/**
|
|
29
43
|
* The handle returned by `lock()` and held by each gated write until its transaction completes.
|
|
@@ -48,6 +62,35 @@ export interface RecordLockHandle {
|
|
|
48
62
|
noteCandidateFloor(version: number): void;
|
|
49
63
|
/** Compute a holder-write version without advancing the floor until that write commits. */
|
|
50
64
|
holderVersionCandidate(floor?: number): number;
|
|
65
|
+
/** `ts_R` of the granted cluster round; undefined while the hold is node-scoped (Phase 0). */
|
|
66
|
+
clusterTsR?: number;
|
|
67
|
+
/**
|
|
68
|
+
* Whether this handle may still authorize a write, evaluated NOW rather than trusting the lease
|
|
69
|
+
* timer to have run. A holder whose event loop stalled past its deadline would otherwise commit
|
|
70
|
+
* between the deadline and its own timer callback, while peers had already expired the hold.
|
|
71
|
+
* Expiry is detected on a monotonic clock, so a wall-clock jump cannot extend a lease.
|
|
72
|
+
*/
|
|
73
|
+
isExpired(): boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Whether the LEASE elapsed. Distinct from `isExpired()` in that a deliberate release does NOT
|
|
76
|
+
* make it true on its own: a write staged while the lock was held stays valid at commit if the
|
|
77
|
+
* caller merely unlocked. Once the deadline passes it is true either way, because by then peers
|
|
78
|
+
* have passed their own bound and the key may already belong to someone else.
|
|
79
|
+
*/
|
|
80
|
+
isLeaseExpired(): boolean;
|
|
81
|
+
/** Revoke authority ahead of the lease, so a staged-but-uncommitted write is fenced at commit. */
|
|
82
|
+
revokeLease(): void;
|
|
83
|
+
/**
|
|
84
|
+
* Re-anchor a granted cluster round: the hold now runs from `tsR` (no margin, so this node
|
|
85
|
+
* always expires before any participant does) and `onRelease` emits the durable LOCK_RELEASE.
|
|
86
|
+
* Returns false when the round completed after the lease had already elapsed.
|
|
87
|
+
*
|
|
88
|
+
* `mintedMono` is `performance.now()` at the instant `tsR` was minted. The remaining lease is
|
|
89
|
+
* measured from it rather than from `tsR - Date.now()`: `tsR` comes from a never-decreasing
|
|
90
|
+
* monotonic source, so after a backward wall-clock step that subtraction would hand back MORE
|
|
91
|
+
* lease than the round was granted, past what every peer bounded from its own observation.
|
|
92
|
+
*/
|
|
93
|
+
joinClusterRound(tsR: number, leaseMs: number, mintedMono: number, onRelease: () => void): boolean;
|
|
51
94
|
/**
|
|
52
95
|
* Return the next version to stamp a holder write with. Starts at acquiredAt when no transaction
|
|
53
96
|
* version has been noted; otherwise advances by the minimum monotonic step from the recorded floor.
|
|
@@ -9,14 +9,21 @@ exports.lockNotHeldError = lockNotHeldError;
|
|
|
9
9
|
exports.lockAttemptKey = lockAttemptKey;
|
|
10
10
|
exports.makeKeyLockHandle = makeKeyLockHandle;
|
|
11
11
|
exports.acquireRecordKey = acquireRecordKey;
|
|
12
|
+
const node_perf_hooks_1 = require("node:perf_hooks");
|
|
12
13
|
const harper_logger_ts_1 = __importDefault(require("../utility/logging/harper_logger.js"));
|
|
13
14
|
const hdbError_ts_1 = require("../utility/errors/hdbError.js");
|
|
14
15
|
/**
|
|
15
|
-
* Exclusive per-record locks (harper#483
|
|
16
|
+
* Exclusive per-record locks (harper#483).
|
|
16
17
|
*
|
|
17
|
-
* The
|
|
18
|
-
* shared by every worker thread's handle.
|
|
19
|
-
*
|
|
18
|
+
* The intra-node authority is the rocksdb-js process-wide key lock: one `locks` map per DBDescriptor
|
|
19
|
+
* shared by every worker thread's handle. Acquiring and releasing it write nothing to the store, and
|
|
20
|
+
* the record's version and bytes are unchanged.
|
|
21
|
+
*
|
|
22
|
+
* Phase 1 layers cluster-wide exclusion on top without changing that: once the native key is held,
|
|
23
|
+
* `Table.lock()` obtains a delegation for the key from its home node (see `recordLockCoordinator.ts`)
|
|
24
|
+
* and calls `joinClusterRound()` on the handle. A live delegation serves repeat locks with no cluster
|
|
25
|
+
* message at all. A node-scoped lock (`{ scope: 'node' }`), or any lock on a database with no
|
|
26
|
+
* transport registered, skips the cluster step entirely and behaves exactly as it did in Phase 0.
|
|
20
27
|
*/
|
|
21
28
|
exports.DEFAULT_LOCK_LEASE_MS = 30_000;
|
|
22
29
|
/** Below this a generation can expire before the caller's work completes, handing back a lock already lost. */
|
|
@@ -40,10 +47,15 @@ function resolveLockOptions(options) {
|
|
|
40
47
|
const hold = options?.hold ?? false;
|
|
41
48
|
if (typeof hold !== 'boolean')
|
|
42
49
|
throw new hdbError_ts_1.ClientError(`Lock option hold must be a boolean, but received ${hold}`);
|
|
50
|
+
const scope = options?.scope ?? 'cluster';
|
|
51
|
+
if (scope !== 'cluster' && scope !== 'node')
|
|
52
|
+
throw new hdbError_ts_1.ClientError(`Lock option scope must be 'cluster' or 'node', but received ${scope}`);
|
|
43
53
|
return {
|
|
44
54
|
lease: requireDuration('lease', options?.lease, exports.DEFAULT_LOCK_LEASE_MS, exports.MIN_LOCK_LEASE_MS, exports.MAX_LOCK_LEASE_MS),
|
|
45
55
|
timeout: requireDuration('timeout', options?.timeout, exports.DEFAULT_LOCK_TIMEOUT_MS, 1, exports.MAX_LOCK_TIMEOUT_MS),
|
|
46
56
|
hold,
|
|
57
|
+
scope,
|
|
58
|
+
scopeRequested: options?.scope !== undefined,
|
|
47
59
|
};
|
|
48
60
|
}
|
|
49
61
|
/**
|
|
@@ -59,6 +71,20 @@ function lockAttemptKey(tableId, id) {
|
|
|
59
71
|
return Array.isArray(id) ? [LOCK_KEY_PREFIX, tableId, ...id] : [LOCK_KEY_PREFIX, tableId, id];
|
|
60
72
|
}
|
|
61
73
|
const warnedLeaseTimerStores = new WeakSet();
|
|
74
|
+
/**
|
|
75
|
+
* Rate-limited rather than latched, for the reason `warnOnce` in the coordinator gives: a release
|
|
76
|
+
* that cannot be written leaves peers waiting out the lease, and a latch would show an operator the
|
|
77
|
+
* first occurrence and then hide the condition for as long as it lasts.
|
|
78
|
+
*/
|
|
79
|
+
const CLUSTER_RELEASE_WARN_INTERVAL_MS = 60_000;
|
|
80
|
+
let lastClusterReleaseWarn = -Infinity;
|
|
81
|
+
function warnClusterReleaseFailure(err) {
|
|
82
|
+
const now = node_perf_hooks_1.performance.now();
|
|
83
|
+
if (now - lastClusterReleaseWarn < CLUSTER_RELEASE_WARN_INTERVAL_MS)
|
|
84
|
+
return;
|
|
85
|
+
lastClusterReleaseWarn = now;
|
|
86
|
+
harper_logger_ts_1.default.warn?.('cluster record lock release could not be written; peers will expire the hold', err);
|
|
87
|
+
}
|
|
62
88
|
class KeyLockHandle {
|
|
63
89
|
store;
|
|
64
90
|
key;
|
|
@@ -68,9 +94,15 @@ class KeyLockHandle {
|
|
|
68
94
|
released = false;
|
|
69
95
|
expired = false;
|
|
70
96
|
acquiredAt;
|
|
97
|
+
clusterTsR;
|
|
71
98
|
#lastHolderVersion;
|
|
72
99
|
#candidateFloor;
|
|
73
100
|
#timer;
|
|
101
|
+
// Monotonic mirror of expiresAt. The wall-clock field stays public (callers and the cluster
|
|
102
|
+
// protocol both speak in timestamps) but the enforcement compares monotonic readings, so neither
|
|
103
|
+
// an NTP step nor a manual clock change can extend a lease past what peers assumed.
|
|
104
|
+
#deadlineMono;
|
|
105
|
+
#onRelease;
|
|
74
106
|
constructor(store, key, keyId, lease, hold = false, acquiredAt) {
|
|
75
107
|
this.store = store;
|
|
76
108
|
this.key = key;
|
|
@@ -79,6 +111,7 @@ class KeyLockHandle {
|
|
|
79
111
|
this.hold = hold;
|
|
80
112
|
this.acquiredAt = acquiredAt ?? store.getMonotonicTimestamp();
|
|
81
113
|
if (lease != null) {
|
|
114
|
+
this.#deadlineMono = node_perf_hooks_1.performance.now() + lease;
|
|
82
115
|
this.#timer = setTimeout(() => this.#onLeaseExpire(), lease).unref();
|
|
83
116
|
}
|
|
84
117
|
}
|
|
@@ -93,7 +126,70 @@ class KeyLockHandle {
|
|
|
93
126
|
const MIN_STEP = 0.000488;
|
|
94
127
|
return Math.max(this.#lastHolderVersion != null ? this.#lastHolderVersion + MIN_STEP : this.acquiredAt, this.acquiredAt, this.#candidateFloor ?? -Infinity, floor ?? -Infinity);
|
|
95
128
|
}
|
|
129
|
+
isExpired() {
|
|
130
|
+
return this.released || this.expired || this.#leaseLapsed();
|
|
131
|
+
}
|
|
132
|
+
isLeaseExpired() {
|
|
133
|
+
return this.expired || this.#leaseLapsed();
|
|
134
|
+
}
|
|
135
|
+
// The single place the deadline is evaluated, so the two predicates cannot disagree about it. A
|
|
136
|
+
// deliberate release does not make a lapsed lease valid again: by then peers have passed their own
|
|
137
|
+
// bound and the key may belong to someone else.
|
|
138
|
+
#leaseLapsed() {
|
|
139
|
+
if (this.#deadlineMono === undefined || node_perf_hooks_1.performance.now() < this.#deadlineMono)
|
|
140
|
+
return false;
|
|
141
|
+
// Finish the expiry rather than only reporting it: the native key must actually go back so a
|
|
142
|
+
// stalled holder does not keep a key every participant has already written off.
|
|
143
|
+
if (!this.released)
|
|
144
|
+
this.#onLeaseExpire();
|
|
145
|
+
return true;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Revoke this handle's authority immediately, ahead of its lease. A recall must stop a delegate
|
|
149
|
+
* from COMMITTING, not merely from admitting: a caller that already staged a write and then called
|
|
150
|
+
* `unlock()` has nothing outstanding for a drain to wait on, but its write is still in the
|
|
151
|
+
* transaction and would land after the successor was admitted. Expiring the handle is what makes
|
|
152
|
+
* the commit-time fence reject it (§6).
|
|
153
|
+
*/
|
|
154
|
+
revokeLease() {
|
|
155
|
+
if (this.expired)
|
|
156
|
+
return;
|
|
157
|
+
// `expired` is what the commit-time fence reads, and it must be set even when the caller has
|
|
158
|
+
// ALREADY unlocked: a write staged before `unlock()` is still in its transaction, and that is
|
|
159
|
+
// precisely the handoff §6 exists to fence. Gating this on `released` made the revocation a
|
|
160
|
+
// no-op in the one state it was written for.
|
|
161
|
+
this.expired = true;
|
|
162
|
+
if (this.released) {
|
|
163
|
+
// The native key is already back and `onRelease` already fired; only the fence flag and the
|
|
164
|
+
// lease timer are left to settle.
|
|
165
|
+
clearTimeout(this.#timer);
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
this.#onLeaseExpire();
|
|
169
|
+
}
|
|
170
|
+
joinClusterRound(tsR, leaseMs, mintedMono, onRelease) {
|
|
171
|
+
// A round that completed after the native lease already fired yields no usable hold: the key
|
|
172
|
+
// has gone back and another worker may hold it, so every write through this handle would 409.
|
|
173
|
+
if (this.isLeaseExpired())
|
|
174
|
+
return false;
|
|
175
|
+
const remaining = leaseMs - (node_perf_hooks_1.performance.now() - mintedMono);
|
|
176
|
+
if (remaining <= 0)
|
|
177
|
+
return false;
|
|
178
|
+
this.clusterTsR = tsR;
|
|
179
|
+
this.acquiredAt = tsR;
|
|
180
|
+
this.#lastHolderVersion = undefined;
|
|
181
|
+
this.#onRelease = onRelease;
|
|
182
|
+
this.expiresAt = tsR + leaseMs;
|
|
183
|
+
// From the mint origin, not a second clock read: the design says this bound has no margin.
|
|
184
|
+
this.#deadlineMono = mintedMono + leaseMs;
|
|
185
|
+
clearTimeout(this.#timer);
|
|
186
|
+
this.#timer = setTimeout(() => this.#onLeaseExpire(), remaining).unref();
|
|
187
|
+
return true;
|
|
188
|
+
}
|
|
96
189
|
nextHolderVersion() {
|
|
190
|
+
// TODO(harper#2412): under the settled dual-clock model the lock-ordered stamp belongs in the
|
|
191
|
+
// distinct-version second word (HAS_DISTINCT_VERSION_FLAG), not the transaction timestamp.
|
|
192
|
+
// Until that lands, Phase 1 keeps this Phase 0 mechanism, anchored at ts_R in cluster mode.
|
|
97
193
|
const next = this.holderVersionCandidate();
|
|
98
194
|
this.#lastHolderVersion = next;
|
|
99
195
|
return next;
|
|
@@ -103,6 +199,7 @@ class KeyLockHandle {
|
|
|
103
199
|
return;
|
|
104
200
|
this.released = true;
|
|
105
201
|
this.expired = true;
|
|
202
|
+
clearTimeout(this.#timer);
|
|
106
203
|
try {
|
|
107
204
|
this.store.unlock(this.key);
|
|
108
205
|
}
|
|
@@ -112,6 +209,25 @@ class KeyLockHandle {
|
|
|
112
209
|
harper_logger_ts_1.default.warn?.('record lock lease timer failed (store may have been dropped)', err);
|
|
113
210
|
}
|
|
114
211
|
}
|
|
212
|
+
this.#emitRelease();
|
|
213
|
+
}
|
|
214
|
+
// The cluster release is a durability optimization, not the safety mechanism — peers expire the
|
|
215
|
+
// hold on their own lease bound — so neither a throw nor a rejected promise may escape here. This
|
|
216
|
+
// runs from a lease timer and from post-commit cleanup, where an escaping rejection would take
|
|
217
|
+
// down the worker or turn a committed transaction into a 500.
|
|
218
|
+
#emitRelease() {
|
|
219
|
+
const onRelease = this.#onRelease;
|
|
220
|
+
if (!onRelease)
|
|
221
|
+
return;
|
|
222
|
+
this.#onRelease = undefined;
|
|
223
|
+
try {
|
|
224
|
+
const result = onRelease();
|
|
225
|
+
if (result && typeof result.then === 'function')
|
|
226
|
+
result.then(undefined, warnClusterReleaseFailure);
|
|
227
|
+
}
|
|
228
|
+
catch (err) {
|
|
229
|
+
warnClusterReleaseFailure(err);
|
|
230
|
+
}
|
|
115
231
|
}
|
|
116
232
|
release() {
|
|
117
233
|
if (this.released)
|
|
@@ -127,13 +243,28 @@ class KeyLockHandle {
|
|
|
127
243
|
harper_logger_ts_1.default.warn?.('record lock release failed (store may have been dropped)', err);
|
|
128
244
|
}
|
|
129
245
|
}
|
|
246
|
+
this.#emitRelease();
|
|
130
247
|
return true;
|
|
131
248
|
}
|
|
132
249
|
upgradeToHold(lease) {
|
|
133
250
|
this.hold = true;
|
|
134
251
|
clearTimeout(this.#timer);
|
|
135
|
-
|
|
136
|
-
|
|
252
|
+
// A granted cluster round may not be extended locally: peers bound the hold from the request
|
|
253
|
+
// they saw, and a longer local lease is exactly the two-holder window this protocol removes.
|
|
254
|
+
// Clamped on the monotonic deadline, not on expiresAt, so a backward wall-clock step cannot
|
|
255
|
+
// turn the upgrade into the extension this is here to refuse.
|
|
256
|
+
const now = node_perf_hooks_1.performance.now();
|
|
257
|
+
const extended = now + lease;
|
|
258
|
+
const deadline = this.clusterTsR === undefined ? extended : Math.min(extended, this.#deadlineMono ?? extended);
|
|
259
|
+
const remaining = deadline - now;
|
|
260
|
+
this.#deadlineMono = deadline;
|
|
261
|
+
this.expiresAt = Date.now() + remaining;
|
|
262
|
+
this.#timer = setTimeout(() => this.#onLeaseExpire(), remaining).unref();
|
|
263
|
+
// Prime the nextHolderVersion counter so a later CLOSED-path save (e.g. after the
|
|
264
|
+
// enclosing transaction commits) gets acquiredAt+MIN_STEP rather than acquiredAt again
|
|
265
|
+
// — the same priming the fresh-hold path performs. Without this, a post-commit save
|
|
266
|
+
// and any in-transaction save both get acquiredAt, causing a LWW tie that drops the write.
|
|
267
|
+
this.nextHolderVersion();
|
|
137
268
|
}
|
|
138
269
|
}
|
|
139
270
|
function makeKeyLockHandle(store, key, keyId, lease, hold = false, acquiredAt) {
|
|
@@ -146,7 +277,7 @@ function makeKeyLockHandle(store, key, keyId, lease, hold = false, acquiredAt) {
|
|
|
146
277
|
*/
|
|
147
278
|
async function acquireRecordKey(txn, store, key, keyId, waitMs, lease, hold = false) {
|
|
148
279
|
const existing = txn.recordLockFor(store, keyId);
|
|
149
|
-
if (existing && !existing.
|
|
280
|
+
if (existing && !existing.isExpired())
|
|
150
281
|
return existing;
|
|
151
282
|
const deadline = Date.now() + waitMs;
|
|
152
283
|
// One persistent wake slot: at most one onUnlocked callback is registered per waiter at any
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recordLock.js","sourceRoot":"","sources":["../../resources/recordLock.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"recordLock.js","sourceRoot":"","sources":["../../resources/recordLock.ts"],"names":[],"mappings":";;;;;;AA4HA,gDAeC;AAOD,4CAEC;AAGD,wCAEC;AAgND,8CASC;AAOD,4CAyCC;AAlaD,qDAA8C;AAC9C,2FAA+D;AAC/D,+DAA4D;AAE5D;;;;;;;;;;;;GAYG;AAEU,QAAA,qBAAqB,GAAG,MAAM,CAAC;AAC5C,+GAA+G;AAClG,QAAA,iBAAiB,GAAG,GAAG,CAAC;AACxB,QAAA,iBAAiB,GAAG,OAAO,CAAC;AAC5B,QAAA,uBAAuB,GAAG,MAAM,CAAC;AACjC,QAAA,mBAAmB,GAAG,OAAO,CAAC;AAC3C,MAAM,eAAe,GAAG,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;AA0FlD,SAAS,eAAe,CAAC,IAAY,EAAE,KAAc,EAAE,QAAgB,EAAE,GAAW,EAAE,GAAW;IAChG,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,QAAQ,CAAC;IACzC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,GAAG;QACtE,MAAM,IAAI,yBAAW,CACpB,eAAe,IAAI,iDAAiD,GAAG,kBAAkB,KAAK,EAAE,CAChG,CAAC;IACH,IAAI,KAAK,GAAG,GAAG;QAAE,MAAM,IAAI,yBAAW,CAAC,eAAe,IAAI,oBAAoB,GAAG,oBAAoB,KAAK,EAAE,CAAC,CAAC;IAC9G,OAAO,KAAK,CAAC;AACd,CAAC;AAED,SAAgB,kBAAkB,CAAC,OAA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