@dbos-inc/dbos-sdk 2.8.2-preview → 2.8.6-preview
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/dist/src/dbos-executor.d.ts +2 -13
- package/dist/src/dbos-executor.d.ts.map +1 -1
- package/dist/src/dbos-executor.js +47 -263
- package/dist/src/dbos-executor.js.map +1 -1
- package/dist/src/dbos.js +6 -6
- package/dist/src/dbos.js.map +1 -1
- package/dist/src/decorators.d.ts +21 -0
- package/dist/src/decorators.d.ts.map +1 -1
- package/dist/src/decorators.js +21 -0
- package/dist/src/decorators.js.map +1 -1
- package/dist/src/error.d.ts +4 -0
- package/dist/src/error.d.ts.map +1 -1
- package/dist/src/error.js +4 -1
- package/dist/src/error.js.map +1 -1
- package/dist/src/eventreceiver.d.ts +107 -4
- package/dist/src/eventreceiver.d.ts.map +1 -1
- package/dist/src/httpServer/server.d.ts +1 -0
- package/dist/src/httpServer/server.d.ts.map +1 -1
- package/dist/src/httpServer/server.js +5 -0
- package/dist/src/httpServer/server.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/procedure.d.ts +4 -0
- package/dist/src/procedure.d.ts.map +1 -1
- package/dist/src/procedure.js.map +1 -1
- package/dist/src/scheduler/scheduler.d.ts +22 -0
- package/dist/src/scheduler/scheduler.d.ts.map +1 -1
- package/dist/src/scheduler/scheduler.js +23 -1
- package/dist/src/scheduler/scheduler.js.map +1 -1
- package/dist/src/step.d.ts +8 -0
- package/dist/src/step.d.ts.map +1 -1
- package/dist/src/step.js.map +1 -1
- package/dist/src/system_database.d.ts +3 -15
- package/dist/src/system_database.d.ts.map +1 -1
- package/dist/src/system_database.js +38 -115
- package/dist/src/system_database.js.map +1 -1
- package/dist/src/transaction.d.ts +8 -0
- package/dist/src/transaction.d.ts.map +1 -1
- package/dist/src/transaction.js +1 -0
- package/dist/src/transaction.js.map +1 -1
- package/dist/src/user_database.d.ts.map +1 -1
- package/dist/src/user_database.js +2 -6
- package/dist/src/user_database.js.map +1 -1
- package/dist/src/wfqueue.d.ts +26 -5
- package/dist/src/wfqueue.d.ts.map +1 -1
- package/dist/src/wfqueue.js +6 -0
- package/dist/src/wfqueue.js.map +1 -1
- package/dist/src/workflow.d.ts +13 -6
- package/dist/src/workflow.d.ts.map +1 -1
- package/dist/src/workflow.js +7 -14
- package/dist/src/workflow.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
import { Workflow, WorkflowConfig, WorkflowHandle, WorkflowParams, WorkflowContextImpl, WorkflowStatus, BufferedResult, GetWorkflowQueueInput, GetWorkflowQueueOutput } from './workflow';
|
1
|
+
import { Workflow, WorkflowConfig, WorkflowHandle, WorkflowParams, WorkflowContextImpl, WorkflowStatus, GetWorkflowQueueInput, GetWorkflowQueueOutput } from './workflow';
|
3
2
|
import { Transaction, TransactionConfig } from './transaction';
|
4
3
|
import { StepConfig, StepFunction } from './step';
|
5
4
|
import { TelemetryCollector } from './telemetry/collector';
|
@@ -8,7 +7,7 @@ import { GlobalLogger as Logger } from './telemetry/logs';
|
|
8
7
|
import { TelemetryConfig } from './telemetry';
|
9
8
|
import { Pool, PoolClient, PoolConfig } from 'pg';
|
10
9
|
import { SystemDatabase } from './system_database';
|
11
|
-
import { UserDatabase, UserDatabaseName
|
10
|
+
import { UserDatabase, UserDatabaseName } from './user_database';
|
12
11
|
import { MethodRegistrationBase, ConfiguredInstance } from './decorators';
|
13
12
|
import { step_info } from '../schemas/system_db_schema';
|
14
13
|
import { StoredProcedure, StoredProcedureConfig } from './procedure';
|
@@ -109,12 +108,8 @@ export declare class DBOSExecutor implements DBOSExecutorContext {
|
|
109
108
|
readonly procedureInfoMap: Map<string, ProcedureRegInfo>;
|
110
109
|
readonly registeredOperations: Array<MethodRegistrationBase>;
|
111
110
|
readonly pendingWorkflowMap: Map<string, Promise<unknown>>;
|
112
|
-
readonly workflowResultBuffer: Map<string, Map<number, BufferedResult>>;
|
113
111
|
readonly workflowCancellationMap: Map<string, boolean>;
|
114
112
|
readonly telemetryCollector: TelemetryCollector;
|
115
|
-
readonly flushBufferIntervalMs: number;
|
116
|
-
readonly flushBufferID: NodeJS.Timeout;
|
117
|
-
isFlushingBuffers: boolean;
|
118
113
|
static readonly defaultNotificationTimeoutSec = 60;
|
119
114
|
readonly debugMode: DebugMode;
|
120
115
|
get isDebugging(): boolean;
|
@@ -158,7 +153,6 @@ export declare class DBOSExecutor implements DBOSExecutorContext {
|
|
158
153
|
getProcedureInfo<T extends unknown[], R>(pf: StoredProcedure<T, R>): ProcedureRegInfo | undefined;
|
159
154
|
workflow<T extends unknown[], R>(wf: Workflow<T, R>, params: InternalWorkflowParams, ...args: T): Promise<WorkflowHandle<R>>;
|
160
155
|
internalWorkflow<T extends unknown[], R>(wf: Workflow<T, R>, params: InternalWorkflowParams, callerUUID?: string, callerFunctionID?: number, ...args: T): Promise<WorkflowHandle<R>>;
|
161
|
-
flushResultBuffer(client: UserDatabaseClient, resultBuffer: Map<number, BufferedResult>, workflowUUID: string): Promise<void>;
|
162
156
|
transaction<T extends unknown[], R>(txn: Transaction<T, R>, params: WorkflowParams, ...args: T): Promise<R>;
|
163
157
|
startTransactionTempWF<T extends unknown[], R>(txn: Transaction<T, R>, params: InternalWorkflowParams, callerUUID?: string, callerFunctionID?: number, ...args: T): Promise<WorkflowHandle<R>>;
|
164
158
|
callTransactionFunction<T extends unknown[], R>(txn: Transaction<T, R>, clsinst: ConfiguredInstance | null, wfCtx: WorkflowContextImpl, ...args: T): Promise<R>;
|
@@ -201,11 +195,6 @@ export declare class DBOSExecutor implements DBOSExecutorContext {
|
|
201
195
|
cancelWorkflow(workflowID: string): Promise<void>;
|
202
196
|
listWorkflowSteps(workflowID: string): Promise<step_info[]>;
|
203
197
|
resumeWorkflow(workflowID: string): Promise<WorkflowHandle<unknown>>;
|
204
|
-
/**
|
205
|
-
* Periodically flush the workflow output buffer to the system database.
|
206
|
-
*/
|
207
|
-
flushWorkflowBuffers(): Promise<void>;
|
208
|
-
flushWorkflowResultBuffer(): Promise<void>;
|
209
198
|
logRegisteredHTTPUrls(): void;
|
210
199
|
getConfig<T>(key: string, defaultValue?: T): T | undefined;
|
211
200
|
/**
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"dbos-executor.d.ts","sourceRoot":"","sources":["../../src/dbos-executor.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"dbos-executor.d.ts","sourceRoot":"","sources":["../../src/dbos-executor.ts"],"names":[],"mappings":"AAaA,OAAO,EAEL,QAAQ,EACR,cAAc,EAEd,cAAc,EACd,cAAc,EAEd,mBAAmB,EACnB,cAAc,EAGd,qBAAqB,EACrB,sBAAsB,EACvB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAkB,WAAW,EAAE,iBAAiB,EAA0B,MAAM,eAAe,CAAC;AACvG,OAAO,EAAE,UAAU,EAAmB,YAAY,EAAE,MAAM,QAAQ,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,YAAY,IAAI,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1D,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,EAAkB,MAAM,IAAI,CAAC;AAClE,OAAO,EAAE,cAAc,EAAkD,MAAM,mBAAmB,CAAC;AAEnG,OAAO,EAGL,YAAY,EAEZ,gBAAgB,EAMjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,sBAAsB,EAOtB,kBAAkB,EAEnB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAcxD,OAAO,EAAE,eAAe,E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AE,CAAC;IAwC9F,kBAAkB;IAYlB,wBAAwB;IA0BxB,mBAAmB,CAAC,YAAY,EAAE,MAAM,EAAE,gBAAgB,GAAE,OAAe,GAAG,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;IA+G9G,qBAAqB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,GAAG,SAAS,CAAC;IAGzG,uBAAuB,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,sBAAsB,EAAE,CAAC;IAGzF,wBAAwB,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAexF,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAMjD,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IAI3D,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;IAQ1E,qBAAqB;IAcrB,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,SAAS;IAS1D;;;;;;OAMG;IACH,iBAAiB,IAAI,MAAM;CAU5B"}
|
@@ -114,12 +114,8 @@ class DBOSExecutor {
|
|
114
114
|
procedureInfoMap = new Map();
|
115
115
|
registeredOperations = [];
|
116
116
|
pendingWorkflowMap = new Map(); // Map from workflowUUID to workflow promise
|
117
|
-
workflowResultBuffer = new Map(); // Map from workflowUUID to its remaining result buffer.
|
118
117
|
workflowCancellationMap = new Map(); // Map from workflowUUID to its cancellation status.
|
119
118
|
telemetryCollector;
|
120
|
-
flushBufferIntervalMs = 1000;
|
121
|
-
flushBufferID;
|
122
|
-
isFlushingBuffers = false;
|
123
119
|
static defaultNotificationTimeoutSec = 60;
|
124
120
|
debugMode;
|
125
121
|
get isDebugging() {
|
@@ -184,13 +180,6 @@ class DBOSExecutor {
|
|
184
180
|
this.logger.debug('Using Postgres system database');
|
185
181
|
this.systemDatabase = new system_database_1.PostgresSystemDatabase(this.config.poolConfig, this.config.system_database, this.logger, this.config.sysDbPoolSize);
|
186
182
|
}
|
187
|
-
this.flushBufferID = setInterval(() => {
|
188
|
-
if (!this.isDebugging && !this.isFlushingBuffers) {
|
189
|
-
this.isFlushingBuffers = true;
|
190
|
-
void this.flushWorkflowBuffers();
|
191
|
-
}
|
192
|
-
}, this.flushBufferIntervalMs);
|
193
|
-
this.logger.debug('Started workflow status buffer worker');
|
194
183
|
this.initialized = false;
|
195
184
|
DBOSExecutor.globalInstance = this;
|
196
185
|
}
|
@@ -434,15 +423,6 @@ class DBOSExecutor {
|
|
434
423
|
this.logger.info('Waiting for pending workflows to finish.');
|
435
424
|
await Promise.allSettled(this.pendingWorkflowMap.values());
|
436
425
|
}
|
437
|
-
clearInterval(this.flushBufferID);
|
438
|
-
if (!this.isDebugging && !this.isFlushingBuffers) {
|
439
|
-
// Don't flush the buffers if we're already flushing them in the background.
|
440
|
-
await this.flushWorkflowBuffers();
|
441
|
-
}
|
442
|
-
while (this.isFlushingBuffers) {
|
443
|
-
this.logger.info('Waiting for result buffers to be exported.');
|
444
|
-
await (0, utils_1.sleepms)(1000);
|
445
|
-
}
|
446
426
|
await this.systemDatabase.destroy();
|
447
427
|
if (this.userDatabase) {
|
448
428
|
await this.userDatabase.destroy();
|
@@ -600,39 +580,35 @@ class DBOSExecutor {
|
|
600
580
|
internalStatus.workflowClassName = params.tempWfClass ?? '';
|
601
581
|
}
|
602
582
|
let status = undefined;
|
603
|
-
// Synchronously set the workflow's status to PENDING and record workflow inputs
|
583
|
+
// Synchronously set the workflow's status to PENDING and record workflow inputs.
|
604
584
|
// We have to do it for all types of workflows because operation_outputs table has a foreign key constraint on workflow status table.
|
605
|
-
if (
|
606
|
-
|
607
|
-
|
608
|
-
if (
|
609
|
-
|
610
|
-
const wfInputs = await this.systemDatabase.getWorkflowInputs(workflowUUID);
|
611
|
-
if (!wfStatus || !wfInputs) {
|
612
|
-
throw new error_1.DBOSDebuggerError(`Failed to find inputs for workflow UUID ${workflowUUID}`);
|
613
|
-
}
|
614
|
-
// Make sure we use the same input.
|
615
|
-
if (utils_1.DBOSJSON.stringify(args) !== utils_1.DBOSJSON.stringify(wfInputs)) {
|
616
|
-
throw new error_1.DBOSDebuggerError(`Detected different inputs for workflow UUID ${workflowUUID}.\n Received: ${utils_1.DBOSJSON.stringify(args)}\n Original: ${utils_1.DBOSJSON.stringify(wfInputs)}`);
|
617
|
-
}
|
618
|
-
status = wfStatus.status;
|
585
|
+
if (this.isDebugging) {
|
586
|
+
const wfStatus = await this.systemDatabase.getWorkflowStatus(workflowUUID);
|
587
|
+
const wfInputs = await this.systemDatabase.getWorkflowInputs(workflowUUID);
|
588
|
+
if (!wfStatus || !wfInputs) {
|
589
|
+
throw new error_1.DBOSDebuggerError(`Failed to find inputs for workflow UUID ${workflowUUID}`);
|
619
590
|
}
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
591
|
+
// Make sure we use the same input.
|
592
|
+
if (utils_1.DBOSJSON.stringify(args) !== utils_1.DBOSJSON.stringify(wfInputs)) {
|
593
|
+
throw new error_1.DBOSDebuggerError(`Detected different inputs for workflow UUID ${workflowUUID}.\n Received: ${utils_1.DBOSJSON.stringify(args)}\n Original: ${utils_1.DBOSJSON.stringify(wfInputs)}`);
|
594
|
+
}
|
595
|
+
status = wfStatus.status;
|
596
|
+
}
|
597
|
+
else {
|
598
|
+
// TODO: Make this transactional (and with the queue step below)
|
599
|
+
if (callerFunctionID !== undefined && callerUUID !== undefined) {
|
600
|
+
const child_id = await this.systemDatabase.checkChildWorkflow(callerUUID, callerFunctionID);
|
601
|
+
if (child_id !== null) {
|
602
|
+
return new workflow_1.RetrievedHandle(this.systemDatabase, child_id, callerUUID, callerFunctionID);
|
631
603
|
}
|
632
|
-
args = ires.args;
|
633
|
-
status = ires.status;
|
634
|
-
await (0, debugpoint_1.debugTriggerPoint)(debugpoint_1.DEBUG_TRIGGER_WORKFLOW_ENQUEUE);
|
635
604
|
}
|
605
|
+
const ires = await this.systemDatabase.initWorkflowStatus(internalStatus, args);
|
606
|
+
if (callerFunctionID !== undefined && callerUUID !== undefined) {
|
607
|
+
await this.systemDatabase.recordChildWorkflow(callerUUID, workflowUUID, callerFunctionID, internalStatus.workflowName);
|
608
|
+
}
|
609
|
+
args = ires.args;
|
610
|
+
status = ires.status;
|
611
|
+
await (0, debugpoint_1.debugTriggerPoint)(debugpoint_1.DEBUG_TRIGGER_WORKFLOW_ENQUEUE);
|
636
612
|
}
|
637
613
|
const runWorkflow = async () => {
|
638
614
|
let result;
|
@@ -669,7 +645,7 @@ class DBOSExecutor {
|
|
669
645
|
await this.systemDatabase.dequeueWorkflow(workflowUUID, this.#getQueueByName(internalStatus.queueName));
|
670
646
|
}
|
671
647
|
if (!this.isDebugging) {
|
672
|
-
this.systemDatabase.
|
648
|
+
await this.systemDatabase.recordWorkflowOutput(workflowUUID, internalStatus);
|
673
649
|
}
|
674
650
|
wCtxt.span.setStatus({ code: api_1.SpanStatusCode.OK });
|
675
651
|
}
|
@@ -714,18 +690,6 @@ class DBOSExecutor {
|
|
714
690
|
}
|
715
691
|
finally {
|
716
692
|
this.tracer.endSpan(wCtxt.span);
|
717
|
-
if (wCtxt.tempWfOperationType === exports.TempWorkflowType.transaction ||
|
718
|
-
wCtxt.tempWfOperationType === exports.TempWorkflowType.procedure) {
|
719
|
-
// For single-transaction workflows, asynchronously record inputs.
|
720
|
-
// We must buffer inputs after workflow status is buffered/flushed because workflow_inputs table has a foreign key reference to the workflow_status table.
|
721
|
-
if (!this.isDebugging) {
|
722
|
-
this.systemDatabase.bufferWorkflowInputs(workflowUUID, args);
|
723
|
-
}
|
724
|
-
}
|
725
|
-
}
|
726
|
-
// Asynchronously flush the result buffer.
|
727
|
-
if (wCtxt.resultBuffer.size > 0) {
|
728
|
-
this.workflowResultBuffer.set(wCtxt.workflowUUID, wCtxt.resultBuffer);
|
729
693
|
}
|
730
694
|
return result;
|
731
695
|
};
|
@@ -837,57 +801,6 @@ class DBOSExecutor {
|
|
837
801
|
}
|
838
802
|
}
|
839
803
|
}
|
840
|
-
/**
|
841
|
-
* Write all entries in the workflow result buffer to the database.
|
842
|
-
* If it encounters a primary key error, this indicates a concurrent execution with the same UUID, so throw an DBOSError.
|
843
|
-
*/
|
844
|
-
async #flushResultBuffer(query, resultBuffer, workflowUUID, isKeyConflict) {
|
845
|
-
const funcIDs = Array.from(resultBuffer.keys());
|
846
|
-
if (funcIDs.length === 0) {
|
847
|
-
return;
|
848
|
-
}
|
849
|
-
if (this.isDebugging) {
|
850
|
-
throw new error_1.DBOSDebuggerError('Cannot flush result buffer in debug mode.');
|
851
|
-
}
|
852
|
-
funcIDs.sort();
|
853
|
-
try {
|
854
|
-
let sqlStmt = 'INSERT INTO dbos.transaction_outputs (workflow_uuid, function_id, output, error, txn_id, txn_snapshot, created_at) VALUES ';
|
855
|
-
let paramCnt = 1;
|
856
|
-
const values = [];
|
857
|
-
for (const funcID of funcIDs) {
|
858
|
-
// Capture output and also transaction snapshot information.
|
859
|
-
// Initially, no txn_id because no queries executed.
|
860
|
-
const recorded = resultBuffer.get(funcID);
|
861
|
-
const output = recorded.output;
|
862
|
-
const txnSnapshot = recorded.txn_snapshot;
|
863
|
-
const createdAt = recorded.created_at;
|
864
|
-
if (paramCnt > 1) {
|
865
|
-
sqlStmt += ', ';
|
866
|
-
}
|
867
|
-
sqlStmt += `($${paramCnt++}, $${paramCnt++}, $${paramCnt++}, $${paramCnt++}, null, $${paramCnt++}, $${paramCnt++})`;
|
868
|
-
values.push(workflowUUID, funcID, utils_1.DBOSJSON.stringify(output), utils_1.DBOSJSON.stringify(null), txnSnapshot, createdAt);
|
869
|
-
}
|
870
|
-
this.logger.debug(sqlStmt);
|
871
|
-
await query(sqlStmt, values);
|
872
|
-
}
|
873
|
-
catch (error) {
|
874
|
-
if (isKeyConflict(error)) {
|
875
|
-
// Serialization and primary key conflict (Postgres).
|
876
|
-
throw new error_1.DBOSWorkflowConflictUUIDError(workflowUUID);
|
877
|
-
}
|
878
|
-
else {
|
879
|
-
throw error;
|
880
|
-
}
|
881
|
-
}
|
882
|
-
}
|
883
|
-
flushResultBuffer(client, resultBuffer, workflowUUID) {
|
884
|
-
const func = (sql, args) => this.userDatabase.queryWithClient(client, sql, ...args);
|
885
|
-
return this.#flushResultBuffer(func, resultBuffer, workflowUUID, (error) => this.userDatabase.isKeyConflictError(error));
|
886
|
-
}
|
887
|
-
#flushResultBufferProc(client, resultBuffer, workflowUUID) {
|
888
|
-
const func = (sql, args) => client.query(sql, args).then((v) => v.rows);
|
889
|
-
return this.#flushResultBuffer(func, resultBuffer, workflowUUID, user_database_1.pgNodeIsKeyConflictError);
|
890
|
-
}
|
891
804
|
async transaction(txn, params, ...args) {
|
892
805
|
return await (await this.startTransactionTempWF(txn, params, undefined, undefined, ...args)).getResult();
|
893
806
|
}
|
@@ -912,7 +825,6 @@ class DBOSExecutor {
|
|
912
825
|
if (this.workflowCancellationMap.get(wfCtx.workflowUUID) === true) {
|
913
826
|
throw new error_1.DBOSWorkflowCancelledError(wfCtx.workflowUUID);
|
914
827
|
}
|
915
|
-
const readOnly = txnInfo.config.readOnly ?? false;
|
916
828
|
let retryWaitMillis = 1;
|
917
829
|
const backoffFactor = 1.5;
|
918
830
|
const maxRetryWaitMs = 2000; // Maximum wait 2 seconds.
|
@@ -923,7 +835,6 @@ class DBOSExecutor {
|
|
923
835
|
authenticatedUser: wfCtx.authenticatedUser,
|
924
836
|
assumedRole: wfCtx.assumedRole,
|
925
837
|
authenticatedRoles: wfCtx.authenticatedRoles,
|
926
|
-
readOnly: readOnly,
|
927
838
|
isolationLevel: txnInfo.config.isolationLevel,
|
928
839
|
}, wfCtx.span);
|
929
840
|
while (true) {
|
@@ -966,10 +877,6 @@ class DBOSExecutor {
|
|
966
877
|
if (this.isDebugging && prevResult === exports.dbosNull) {
|
967
878
|
throw new error_1.DBOSDebuggerError(`Failed to find the recorded output for the transaction: workflow UUID ${workflowUUID}, step number ${funcId}`);
|
968
879
|
}
|
969
|
-
// For non-read-only transactions, flush the result buffer.
|
970
|
-
if (!this.isDebugging && !readOnly) {
|
971
|
-
await this.flushResultBuffer(client, wfCtx.resultBuffer, wfCtx.workflowUUID);
|
972
|
-
}
|
973
880
|
// Execute the user's transaction.
|
974
881
|
const result = await (async function () {
|
975
882
|
try {
|
@@ -1002,30 +909,18 @@ class DBOSExecutor {
|
|
1002
909
|
throw result;
|
1003
910
|
}
|
1004
911
|
// Record the execution, commit, and return.
|
1005
|
-
|
1006
|
-
//
|
1007
|
-
const
|
1008
|
-
|
1009
|
-
txn_snapshot: txn_snapshot,
|
1010
|
-
created_at: Date.now(),
|
1011
|
-
};
|
1012
|
-
wfCtx.resultBuffer.set(funcId, readOutput);
|
912
|
+
try {
|
913
|
+
// Synchronously record the output of write transactions and obtain the transaction ID.
|
914
|
+
const pg_txn_id = await this.#recordOutput(queryFunc, wfCtx.workflowUUID, funcId, txn_snapshot, result, (error) => this.userDatabase.isKeyConflictError(error));
|
915
|
+
tCtxt.span.setAttribute('pg_txn_id', pg_txn_id);
|
1013
916
|
}
|
1014
|
-
|
1015
|
-
|
1016
|
-
|
1017
|
-
|
1018
|
-
tCtxt.span.setAttribute('pg_txn_id', pg_txn_id);
|
1019
|
-
wfCtx.resultBuffer.clear();
|
917
|
+
catch (error) {
|
918
|
+
if (this.userDatabase.isFailedSqlTransactionError(error)) {
|
919
|
+
this.logger.error(`Postgres aborted the ${txn.name} @DBOS.transaction of Workflow ${workflowUUID}, but the function did not raise an exception. Please ensure that the @DBOS.transaction method raises an exception if the database transaction is aborted.`);
|
920
|
+
throw new error_1.DBOSFailedSqlTransactionError(workflowUUID, txn.name);
|
1020
921
|
}
|
1021
|
-
|
1022
|
-
|
1023
|
-
this.logger.error(`Postgres aborted the ${txn.name} @Transaction of Workflow ${workflowUUID}, but the function did not raise an exception. Please ensure that the @Transaction method raises an exception if the database transaction is aborted.`);
|
1024
|
-
throw new error_1.DBOSFailedSqlTransactionError(workflowUUID, txn.name);
|
1025
|
-
}
|
1026
|
-
else {
|
1027
|
-
throw error;
|
1028
|
-
}
|
922
|
+
else {
|
923
|
+
throw error;
|
1029
924
|
}
|
1030
925
|
}
|
1031
926
|
return result;
|
@@ -1051,11 +946,9 @@ class DBOSExecutor {
|
|
1051
946
|
// Record and throw other errors.
|
1052
947
|
const e = err;
|
1053
948
|
await this.userDatabase.transaction(async (client) => {
|
1054
|
-
await this.flushResultBuffer(client, wfCtx.resultBuffer, wfCtx.workflowUUID);
|
1055
949
|
const func = (sql, args) => this.userDatabase.queryWithClient(client, sql, ...args);
|
1056
950
|
await this.#recordError(func, wfCtx.workflowUUID, funcId, txn_snapshot, e, (error) => this.userDatabase.isKeyConflictError(error));
|
1057
951
|
}, { isolationLevel: transaction_1.IsolationLevel.ReadCommitted });
|
1058
|
-
wfCtx.resultBuffer.clear();
|
1059
952
|
}
|
1060
953
|
span.setStatus({ code: api_1.SpanStatusCode.ERROR, message: e.message });
|
1061
954
|
this.tracer.endSpan(span);
|
@@ -1092,7 +985,6 @@ class DBOSExecutor {
|
|
1092
985
|
authenticatedUser: wfCtx.authenticatedUser,
|
1093
986
|
assumedRole: wfCtx.assumedRole,
|
1094
987
|
authenticatedRoles: wfCtx.authenticatedRoles,
|
1095
|
-
readOnly: procInfo.config.readOnly ?? false,
|
1096
988
|
isolationLevel: procInfo.config.isolationLevel,
|
1097
989
|
executeLocally,
|
1098
990
|
}, wfCtx.span);
|
@@ -1116,7 +1008,6 @@ class DBOSExecutor {
|
|
1116
1008
|
let retryWaitMillis = 1;
|
1117
1009
|
const backoffFactor = 1.5;
|
1118
1010
|
const maxRetryWaitMs = 2000; // Maximum wait 2 seconds.
|
1119
|
-
const readOnly = procInfo.config.readOnly ?? false;
|
1120
1011
|
while (true) {
|
1121
1012
|
if (this.workflowCancellationMap.get(wfCtx.workflowUUID) === true) {
|
1122
1013
|
throw new error_1.DBOSWorkflowCancelledError(wfCtx.workflowUUID);
|
@@ -1154,10 +1045,6 @@ class DBOSExecutor {
|
|
1154
1045
|
if (this.isDebugging && prevResult === exports.dbosNull) {
|
1155
1046
|
throw new error_1.DBOSDebuggerError(`Failed to find the recorded output for the procedure: workflow UUID ${wfCtx.workflowUUID}, step number ${funcId}`);
|
1156
1047
|
}
|
1157
|
-
// For non-read-only transactions, flush the result buffer.
|
1158
|
-
if (!this.isDebugging && !readOnly) {
|
1159
|
-
await this.#flushResultBufferProc(client, wfCtx.resultBuffer, wfCtx.workflowUUID);
|
1160
|
-
}
|
1161
1048
|
// Execute the user's transaction.
|
1162
1049
|
const result = await (async function () {
|
1163
1050
|
try {
|
@@ -1189,23 +1076,11 @@ class DBOSExecutor {
|
|
1189
1076
|
if (result instanceof Error) {
|
1190
1077
|
throw result;
|
1191
1078
|
}
|
1192
|
-
|
1193
|
-
|
1194
|
-
|
1195
|
-
|
1196
|
-
|
1197
|
-
created_at: Date.now(),
|
1198
|
-
};
|
1199
|
-
wfCtx.resultBuffer.set(funcId, readOutput);
|
1200
|
-
}
|
1201
|
-
else {
|
1202
|
-
// Synchronously record the output of write transactions and obtain the transaction ID.
|
1203
|
-
const func = (sql, args) => client.query(sql, args).then((v) => v.rows);
|
1204
|
-
const pg_txn_id = await this.#recordOutput(func, wfCtx.workflowUUID, funcId, txn_snapshot, result, user_database_1.pgNodeIsKeyConflictError);
|
1205
|
-
// const pg_txn_id = await wfCtx.recordOutputProc<R>(client, funcId, txn_snapshot, result);
|
1206
|
-
ctxt.span.setAttribute('pg_txn_id', pg_txn_id);
|
1207
|
-
wfCtx.resultBuffer.clear();
|
1208
|
-
}
|
1079
|
+
// Synchronously record the output of write transactions and obtain the transaction ID.
|
1080
|
+
const func = (sql, args) => client.query(sql, args).then((v) => v.rows);
|
1081
|
+
const pg_txn_id = await this.#recordOutput(func, wfCtx.workflowUUID, funcId, txn_snapshot, result, user_database_1.pgNodeIsKeyConflictError);
|
1082
|
+
// const pg_txn_id = await wfCtx.recordOutputProc<R>(client, funcId, txn_snapshot, result);
|
1083
|
+
ctxt.span.setAttribute('pg_txn_id', pg_txn_id);
|
1209
1084
|
return result;
|
1210
1085
|
};
|
1211
1086
|
try {
|
@@ -1229,16 +1104,13 @@ class DBOSExecutor {
|
|
1229
1104
|
// Record and throw other errors.
|
1230
1105
|
const e = err;
|
1231
1106
|
await this.invokeStoredProcFunction(async (client) => {
|
1232
|
-
await this.#flushResultBufferProc(client, wfCtx.resultBuffer, wfCtx.workflowUUID);
|
1233
1107
|
const func = (sql, args) => client.query(sql, args).then((v) => v.rows);
|
1234
1108
|
await this.#recordError(func, wfCtx.workflowUUID, funcId, txn_snapshot, e, user_database_1.pgNodeIsKeyConflictError);
|
1235
1109
|
}, { isolationLevel: transaction_1.IsolationLevel.ReadCommitted });
|
1236
1110
|
await this.userDatabase.transaction(async (client) => {
|
1237
|
-
await this.flushResultBuffer(client, wfCtx.resultBuffer, wfCtx.workflowUUID);
|
1238
1111
|
const func = (sql, args) => this.userDatabase.queryWithClient(client, sql, ...args);
|
1239
1112
|
await this.#recordError(func, wfCtx.workflowUUID, funcId, txn_snapshot, e, (error) => this.userDatabase.isKeyConflictError(error));
|
1240
1113
|
}, { isolationLevel: transaction_1.IsolationLevel.ReadCommitted });
|
1241
|
-
wfCtx.resultBuffer.clear();
|
1242
1114
|
}
|
1243
1115
|
throw err;
|
1244
1116
|
}
|
@@ -1248,7 +1120,6 @@ class DBOSExecutor {
|
|
1248
1120
|
if (this.isDebugging) {
|
1249
1121
|
throw new error_1.DBOSDebuggerError("Can't invoke stored procedure in debug mode.");
|
1250
1122
|
}
|
1251
|
-
const readOnly = config.readOnly ?? false;
|
1252
1123
|
if (this.workflowCancellationMap.get(wfCtx.workflowUUID) === true) {
|
1253
1124
|
throw new error_1.DBOSWorkflowCancelledError(wfCtx.workflowUUID);
|
1254
1125
|
}
|
@@ -1258,41 +1129,21 @@ class DBOSExecutor {
|
|
1258
1129
|
authenticatedRoles: wfCtx.authenticatedRoles,
|
1259
1130
|
assumedRole: wfCtx.assumedRole,
|
1260
1131
|
};
|
1132
|
+
// TODO (Qian/Harry): remove this unshift when we remove the resultBuffer argument
|
1261
1133
|
// Note, node-pg converts JS arrays to postgres array literals, so must call JSON.strigify on
|
1262
1134
|
// args and bufferedResults before being passed to #invokeStoredProc
|
1263
1135
|
const $args = [wfCtx.workflowUUID, funcId, wfCtx.presetUUID, $jsonCtx, null, JSON.stringify(args)];
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1267
|
-
for (const [functionID, { output, txn_snapshot, created_at }] of wfCtx.resultBuffer.entries()) {
|
1268
|
-
bufferedResults.push([functionID, output, txn_snapshot, created_at]);
|
1269
|
-
}
|
1270
|
-
// sort by function ID
|
1271
|
-
bufferedResults.sort((a, b) => a[0] - b[0]);
|
1272
|
-
$args.unshift(bufferedResults.length > 0 ? JSON.stringify(bufferedResults) : null);
|
1136
|
+
const readonly = config.readOnly ?? false;
|
1137
|
+
if (!readonly) {
|
1138
|
+
$args.unshift(null);
|
1273
1139
|
}
|
1274
1140
|
const [{ return_value }] = await this.#invokeStoredProc(proc, $args);
|
1275
|
-
const { error, output,
|
1276
|
-
// buffered results are persisted in r/w stored procs, even if it returns an error
|
1277
|
-
if (!readOnly) {
|
1278
|
-
wfCtx.resultBuffer.clear();
|
1279
|
-
}
|
1141
|
+
const { error, output, txn_id } = return_value;
|
1280
1142
|
// if the stored proc returns an error, deserialize and throw it.
|
1281
1143
|
// stored proc saves the error in tx_output before returning
|
1282
1144
|
if (error) {
|
1283
1145
|
throw (0, serialize_error_1.deserializeError)(error);
|
1284
1146
|
}
|
1285
|
-
// if txn_snapshot is provided, the output needs to be buffered
|
1286
|
-
if (readOnly && txn_snapshot) {
|
1287
|
-
wfCtx.resultBuffer.set(funcId, {
|
1288
|
-
output,
|
1289
|
-
txn_snapshot,
|
1290
|
-
created_at: created_at ?? Date.now(),
|
1291
|
-
});
|
1292
|
-
}
|
1293
|
-
if (!readOnly) {
|
1294
|
-
wfCtx.resultBuffer.clear();
|
1295
|
-
}
|
1296
1147
|
if (txn_id) {
|
1297
1148
|
span.setAttribute('pg_txn_id', txn_id);
|
1298
1149
|
}
|
@@ -1379,10 +1230,6 @@ class DBOSExecutor {
|
|
1379
1230
|
backoffRate: commInfo.config.backoffRate,
|
1380
1231
|
}, wfCtx.span);
|
1381
1232
|
const ctxt = new step_1.StepContextImpl(wfCtx, funcID, span, this.logger, commInfo.config, stepFn.name);
|
1382
|
-
await this.userDatabase.transaction(async (client) => {
|
1383
|
-
await this.flushResultBuffer(client, wfCtx.resultBuffer, wfCtx.workflowUUID);
|
1384
|
-
}, { isolationLevel: transaction_1.IsolationLevel.ReadCommitted });
|
1385
|
-
wfCtx.resultBuffer.clear();
|
1386
1233
|
// Check if this execution previously happened, returning its original result if it did.
|
1387
1234
|
const check = await this.systemDatabase.checkOperationOutput(wfCtx.workflowUUID, ctxt.functionID);
|
1388
1235
|
if (check !== exports.dbosNull) {
|
@@ -1592,7 +1439,7 @@ class DBOSExecutor {
|
|
1592
1439
|
}
|
1593
1440
|
}
|
1594
1441
|
async deactivateEventReceivers() {
|
1595
|
-
this.logger.
|
1442
|
+
this.logger.debug('Deactivating event receivers');
|
1596
1443
|
for (const evtRcvr of this.eventReceivers || []) {
|
1597
1444
|
try {
|
1598
1445
|
await evtRcvr.destroy();
|
@@ -1732,69 +1579,6 @@ class DBOSExecutor {
|
|
1732
1579
|
return await this.executeWorkflowUUID(workflowID, false);
|
1733
1580
|
}
|
1734
1581
|
/* BACKGROUND PROCESSES */
|
1735
|
-
/**
|
1736
|
-
* Periodically flush the workflow output buffer to the system database.
|
1737
|
-
*/
|
1738
|
-
async flushWorkflowBuffers() {
|
1739
|
-
if (this.initialized && !this.isDebugging) {
|
1740
|
-
await this.flushWorkflowResultBuffer();
|
1741
|
-
await this.systemDatabase.flushWorkflowSystemBuffers();
|
1742
|
-
}
|
1743
|
-
this.isFlushingBuffers = false;
|
1744
|
-
}
|
1745
|
-
async flushWorkflowResultBuffer() {
|
1746
|
-
if (this.isDebugging) {
|
1747
|
-
throw new error_1.DBOSDebuggerError(`Cannot flush workflow result buffer in debug mode.`);
|
1748
|
-
}
|
1749
|
-
const localBuffer = new Map(this.workflowResultBuffer);
|
1750
|
-
this.workflowResultBuffer.clear();
|
1751
|
-
const totalSize = localBuffer.size;
|
1752
|
-
const flushBatchSize = 50;
|
1753
|
-
try {
|
1754
|
-
let finishedCnt = 0;
|
1755
|
-
while (finishedCnt < totalSize) {
|
1756
|
-
let sqlStmt = 'INSERT INTO dbos.transaction_outputs (workflow_uuid, function_id, output, error, txn_id, txn_snapshot, created_at) VALUES ';
|
1757
|
-
let paramCnt = 1;
|
1758
|
-
const values = [];
|
1759
|
-
const batchUUIDs = [];
|
1760
|
-
for (const [workflowUUID, wfBuffer] of localBuffer) {
|
1761
|
-
for (const [funcID, recorded] of wfBuffer) {
|
1762
|
-
const output = recorded.output;
|
1763
|
-
const txnSnapshot = recorded.txn_snapshot;
|
1764
|
-
const createdAt = recorded.created_at;
|
1765
|
-
if (paramCnt > 1) {
|
1766
|
-
sqlStmt += ', ';
|
1767
|
-
}
|
1768
|
-
sqlStmt += `($${paramCnt++}, $${paramCnt++}, $${paramCnt++}, $${paramCnt++}, null, $${paramCnt++}, $${paramCnt++})`;
|
1769
|
-
values.push(workflowUUID, funcID, utils_1.DBOSJSON.stringify(output), utils_1.DBOSJSON.stringify(null), txnSnapshot, createdAt);
|
1770
|
-
}
|
1771
|
-
batchUUIDs.push(workflowUUID);
|
1772
|
-
finishedCnt++;
|
1773
|
-
if (batchUUIDs.length >= flushBatchSize) {
|
1774
|
-
// Cap at the batch size.
|
1775
|
-
break;
|
1776
|
-
}
|
1777
|
-
}
|
1778
|
-
this.logger.debug(sqlStmt);
|
1779
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
1780
|
-
await this.userDatabase.query(sqlStmt, ...values);
|
1781
|
-
// Clean up after each batch succeeds
|
1782
|
-
batchUUIDs.forEach((value) => {
|
1783
|
-
localBuffer.delete(value);
|
1784
|
-
});
|
1785
|
-
}
|
1786
|
-
}
|
1787
|
-
catch (error) {
|
1788
|
-
error.message = `Error flushing workflow result buffer: ${error.message}`;
|
1789
|
-
this.logger.error(error);
|
1790
|
-
// If there is a failure in flushing the buffer, return items to the global buffer for retrying later.
|
1791
|
-
for (const [workflowUUID, wfBuffer] of localBuffer) {
|
1792
|
-
if (!this.workflowResultBuffer.has(workflowUUID)) {
|
1793
|
-
this.workflowResultBuffer.set(workflowUUID, wfBuffer);
|
1794
|
-
}
|
1795
|
-
}
|
1796
|
-
}
|
1797
|
-
}
|
1798
1582
|
logRegisteredHTTPUrls() {
|
1799
1583
|
this.logger.info('HTTP endpoints supported:');
|
1800
1584
|
this.registeredOperations.forEach((registeredOperation) => {
|