@dbos-inc/dbos-sdk 1.30.7-preview → 1.30.21-preview.g838bed7f8d
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/context.d.ts +2 -0
- package/dist/src/context.d.ts.map +1 -1
- package/dist/src/context.js +16 -1
- package/dist/src/context.js.map +1 -1
- package/dist/src/dbos-executor.d.ts +9 -8
- package/dist/src/dbos-executor.d.ts.map +1 -1
- package/dist/src/dbos-executor.js +323 -28
- package/dist/src/dbos-executor.js.map +1 -1
- package/dist/src/dbos.d.ts +2 -0
- package/dist/src/dbos.d.ts.map +1 -1
- package/dist/src/dbos.js +35 -1
- package/dist/src/dbos.js.map +1 -1
- package/dist/src/debugger/debug_workflow.d.ts +1 -1
- package/dist/src/debugger/debug_workflow.d.ts.map +1 -1
- package/dist/src/debugger/debug_workflow.js +2 -2
- package/dist/src/debugger/debug_workflow.js.map +1 -1
- package/dist/src/eventreceiver.d.ts +2 -0
- package/dist/src/eventreceiver.d.ts.map +1 -1
- package/dist/src/httpServer/handler.js.map +1 -1
- package/dist/src/procedure.d.ts +3 -3
- package/dist/src/procedure.d.ts.map +1 -1
- package/dist/src/procedure.js +3 -1
- package/dist/src/procedure.js.map +1 -1
- package/dist/src/testing/testing_runtime.js.map +1 -1
- package/dist/src/workflow.d.ts +1 -13
- package/dist/src/workflow.d.ts.map +1 -1
- package/dist/src/workflow.js +4 -322
- package/dist/src/workflow.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/src/context.d.ts
CHANGED
@@ -12,6 +12,7 @@ import { AsyncLocalStorage } from "async_hooks";
|
|
12
12
|
import { WorkflowContext, WorkflowContextImpl } from "./workflow";
|
13
13
|
import { TransactionContextImpl } from "./transaction";
|
14
14
|
import { StepContextImpl } from "./step";
|
15
|
+
import { StoredProcedureContextImpl } from "./procedure";
|
15
16
|
import { HandlerContextImpl } from "./httpServer/handler";
|
16
17
|
export interface DBOSLocalCtx {
|
17
18
|
ctx?: DBOSContext;
|
@@ -42,6 +43,7 @@ export declare function runWithDBOSContext<R>(ctx: DBOSContext, callback: () =>
|
|
42
43
|
export declare function runWithHandlerContext<R>(ctx: HandlerContextImpl, callback: () => Promise<R>): Promise<R>;
|
43
44
|
export declare function runWithTopContext<R>(ctx: DBOSLocalCtx, callback: () => Promise<R>): Promise<R>;
|
44
45
|
export declare function runWithTransactionContext<Client extends UserDatabaseClient, R>(ctx: TransactionContextImpl<Client>, callback: () => Promise<R>): Promise<R>;
|
46
|
+
export declare function runWithStoredProcContext<R>(ctx: StoredProcedureContextImpl, callback: () => Promise<R>): Promise<R>;
|
45
47
|
export declare function runWithStepContext<R>(ctx: StepContextImpl, callback: () => Promise<R>): Promise<R>;
|
46
48
|
export declare function runWithWorkflowContext<R>(ctx: WorkflowContext, callback: () => Promise<R>): Promise<R>;
|
47
49
|
export interface HTTPRequest {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/context.ts"],"names":[],"mappings":";;;;AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AACrD,OAAO,EAAE,YAAY,IAAI,MAAM,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEhF,OAAO,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAgB,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAClE,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;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AAED;;GAEG;AACH,qBAAa,WAAW;IAOV,QAAQ,CAAC,QAAQ,EAAE,YAAY;IAN3C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAGxB,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,WAAW,CAAC,CAAS;gBAER,QAAQ,EAAE,YAAY;IAM3C,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;IAKjC,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAK/B,WAAW,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC;IAI/D,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IACxC,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,GAAG,CAAC;CAS9C"}
|
package/dist/src/context.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.InitContext = exports.DBOSContextImpl = exports.runWithWorkflowContext = exports.runWithStepContext = exports.runWithTransactionContext = exports.runWithTopContext = exports.runWithHandlerContext = exports.runWithDBOSContext = exports.getNextWFID = exports.assertCurrentWorkflowContext = exports.assertCurrentDBOSContext = exports.getCurrentDBOSContext = exports.getCurrentContextStore = exports.asyncLocalCtx = void 0;
|
3
|
+
exports.InitContext = exports.DBOSContextImpl = exports.runWithWorkflowContext = exports.runWithStepContext = exports.runWithStoredProcContext = exports.runWithTransactionContext = exports.runWithTopContext = exports.runWithHandlerContext = exports.runWithDBOSContext = exports.getNextWFID = exports.assertCurrentWorkflowContext = exports.assertCurrentDBOSContext = exports.getCurrentDBOSContext = exports.getCurrentContextStore = exports.asyncLocalCtx = void 0;
|
4
4
|
const logs_1 = require("./telemetry/logs");
|
5
5
|
const lodash_1 = require("lodash");
|
6
6
|
const error_1 = require("./error");
|
@@ -112,6 +112,21 @@ async function runWithTransactionContext(ctx, callback) {
|
|
112
112
|
}, callback);
|
113
113
|
}
|
114
114
|
exports.runWithTransactionContext = runWithTransactionContext;
|
115
|
+
async function runWithStoredProcContext(ctx, callback) {
|
116
|
+
// Check we are in a workflow context and not in a step / transaction already
|
117
|
+
const pctx = getCurrentContextStore();
|
118
|
+
if (!pctx)
|
119
|
+
throw new error_2.DBOSInvalidWorkflowTransitionError();
|
120
|
+
if (!isInWorkflowCtx(pctx))
|
121
|
+
throw new error_2.DBOSInvalidWorkflowTransitionError();
|
122
|
+
return await exports.asyncLocalCtx.run({
|
123
|
+
ctx,
|
124
|
+
workflowId: ctx.workflowUUID,
|
125
|
+
curTxFunctionId: ctx.functionID,
|
126
|
+
parentCtx: pctx,
|
127
|
+
}, callback);
|
128
|
+
}
|
129
|
+
exports.runWithStoredProcContext = runWithStoredProcContext;
|
115
130
|
async function runWithStepContext(ctx, callback) {
|
116
131
|
// Check we are in a workflow context and not in a step / transaction already
|
117
132
|
const pctx = getCurrentContextStore();
|
package/dist/src/context.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/context.ts"],"names":[],"mappings":";;;AACA,2CAAgF;AAChF,mCAA6B;AAK7B,mCAAyE;AACzE,6CAAgD;AAIhD,mCAA6D;
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/context.ts"],"names":[],"mappings":";;;AACA,2CAAgF;AAChF,mCAA6B;AAK7B,mCAAyE;AACzE,6CAAgD;AAIhD,mCAA6D;AAwB7D,SAAS,mBAAmB,CAAC,GAAiB;IAC5C,IAAI,GAAG,CAAC,UAAU,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IAC/C,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,WAAW,CAAC,GAAiB;IACpC,IAAI,GAAG,CAAC,UAAU,KAAK,SAAS;QAAE,OAAO,KAAK,CAA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,CAAC,CAAC;QACrJ,OAAO,IAAI,CAAC,YAAY,CAAC,UAAU,EAAE,CAAC;IACxC,CAAC;IAED,WAAW,CAAI,GAAW,EAAE,GAAG,MAAiB;QAC9C,OAAO,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,CAAC;IACjD,CAAC;IAID,SAAS,CAAI,GAAW,EAAE,YAAgB;QACxC,MAAM,KAAK,GAAG,IAAA,YAAG,EAAC,IAAI,CAAC,WAAW,EAAE,GAAG,EAAE,YAAY,CAAC,CAAC;QACvD,sGAAsG;QACtG,IAAI,KAAK,IAAI,YAAY,IAAI,OAAO,KAAK,KAAK,OAAO,YAAY,EAAE,CAAC;YAClE,MAAM,IAAI,8BAAsB,CAAC,GAAG,EAAE,OAAO,YAAY,EAAE,OAAO,KAAK,CAAC,CAAC;QAC3E,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AArCD,kCAqCC"}
|
@@ -6,9 +6,9 @@ import { TelemetryCollector } from './telemetry/collector';
|
|
6
6
|
import { Tracer } from './telemetry/traces';
|
7
7
|
import { GlobalLogger as Logger } from './telemetry/logs';
|
8
8
|
import { TelemetryConfig } from './telemetry';
|
9
|
-
import { Pool, PoolClient, PoolConfig
|
9
|
+
import { Pool, PoolClient, PoolConfig } from 'pg';
|
10
10
|
import { SystemDatabase } from './system_database';
|
11
|
-
import { UserDatabase, UserDatabaseName } from './user_database';
|
11
|
+
import { UserDatabase, UserDatabaseName, UserDatabaseClient } from './user_database';
|
12
12
|
import { MethodRegistrationBase, ConfiguredInstance } from './decorators';
|
13
13
|
import { StoredProcedure, StoredProcedureConfig } from './procedure';
|
14
14
|
import { DBOSEventReceiver, DBOSExecutorContext, GetWorkflowsInput, GetWorkflowsOutput } from ".";
|
@@ -49,7 +49,7 @@ interface StepRegInfo {
|
|
49
49
|
registration: MethodRegistrationBase;
|
50
50
|
}
|
51
51
|
interface ProcedureRegInfo {
|
52
|
-
procedure: StoredProcedure<unknown>;
|
52
|
+
procedure: StoredProcedure<unknown[], unknown>;
|
53
53
|
config: StoredProcedureConfig;
|
54
54
|
registration: MethodRegistrationBase;
|
55
55
|
}
|
@@ -106,7 +106,6 @@ export declare class DBOSExecutor implements DBOSExecutorContext {
|
|
106
106
|
methodReg: MethodRegistrationBase;
|
107
107
|
}[];
|
108
108
|
init(classes?: object[]): Promise<void>;
|
109
|
-
callProcedure<R extends QueryResultRow = any>(proc: StoredProcedure<unknown>, args: unknown[]): Promise<R[]>;
|
110
109
|
destroy(): Promise<void>;
|
111
110
|
getWorkflowInfo(wf: Workflow<unknown[], unknown>): WorkflowRegInfo | undefined;
|
112
111
|
getWorkflowInfoByStatus(wf: WorkflowStatus): {
|
@@ -123,18 +122,20 @@ export declare class DBOSExecutor implements DBOSExecutorContext {
|
|
123
122
|
commInfo: StepRegInfo | undefined;
|
124
123
|
clsInst: ConfiguredInstance | null;
|
125
124
|
};
|
126
|
-
getProcedureClassName(pf: StoredProcedure<
|
127
|
-
getProcedureInfo(pf: StoredProcedure<
|
125
|
+
getProcedureClassName<T extends unknown[], R>(pf: StoredProcedure<T, R>): string;
|
126
|
+
getProcedureInfo<T extends unknown[], R>(pf: StoredProcedure<T, R>): ProcedureRegInfo | undefined;
|
128
127
|
workflow<T extends unknown[], R>(wf: Workflow<T, R>, params: InternalWorkflowParams, ...args: T): Promise<WorkflowHandle<R>>;
|
129
128
|
internalWorkflow<T extends unknown[], R>(wf: Workflow<T, R>, params: InternalWorkflowParams, callerUUID?: string, callerFunctionID?: number, ...args: T): Promise<WorkflowHandle<R>>;
|
130
129
|
/**
|
131
130
|
* DEBUG MODE workflow execution, skipping all the recording
|
132
131
|
*/
|
133
132
|
debugWorkflow<T extends unknown[], R>(wf: Workflow<T, R>, params: WorkflowParams, callerUUID?: string, callerFunctionID?: number, ...args: T): Promise<WorkflowHandle<R>>;
|
133
|
+
flushResultBuffer(client: UserDatabaseClient, resultBuffer: Map<number, BufferedResult>, workflowUUID: string): Promise<void>;
|
134
134
|
transaction<T extends unknown[], R>(txn: Transaction<T, R>, params: WorkflowParams, ...args: T): Promise<R>;
|
135
135
|
callTransactionFunction<T extends unknown[], R>(txn: Transaction<T, R>, clsinst: ConfiguredInstance | null, wfCtx: WorkflowContextImpl, ...args: T): Promise<R>;
|
136
|
-
procedure<R>(proc: StoredProcedure<R>, params: WorkflowParams, ...args:
|
137
|
-
|
136
|
+
procedure<T extends unknown[], R>(proc: StoredProcedure<T, R>, params: WorkflowParams, ...args: T): Promise<R>;
|
137
|
+
callProcedureFunction<T extends unknown[], R>(proc: StoredProcedure<T, R>, wfCtx: WorkflowContextImpl, ...args: T): Promise<R>;
|
138
|
+
invokeStoredProcFunction<R>(func: (client: PoolClient) => Promise<R>, config: TransactionConfig): Promise<R>;
|
138
139
|
external<T extends unknown[], R>(stepFn: StepFunction<T, R>, params: WorkflowParams, ...args: T): Promise<R>;
|
139
140
|
/**
|
140
141
|
* Execute a step function.
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"dbos-executor.d.ts","sourceRoot":"","sources":["../../src/dbos-executor.ts"],"names":[],"mappings":";AAGA,OAAO,EAEL,QAAQ,EACR,cAAc,EAEd,cAAc,EACd,cAAc,EAEd,mBAAmB,EACnB,cAAc,EAEd,cAAc,EAEd,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,UAA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,OAAO,CAAC,EAAE,CAAC;IAuB9F,wBAAwB;IAUxB,mBAAmB,CAAC,YAAY,EAAE,MAAM,EAAE,gBAAgB,GAAE,OAAe,GAAG,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;IAmF9G,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;IAyB9F;;OAEG;IACG,oBAAoB;IAQpB,yBAAyB,IAAI,OAAO,CAAC,IAAI,CAAC;IAiDhD,qBAAqB;IAcrB,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,SAAS;CAQ3D"}
|
@@ -24,6 +24,7 @@ const debug_workflow_1 = require("./debugger/debug_workflow");
|
|
24
24
|
const serialize_error_1 = require("serialize-error");
|
25
25
|
const utils_1 = require("./utils");
|
26
26
|
const node_path_1 = __importDefault(require("node:path"));
|
27
|
+
const procedure_1 = require("./procedure");
|
27
28
|
const lodash_1 = require("lodash");
|
28
29
|
const wfqueue_1 = require("./wfqueue");
|
29
30
|
const debugpoint_1 = require("./debugpoint");
|
@@ -352,24 +353,6 @@ class DBOSExecutor {
|
|
352
353
|
this.logger.error(`Unknown notice severity: ${msg.severity} - ${msg.message}`);
|
353
354
|
}
|
354
355
|
}
|
355
|
-
async callProcedure(proc, args) {
|
356
|
-
const client = await this.procedurePool.connect();
|
357
|
-
const log = (msg) => this.#logNotice(msg);
|
358
|
-
const procClassName = this.getProcedureClassName(proc);
|
359
|
-
const plainProcName = `${procClassName}_${proc.name}_p`;
|
360
|
-
const procName = this.config.appVersion
|
361
|
-
? `v${this.config.appVersion}_${plainProcName}`
|
362
|
-
: plainProcName;
|
363
|
-
const sql = `CALL "${procName}"(${args.map((_v, i) => `$${i + 1}`).join()});`;
|
364
|
-
try {
|
365
|
-
client.on('notice', log);
|
366
|
-
return await client.query(sql, args).then(value => value.rows);
|
367
|
-
}
|
368
|
-
finally {
|
369
|
-
client.off('notice', log);
|
370
|
-
client.release();
|
371
|
-
}
|
372
|
-
}
|
373
356
|
async destroy() {
|
374
357
|
if (this.pendingWorkflowMap.size > 0) {
|
375
358
|
this.logger.info("Waiting for pending workflows to finish.");
|
@@ -711,6 +694,128 @@ class DBOSExecutor {
|
|
711
694
|
});
|
712
695
|
return new workflow_1.InvokedHandle(this.systemDatabase, workflowPromise, workflowUUID, wf.name, callerUUID, callerFunctionID);
|
713
696
|
}
|
697
|
+
/**
|
698
|
+
* Retrieve the transaction snapshot information of the current transaction
|
699
|
+
*/
|
700
|
+
static async #retrieveSnapshot(query) {
|
701
|
+
const rows = await query("SELECT pg_current_snapshot()::text as txn_snapshot;", []);
|
702
|
+
return rows[0].txn_snapshot;
|
703
|
+
}
|
704
|
+
/**
|
705
|
+
* Check if an operation has already executed in a workflow.
|
706
|
+
* If it previously executed successfully, return its output.
|
707
|
+
* If it previously executed and threw an error, throw that error.
|
708
|
+
* Otherwise, return DBOSNull.
|
709
|
+
* Also return the transaction snapshot information of this current transaction.
|
710
|
+
*/
|
711
|
+
async #checkExecution(query, workflowUUID, funcID) {
|
712
|
+
// Note: we read the current snapshot, not the recorded one!
|
713
|
+
const rows = await query("(SELECT output, error, txn_snapshot, true as recorded FROM dbos.transaction_outputs WHERE workflow_uuid=$1 AND function_id=$2 UNION ALL SELECT null as output, null as error, pg_current_snapshot()::text as txn_snapshot, false as recorded) ORDER BY recorded", [workflowUUID, funcID]);
|
714
|
+
if (rows.length === 0 || rows.length > 2) {
|
715
|
+
this.logger.error("Unexpected! This should never happen. Returned rows: " + rows.toString());
|
716
|
+
throw new error_1.DBOSError("This should never happen. Returned rows: " + rows.toString());
|
717
|
+
}
|
718
|
+
const res = {
|
719
|
+
output: exports.dbosNull,
|
720
|
+
txn_snapshot: ""
|
721
|
+
};
|
722
|
+
// recorded=false row will be first because we used ORDER BY.
|
723
|
+
res.txn_snapshot = rows[0].txn_snapshot;
|
724
|
+
if (rows.length === 2) {
|
725
|
+
if (utils_1.DBOSJSON.parse(rows[1].error) !== null) {
|
726
|
+
throw (0, serialize_error_1.deserializeError)(utils_1.DBOSJSON.parse(rows[1].error));
|
727
|
+
}
|
728
|
+
else {
|
729
|
+
res.output = utils_1.DBOSJSON.parse(rows[1].output);
|
730
|
+
}
|
731
|
+
}
|
732
|
+
return res;
|
733
|
+
}
|
734
|
+
/**
|
735
|
+
* Write a operation's output to the database.
|
736
|
+
*/
|
737
|
+
static async #recordOutput(query, workflowUUID, funcID, txnSnapshot, output, isKeyConflict) {
|
738
|
+
try {
|
739
|
+
const serialOutput = utils_1.DBOSJSON.stringify(output);
|
740
|
+
const rows = await query("INSERT INTO dbos.transaction_outputs (workflow_uuid, function_id, output, txn_id, txn_snapshot, created_at) VALUES ($1, $2, $3, (select pg_current_xact_id_if_assigned()::text), $4, $5) RETURNING txn_id;", [workflowUUID, funcID, serialOutput, txnSnapshot, Date.now()]);
|
741
|
+
return rows[0].txn_id;
|
742
|
+
}
|
743
|
+
catch (error) {
|
744
|
+
if (isKeyConflict(error)) {
|
745
|
+
// Serialization and primary key conflict (Postgres).
|
746
|
+
throw new error_1.DBOSWorkflowConflictUUIDError(workflowUUID);
|
747
|
+
}
|
748
|
+
else {
|
749
|
+
throw error;
|
750
|
+
}
|
751
|
+
}
|
752
|
+
}
|
753
|
+
/**
|
754
|
+
* Record an error in an operation to the database.
|
755
|
+
*/
|
756
|
+
static async #recordError(query, workflowUUID, funcID, txnSnapshot, err, isKeyConflict) {
|
757
|
+
try {
|
758
|
+
const serialErr = utils_1.DBOSJSON.stringify((0, serialize_error_1.serializeError)(err));
|
759
|
+
await query("INSERT INTO dbos.transaction_outputs (workflow_uuid, function_id, error, txn_id, txn_snapshot, created_at) VALUES ($1, $2, $3, null, $4, $5) RETURNING txn_id;", [workflowUUID, funcID, serialErr, txnSnapshot, Date.now()]);
|
760
|
+
}
|
761
|
+
catch (error) {
|
762
|
+
if (isKeyConflict(error)) {
|
763
|
+
// Serialization and primary key conflict (Postgres).
|
764
|
+
throw new error_1.DBOSWorkflowConflictUUIDError(workflowUUID);
|
765
|
+
}
|
766
|
+
else {
|
767
|
+
throw error;
|
768
|
+
}
|
769
|
+
}
|
770
|
+
}
|
771
|
+
/**
|
772
|
+
* Write all entries in the workflow result buffer to the database.
|
773
|
+
* If it encounters a primary key error, this indicates a concurrent execution with the same UUID, so throw an DBOSError.
|
774
|
+
*/
|
775
|
+
async #flushResultBuffer(query, resultBuffer, workflowUUID, isKeyConflict) {
|
776
|
+
const funcIDs = Array.from(resultBuffer.keys());
|
777
|
+
if (funcIDs.length === 0) {
|
778
|
+
return;
|
779
|
+
}
|
780
|
+
funcIDs.sort();
|
781
|
+
try {
|
782
|
+
let sqlStmt = "INSERT INTO dbos.transaction_outputs (workflow_uuid, function_id, output, error, txn_id, txn_snapshot, created_at) VALUES ";
|
783
|
+
let paramCnt = 1;
|
784
|
+
const values = [];
|
785
|
+
for (const funcID of funcIDs) {
|
786
|
+
// Capture output and also transaction snapshot information.
|
787
|
+
// Initially, no txn_id because no queries executed.
|
788
|
+
const recorded = resultBuffer.get(funcID);
|
789
|
+
const output = recorded.output;
|
790
|
+
const txnSnapshot = recorded.txn_snapshot;
|
791
|
+
const createdAt = recorded.created_at;
|
792
|
+
if (paramCnt > 1) {
|
793
|
+
sqlStmt += ", ";
|
794
|
+
}
|
795
|
+
sqlStmt += `($${paramCnt++}, $${paramCnt++}, $${paramCnt++}, $${paramCnt++}, null, $${paramCnt++}, $${paramCnt++})`;
|
796
|
+
values.push(workflowUUID, funcID, utils_1.DBOSJSON.stringify(output), utils_1.DBOSJSON.stringify(null), txnSnapshot, createdAt);
|
797
|
+
}
|
798
|
+
this.logger.debug(sqlStmt);
|
799
|
+
await query(sqlStmt, values);
|
800
|
+
}
|
801
|
+
catch (error) {
|
802
|
+
if (isKeyConflict(error)) {
|
803
|
+
// Serialization and primary key conflict (Postgres).
|
804
|
+
throw new error_1.DBOSWorkflowConflictUUIDError(workflowUUID);
|
805
|
+
}
|
806
|
+
else {
|
807
|
+
throw error;
|
808
|
+
}
|
809
|
+
}
|
810
|
+
}
|
811
|
+
flushResultBuffer(client, resultBuffer, workflowUUID) {
|
812
|
+
const func = (sql, args) => this.userDatabase.queryWithClient(client, sql, ...args);
|
813
|
+
return this.#flushResultBuffer(func, resultBuffer, workflowUUID, (error) => this.userDatabase.isKeyConflictError(error));
|
814
|
+
}
|
815
|
+
#flushResultBufferProc(client, resultBuffer, workflowUUID) {
|
816
|
+
const func = (sql, args) => client.query(sql, args).then(v => v.rows);
|
817
|
+
return this.#flushResultBuffer(func, resultBuffer, workflowUUID, user_database_1.pgNodeIsKeyConflictError);
|
818
|
+
}
|
714
819
|
async transaction(txn, params, ...args) {
|
715
820
|
// Create a workflow and call transaction.
|
716
821
|
const temp_workflow = async (ctxt, ...args) => {
|
@@ -751,7 +856,8 @@ class DBOSExecutor {
|
|
751
856
|
// If the UUID is preset, it is possible this execution previously happened. Check, and return its original result if it did.
|
752
857
|
// Note: It is possible to retrieve a generated ID from a workflow handle, run a concurrent execution, and cause trouble for yourself. We recommend against this.
|
753
858
|
if (wfCtx.presetUUID) {
|
754
|
-
const
|
859
|
+
const func = (sql, args) => this.userDatabase.queryWithClient(client, sql, ...args);
|
860
|
+
const check = await this.#checkExecution(func, workflowUUID, funcId);
|
755
861
|
txn_snapshot = check.txn_snapshot;
|
756
862
|
if (check.output !== exports.dbosNull) {
|
757
863
|
tCtxt.span.setAttribute("cached", true);
|
@@ -762,11 +868,12 @@ class DBOSExecutor {
|
|
762
868
|
}
|
763
869
|
else {
|
764
870
|
// Collect snapshot information for read-only transactions and non-preset UUID transactions, if not already collected above
|
765
|
-
|
871
|
+
const func = (sql, args) => this.userDatabase.queryWithClient(client, sql, ...args);
|
872
|
+
txn_snapshot = await DBOSExecutor.#retrieveSnapshot(func);
|
766
873
|
}
|
767
874
|
// For non-read-only transactions, flush the result buffer.
|
768
875
|
if (!readOnly) {
|
769
|
-
await
|
876
|
+
await this.flushResultBuffer(client, wfCtx.resultBuffer, wfCtx.workflowUUID);
|
770
877
|
}
|
771
878
|
// Execute the user's transaction.
|
772
879
|
let cresult;
|
@@ -795,7 +902,8 @@ class DBOSExecutor {
|
|
795
902
|
else {
|
796
903
|
try {
|
797
904
|
// Synchronously record the output of write transactions and obtain the transaction ID.
|
798
|
-
const
|
905
|
+
const func = (sql, args) => this.userDatabase.queryWithClient(client, sql, ...args);
|
906
|
+
const pg_txn_id = await DBOSExecutor.#recordOutput(func, wfCtx.workflowUUID, funcId, txn_snapshot, result, (error) => this.userDatabase.isKeyConflictError(error));
|
799
907
|
tCtxt.span.setAttribute("pg_txn_id", pg_txn_id);
|
800
908
|
wfCtx.resultBuffer.clear();
|
801
909
|
}
|
@@ -830,8 +938,9 @@ class DBOSExecutor {
|
|
830
938
|
// Record and throw other errors.
|
831
939
|
const e = err;
|
832
940
|
await this.userDatabase.transaction(async (client) => {
|
833
|
-
await
|
834
|
-
|
941
|
+
await this.flushResultBuffer(client, wfCtx.resultBuffer, wfCtx.workflowUUID);
|
942
|
+
const func = (sql, args) => this.userDatabase.queryWithClient(client, sql, ...args);
|
943
|
+
await DBOSExecutor.#recordError(func, wfCtx.workflowUUID, funcId, txn_snapshot, e, (error) => this.userDatabase.isKeyConflictError(error));
|
835
944
|
}, { isolationLevel: transaction_1.IsolationLevel.ReadCommitted });
|
836
945
|
wfCtx.resultBuffer.clear();
|
837
946
|
span.setStatus({ code: api_1.SpanStatusCode.ERROR, message: e.message });
|
@@ -844,15 +953,201 @@ class DBOSExecutor {
|
|
844
953
|
// Create a workflow and call procedure.
|
845
954
|
const temp_workflow = async (ctxt, ...args) => {
|
846
955
|
const ctxtImpl = ctxt;
|
847
|
-
return
|
956
|
+
return this.callProcedureFunction(proc, ctxtImpl, ...args);
|
848
957
|
};
|
849
|
-
return (await this.workflow(temp_workflow, {
|
958
|
+
return await (await this.workflow(temp_workflow, {
|
959
|
+
...params,
|
850
960
|
tempWfType: TempWorkflowType.procedure,
|
851
961
|
tempWfName: (0, decorators_1.getRegisteredMethodName)(proc),
|
852
962
|
tempWfClass: (0, decorators_1.getRegisteredMethodClassName)(proc),
|
853
963
|
}, ...args)).getResult();
|
854
964
|
}
|
855
|
-
async
|
965
|
+
async callProcedureFunction(proc, wfCtx, ...args) {
|
966
|
+
const procInfo = this.getProcedureInfo(proc);
|
967
|
+
if (procInfo === undefined) {
|
968
|
+
throw new error_1.DBOSNotRegisteredError(proc.name);
|
969
|
+
}
|
970
|
+
const executeLocally = procInfo.config.executeLocally ?? false;
|
971
|
+
const funcId = wfCtx.functionIDGetIncrement();
|
972
|
+
const span = this.tracer.startSpan(proc.name, {
|
973
|
+
operationUUID: wfCtx.workflowUUID,
|
974
|
+
operationType: exports.OperationType.PROCEDURE,
|
975
|
+
authenticatedUser: wfCtx.authenticatedUser,
|
976
|
+
assumedRole: wfCtx.assumedRole,
|
977
|
+
authenticatedRoles: wfCtx.authenticatedRoles,
|
978
|
+
readOnly: procInfo.config.readOnly ?? false,
|
979
|
+
isolationLevel: procInfo.config.isolationLevel,
|
980
|
+
executeLocally,
|
981
|
+
}, wfCtx.span);
|
982
|
+
try {
|
983
|
+
const result = executeLocally
|
984
|
+
? await this.#callProcedureFunctionLocal(proc, args, wfCtx, span, procInfo.config, funcId)
|
985
|
+
: await this.#callProcedureFunctionRemote(proc, args, wfCtx, span, procInfo.config, funcId);
|
986
|
+
span.setStatus({ code: api_1.SpanStatusCode.OK });
|
987
|
+
return result;
|
988
|
+
}
|
989
|
+
catch (e) {
|
990
|
+
const { message } = e;
|
991
|
+
span.setStatus({ code: api_1.SpanStatusCode.ERROR, message });
|
992
|
+
throw e;
|
993
|
+
}
|
994
|
+
finally {
|
995
|
+
this.tracer.endSpan(span);
|
996
|
+
}
|
997
|
+
}
|
998
|
+
async #callProcedureFunctionLocal(proc, args, wfCtx, span, config, funcId) {
|
999
|
+
let retryWaitMillis = 1;
|
1000
|
+
const backoffFactor = 1.5;
|
1001
|
+
const maxRetryWaitMs = 2000; // Maximum wait 2 seconds.
|
1002
|
+
const readOnly = config.readOnly ?? false;
|
1003
|
+
while (true) {
|
1004
|
+
let txn_snapshot = "invalid";
|
1005
|
+
const wrappedProcedure = async (client) => {
|
1006
|
+
const ctxt = new procedure_1.StoredProcedureContextImpl(client, wfCtx, span, this.logger, funcId, proc.name);
|
1007
|
+
if (wfCtx.presetUUID) {
|
1008
|
+
const func = (sql, args) => this.procedurePool.query(sql, args).then(v => v.rows);
|
1009
|
+
const check = await this.#checkExecution(func, wfCtx.workflowUUID, funcId);
|
1010
|
+
txn_snapshot = check.txn_snapshot;
|
1011
|
+
if (check.output !== exports.dbosNull) {
|
1012
|
+
ctxt.span.setAttribute("cached", true);
|
1013
|
+
ctxt.span.setStatus({ code: api_1.SpanStatusCode.OK });
|
1014
|
+
this.tracer.endSpan(ctxt.span);
|
1015
|
+
return check.output;
|
1016
|
+
}
|
1017
|
+
}
|
1018
|
+
else {
|
1019
|
+
// Collect snapshot information for read-only transactions and non-preset UUID transactions, if not already collected above
|
1020
|
+
const func = (sql, args) => this.procedurePool.query(sql, args).then(v => v.rows);
|
1021
|
+
txn_snapshot = await DBOSExecutor.#retrieveSnapshot(func);
|
1022
|
+
}
|
1023
|
+
// For non-read-only transactions, flush the result buffer.
|
1024
|
+
if (!readOnly) {
|
1025
|
+
await this.#flushResultBufferProc(client, wfCtx.resultBuffer, wfCtx.workflowUUID);
|
1026
|
+
}
|
1027
|
+
let cresult;
|
1028
|
+
await (0, context_1.runWithStoredProcContext)(ctxt, async () => {
|
1029
|
+
cresult = await proc(ctxt, ...args);
|
1030
|
+
});
|
1031
|
+
const result = cresult;
|
1032
|
+
if (readOnly) {
|
1033
|
+
// Buffer the output of read-only transactions instead of synchronously writing it.
|
1034
|
+
const readOutput = {
|
1035
|
+
output: result,
|
1036
|
+
txn_snapshot: txn_snapshot,
|
1037
|
+
created_at: Date.now(),
|
1038
|
+
};
|
1039
|
+
wfCtx.resultBuffer.set(funcId, readOutput);
|
1040
|
+
}
|
1041
|
+
else {
|
1042
|
+
// Synchronously record the output of write transactions and obtain the transaction ID.
|
1043
|
+
const func = (sql, args) => client.query(sql, args).then(v => v.rows);
|
1044
|
+
const pg_txn_id = await DBOSExecutor.#recordOutput(func, wfCtx.workflowUUID, funcId, txn_snapshot, result, user_database_1.pgNodeIsKeyConflictError);
|
1045
|
+
// const pg_txn_id = await wfCtx.recordOutputProc<R>(client, funcId, txn_snapshot, result);
|
1046
|
+
ctxt.span.setAttribute("pg_txn_id", pg_txn_id);
|
1047
|
+
wfCtx.resultBuffer.clear();
|
1048
|
+
}
|
1049
|
+
return result;
|
1050
|
+
};
|
1051
|
+
try {
|
1052
|
+
const result = await this.invokeStoredProcFunction(wrappedProcedure, { isolationLevel: config.isolationLevel });
|
1053
|
+
span.setStatus({ code: api_1.SpanStatusCode.OK });
|
1054
|
+
return result;
|
1055
|
+
}
|
1056
|
+
catch (err) {
|
1057
|
+
if (this.userDatabase.isRetriableTransactionError(err)) {
|
1058
|
+
// serialization_failure in PostgreSQL
|
1059
|
+
span.addEvent("TXN SERIALIZATION FAILURE", { "retryWaitMillis": retryWaitMillis }, performance.now());
|
1060
|
+
// Retry serialization failures.
|
1061
|
+
await (0, utils_1.sleepms)(retryWaitMillis);
|
1062
|
+
retryWaitMillis *= backoffFactor;
|
1063
|
+
retryWaitMillis = retryWaitMillis < maxRetryWaitMs ? retryWaitMillis : maxRetryWaitMs;
|
1064
|
+
continue;
|
1065
|
+
}
|
1066
|
+
// Record and throw other errors.
|
1067
|
+
const e = err;
|
1068
|
+
await this.invokeStoredProcFunction(async (client) => {
|
1069
|
+
await this.#flushResultBufferProc(client, wfCtx.resultBuffer, wfCtx.workflowUUID);
|
1070
|
+
const func = (sql, args) => client.query(sql, args).then(v => v.rows);
|
1071
|
+
await DBOSExecutor.#recordError(func, wfCtx.workflowUUID, funcId, txn_snapshot, e, user_database_1.pgNodeIsKeyConflictError);
|
1072
|
+
}, { isolationLevel: transaction_1.IsolationLevel.ReadCommitted });
|
1073
|
+
await this.userDatabase.transaction(async (client) => {
|
1074
|
+
this.flushResultBuffer(client, wfCtx.resultBuffer, wfCtx.workflowUUID);
|
1075
|
+
const func = (sql, args) => this.userDatabase.queryWithClient(client, sql, ...args);
|
1076
|
+
await DBOSExecutor.#recordError(func, wfCtx.workflowUUID, funcId, txn_snapshot, e, (error) => this.userDatabase.isKeyConflictError(error));
|
1077
|
+
}, { isolationLevel: transaction_1.IsolationLevel.ReadCommitted });
|
1078
|
+
wfCtx.resultBuffer.clear();
|
1079
|
+
throw err;
|
1080
|
+
}
|
1081
|
+
}
|
1082
|
+
}
|
1083
|
+
async #callProcedureFunctionRemote(proc, args, wfCtx, span, config, funcId) {
|
1084
|
+
const readOnly = config.readOnly ?? false;
|
1085
|
+
const $jsonCtx = {
|
1086
|
+
request: wfCtx.request,
|
1087
|
+
authenticatedUser: wfCtx.authenticatedUser,
|
1088
|
+
authenticatedRoles: wfCtx.authenticatedRoles,
|
1089
|
+
assumedRole: wfCtx.assumedRole,
|
1090
|
+
};
|
1091
|
+
// Note, node-pg converts JS arrays to postgres array literals, so must call JSON.strigify on
|
1092
|
+
// args and bufferedResults before being passed to #invokeStoredProc
|
1093
|
+
const $args = [wfCtx.workflowUUID, funcId, wfCtx.presetUUID, $jsonCtx, null, JSON.stringify(args)];
|
1094
|
+
if (!readOnly) {
|
1095
|
+
// function_id, output, txn_snapshot, created_at
|
1096
|
+
const bufferedResults = new Array();
|
1097
|
+
for (const [functionID, { output, txn_snapshot, created_at }] of wfCtx.resultBuffer.entries()) {
|
1098
|
+
bufferedResults.push([functionID, output, txn_snapshot, created_at]);
|
1099
|
+
}
|
1100
|
+
// sort by function ID
|
1101
|
+
bufferedResults.sort((a, b) => a[0] - b[0]);
|
1102
|
+
$args.unshift(bufferedResults.length > 0 ? JSON.stringify(bufferedResults) : null);
|
1103
|
+
}
|
1104
|
+
const [{ return_value }] = await this.#invokeStoredProc(proc, $args);
|
1105
|
+
const { error, output, txn_snapshot, txn_id, created_at } = return_value;
|
1106
|
+
// buffered results are persisted in r/w stored procs, even if it returns an error
|
1107
|
+
if (!readOnly) {
|
1108
|
+
wfCtx.resultBuffer.clear();
|
1109
|
+
}
|
1110
|
+
// if the stored proc returns an error, deserialize and throw it.
|
1111
|
+
// stored proc saves the error in tx_output before returning
|
1112
|
+
if (error) {
|
1113
|
+
throw (0, serialize_error_1.deserializeError)(error);
|
1114
|
+
}
|
1115
|
+
// if txn_snapshot is provided, the output needs to be buffered
|
1116
|
+
if (readOnly && txn_snapshot) {
|
1117
|
+
wfCtx.resultBuffer.set(funcId, {
|
1118
|
+
output,
|
1119
|
+
txn_snapshot,
|
1120
|
+
created_at: created_at ?? Date.now(),
|
1121
|
+
});
|
1122
|
+
}
|
1123
|
+
if (!readOnly) {
|
1124
|
+
wfCtx.resultBuffer.clear();
|
1125
|
+
}
|
1126
|
+
if (txn_id) {
|
1127
|
+
span.setAttribute("pg_txn_id", txn_id);
|
1128
|
+
}
|
1129
|
+
span.setStatus({ code: api_1.SpanStatusCode.OK });
|
1130
|
+
return output;
|
1131
|
+
}
|
1132
|
+
async #invokeStoredProc(proc, args) {
|
1133
|
+
const client = await this.procedurePool.connect();
|
1134
|
+
const log = (msg) => this.#logNotice(msg);
|
1135
|
+
const procClassName = this.getProcedureClassName(proc);
|
1136
|
+
const plainProcName = `${procClassName}_${proc.name}_p`;
|
1137
|
+
const procName = this.config.appVersion
|
1138
|
+
? `v${this.config.appVersion}_${plainProcName}`
|
1139
|
+
: plainProcName;
|
1140
|
+
const sql = `CALL "${procName}"(${args.map((_v, i) => `$${i + 1}`).join()});`;
|
1141
|
+
try {
|
1142
|
+
client.on('notice', log);
|
1143
|
+
return await client.query(sql, args).then(value => value.rows);
|
1144
|
+
}
|
1145
|
+
finally {
|
1146
|
+
client.off('notice', log);
|
1147
|
+
client.release();
|
1148
|
+
}
|
1149
|
+
}
|
1150
|
+
async invokeStoredProcFunction(func, config) {
|
856
1151
|
const client = await this.procedurePool.connect();
|
857
1152
|
try {
|
858
1153
|
const readOnly = config.readOnly ?? false;
|
@@ -911,7 +1206,7 @@ class DBOSExecutor {
|
|
911
1206
|
}, wfCtx.span);
|
912
1207
|
const ctxt = new step_1.StepContextImpl(wfCtx, funcID, span, this.logger, commInfo.config, stepFn.name);
|
913
1208
|
await this.userDatabase.transaction(async (client) => {
|
914
|
-
await
|
1209
|
+
await this.flushResultBuffer(client, wfCtx.resultBuffer, wfCtx.workflowUUID);
|
915
1210
|
}, { isolationLevel: transaction_1.IsolationLevel.ReadCommitted });
|
916
1211
|
wfCtx.resultBuffer.clear();
|
917
1212
|
// Check if this execution previously happened, returning its original result if it did.
|