@dbos-inc/dbos-sdk 1.30.21-preview.g838bed7f8d → 1.31.5-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/context.d.ts +0 -2
- package/dist/src/context.d.ts.map +1 -1
- package/dist/src/context.js +3 -17
- package/dist/src/context.js.map +1 -1
- package/dist/src/dbos-executor.d.ts +8 -9
- package/dist/src/dbos-executor.d.ts.map +1 -1
- package/dist/src/dbos-executor.js +28 -323
- package/dist/src/dbos-executor.js.map +1 -1
- package/dist/src/dbos.d.ts +1 -2
- package/dist/src/dbos.d.ts.map +1 -1
- package/dist/src/dbos.js +40 -36
- 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 +0 -2
- package/dist/src/eventreceiver.d.ts.map +1 -1
- package/dist/src/httpServer/handler.js.map +1 -1
- package/dist/src/httpServer/server.js +1 -1
- package/dist/src/httpServer/server.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 +1 -3
- package/dist/src/procedure.js.map +1 -1
- package/dist/src/testing/testing_runtime.js.map +1 -1
- package/dist/src/workflow.d.ts +13 -1
- package/dist/src/workflow.d.ts.map +1 -1
- package/dist/src/workflow.js +322 -4
- 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,7 +12,6 @@ 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";
|
16
15
|
import { HandlerContextImpl } from "./httpServer/handler";
|
17
16
|
export interface DBOSLocalCtx {
|
18
17
|
ctx?: DBOSContext;
|
@@ -43,7 +42,6 @@ export declare function runWithDBOSContext<R>(ctx: DBOSContext, callback: () =>
|
|
43
42
|
export declare function runWithHandlerContext<R>(ctx: HandlerContextImpl, callback: () => Promise<R>): Promise<R>;
|
44
43
|
export declare function runWithTopContext<R>(ctx: DBOSLocalCtx, callback: () => Promise<R>): Promise<R>;
|
45
44
|
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>;
|
47
45
|
export declare function runWithStepContext<R>(ctx: StepContextImpl, callback: () => Promise<R>): Promise<R>;
|
48
46
|
export declare function runWithWorkflowContext<R>(ctx: WorkflowContext, callback: () => Promise<R>): Promise<R>;
|
49
47
|
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,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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.
|
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;
|
4
4
|
const logs_1 = require("./telemetry/logs");
|
5
5
|
const lodash_1 = require("lodash");
|
6
6
|
const error_1 = require("./error");
|
@@ -51,7 +51,8 @@ function assertCurrentDBOSContext() {
|
|
51
51
|
}
|
52
52
|
exports.assertCurrentDBOSContext = assertCurrentDBOSContext;
|
53
53
|
function assertCurrentWorkflowContext() {
|
54
|
-
|
54
|
+
const ctxs = getCurrentContextStore();
|
55
|
+
if (!ctxs || !isInWorkflowCtx(ctxs)) {
|
55
56
|
throw new error_2.DBOSInvalidWorkflowTransitionError();
|
56
57
|
}
|
57
58
|
const ctx = assertCurrentDBOSContext();
|
@@ -112,21 +113,6 @@ async function runWithTransactionContext(ctx, callback) {
|
|
112
113
|
}, callback);
|
113
114
|
}
|
114
115
|
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;
|
130
116
|
async function runWithStepContext(ctx, callback) {
|
131
117
|
// Check we are in a workflow context and not in a step / transaction already
|
132
118
|
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;AAuB7D,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,CAAC;IAC/C,IAAI,GAAG,CAAC,iBAAiB;QAAE,OAAO,IAAI,CAAC;IACvC,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,UAAU,CAAC,GAAiB;IACnC,IAAI,GAAG,CAAC,UAAU,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IAC/C,IAAI,GAAG,CAAC,eAAe;QAAE,OAAO,IAAI,CAAC;IACrC,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,eAAe,CAAC,GAAiB;IACxC,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC;QAAE,OAAO,KAAK,CAAC;IAC5C,IAAI,WAAW,CAAC,GAAG,CAAC;QAAE,OAAO,KAAK,CAAC;IACnC,IAAI,UAAU,CAAC,GAAG,CAAC;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I,CAAC,YAAY,GAAG,QAAQ,CAAC,YAAY,CAAC;QAC1C,IAAI,CAAC,WAAW,GAAG,QAAQ,CAAC,MAAM,CAAC,WAAW,CAAC;IACjD,CAAC;IAED,gBAAgB;QACd,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,kIAAkI,CAAC,CAAC;QACrJ,OAAO,IAAI,CAAC,YAAY,CAAC,YAAY,EAAE,CAAC;IAC1C,CAAC;IAED,cAAc;QACZ,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,kIAAkI,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 } from 'pg';
|
9
|
+
import { Pool, PoolClient, PoolConfig, QueryResultRow } from 'pg';
|
10
10
|
import { SystemDatabase } from './system_database';
|
11
|
-
import { UserDatabase, UserDatabaseName
|
11
|
+
import { UserDatabase, UserDatabaseName } 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>;
|
53
53
|
config: StoredProcedureConfig;
|
54
54
|
registration: MethodRegistrationBase;
|
55
55
|
}
|
@@ -106,6 +106,7 @@ 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[]>;
|
109
110
|
destroy(): Promise<void>;
|
110
111
|
getWorkflowInfo(wf: Workflow<unknown[], unknown>): WorkflowRegInfo | undefined;
|
111
112
|
getWorkflowInfoByStatus(wf: WorkflowStatus): {
|
@@ -122,20 +123,18 @@ export declare class DBOSExecutor implements DBOSExecutorContext {
|
|
122
123
|
commInfo: StepRegInfo | undefined;
|
123
124
|
clsInst: ConfiguredInstance | null;
|
124
125
|
};
|
125
|
-
getProcedureClassName
|
126
|
-
getProcedureInfo
|
126
|
+
getProcedureClassName(pf: StoredProcedure<unknown>): string;
|
127
|
+
getProcedureInfo(pf: StoredProcedure<unknown>): ProcedureRegInfo | undefined;
|
127
128
|
workflow<T extends unknown[], R>(wf: Workflow<T, R>, params: InternalWorkflowParams, ...args: T): Promise<WorkflowHandle<R>>;
|
128
129
|
internalWorkflow<T extends unknown[], R>(wf: Workflow<T, R>, params: InternalWorkflowParams, callerUUID?: string, callerFunctionID?: number, ...args: T): Promise<WorkflowHandle<R>>;
|
129
130
|
/**
|
130
131
|
* DEBUG MODE workflow execution, skipping all the recording
|
131
132
|
*/
|
132
133
|
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<
|
137
|
-
|
138
|
-
invokeStoredProcFunction<R>(func: (client: PoolClient) => Promise<R>, config: TransactionConfig): Promise<R>;
|
136
|
+
procedure<R>(proc: StoredProcedure<R>, params: WorkflowParams, ...args: unknown[]): Promise<R>;
|
137
|
+
executeProcedure<R>(func: (client: PoolClient) => Promise<R>, config: TransactionConfig): Promise<R>;
|
139
138
|
external<T extends unknown[], R>(stepFn: StepFunction<T, R>, params: WorkflowParams, ...args: T): Promise<R>;
|
140
139
|
/**
|
141
140
|
* 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;AAC3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AAqB,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,7 +24,6 @@ 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");
|
28
27
|
const lodash_1 = require("lodash");
|
29
28
|
const wfqueue_1 = require("./wfqueue");
|
30
29
|
const debugpoint_1 = require("./debugpoint");
|
@@ -353,6 +352,24 @@ class DBOSExecutor {
|
|
353
352
|
this.logger.error(`Unknown notice severity: ${msg.severity} - ${msg.message}`);
|
354
353
|
}
|
355
354
|
}
|
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
|
+
}
|
356
373
|
async destroy() {
|
357
374
|
if (this.pendingWorkflowMap.size > 0) {
|
358
375
|
this.logger.info("Waiting for pending workflows to finish.");
|
@@ -694,128 +711,6 @@ class DBOSExecutor {
|
|
694
711
|
});
|
695
712
|
return new workflow_1.InvokedHandle(this.systemDatabase, workflowPromise, workflowUUID, wf.name, callerUUID, callerFunctionID);
|
696
713
|
}
|
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
|
-
}
|
819
714
|
async transaction(txn, params, ...args) {
|
820
715
|
// Create a workflow and call transaction.
|
821
716
|
const temp_workflow = async (ctxt, ...args) => {
|
@@ -856,8 +751,7 @@ class DBOSExecutor {
|
|
856
751
|
// If the UUID is preset, it is possible this execution previously happened. Check, and return its original result if it did.
|
857
752
|
// 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.
|
858
753
|
if (wfCtx.presetUUID) {
|
859
|
-
const
|
860
|
-
const check = await this.#checkExecution(func, workflowUUID, funcId);
|
754
|
+
const check = await wfCtx.checkTxExecution(client, funcId);
|
861
755
|
txn_snapshot = check.txn_snapshot;
|
862
756
|
if (check.output !== exports.dbosNull) {
|
863
757
|
tCtxt.span.setAttribute("cached", true);
|
@@ -868,12 +762,11 @@ class DBOSExecutor {
|
|
868
762
|
}
|
869
763
|
else {
|
870
764
|
// Collect snapshot information for read-only transactions and non-preset UUID transactions, if not already collected above
|
871
|
-
|
872
|
-
txn_snapshot = await DBOSExecutor.#retrieveSnapshot(func);
|
765
|
+
txn_snapshot = await wfCtx.retrieveTxSnapshot(client);
|
873
766
|
}
|
874
767
|
// For non-read-only transactions, flush the result buffer.
|
875
768
|
if (!readOnly) {
|
876
|
-
await
|
769
|
+
await wfCtx.flushResultBuffer(client);
|
877
770
|
}
|
878
771
|
// Execute the user's transaction.
|
879
772
|
let cresult;
|
@@ -902,8 +795,7 @@ class DBOSExecutor {
|
|
902
795
|
else {
|
903
796
|
try {
|
904
797
|
// Synchronously record the output of write transactions and obtain the transaction ID.
|
905
|
-
const
|
906
|
-
const pg_txn_id = await DBOSExecutor.#recordOutput(func, wfCtx.workflowUUID, funcId, txn_snapshot, result, (error) => this.userDatabase.isKeyConflictError(error));
|
798
|
+
const pg_txn_id = await wfCtx.recordOutputTx(client, funcId, txn_snapshot, result);
|
907
799
|
tCtxt.span.setAttribute("pg_txn_id", pg_txn_id);
|
908
800
|
wfCtx.resultBuffer.clear();
|
909
801
|
}
|
@@ -938,9 +830,8 @@ class DBOSExecutor {
|
|
938
830
|
// Record and throw other errors.
|
939
831
|
const e = err;
|
940
832
|
await this.userDatabase.transaction(async (client) => {
|
941
|
-
await
|
942
|
-
|
943
|
-
await DBOSExecutor.#recordError(func, wfCtx.workflowUUID, funcId, txn_snapshot, e, (error) => this.userDatabase.isKeyConflictError(error));
|
833
|
+
await wfCtx.flushResultBuffer(client);
|
834
|
+
await wfCtx.recordErrorTx(client, funcId, txn_snapshot, e);
|
944
835
|
}, { isolationLevel: transaction_1.IsolationLevel.ReadCommitted });
|
945
836
|
wfCtx.resultBuffer.clear();
|
946
837
|
span.setStatus({ code: api_1.SpanStatusCode.ERROR, message: e.message });
|
@@ -953,201 +844,15 @@ class DBOSExecutor {
|
|
953
844
|
// Create a workflow and call procedure.
|
954
845
|
const temp_workflow = async (ctxt, ...args) => {
|
955
846
|
const ctxtImpl = ctxt;
|
956
|
-
return
|
847
|
+
return await ctxtImpl.procedure(proc, ...args);
|
957
848
|
};
|
958
|
-
return
|
959
|
-
...params,
|
849
|
+
return (await this.workflow(temp_workflow, { ...params,
|
960
850
|
tempWfType: TempWorkflowType.procedure,
|
961
851
|
tempWfName: (0, decorators_1.getRegisteredMethodName)(proc),
|
962
852
|
tempWfClass: (0, decorators_1.getRegisteredMethodClassName)(proc),
|
963
853
|
}, ...args)).getResult();
|
964
854
|
}
|
965
|
-
async
|
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) {
|
855
|
+
async executeProcedure(func, config) {
|
1151
856
|
const client = await this.procedurePool.connect();
|
1152
857
|
try {
|
1153
858
|
const readOnly = config.readOnly ?? false;
|
@@ -1206,7 +911,7 @@ class DBOSExecutor {
|
|
1206
911
|
}, wfCtx.span);
|
1207
912
|
const ctxt = new step_1.StepContextImpl(wfCtx, funcID, span, this.logger, commInfo.config, stepFn.name);
|
1208
913
|
await this.userDatabase.transaction(async (client) => {
|
1209
|
-
await
|
914
|
+
await wfCtx.flushResultBuffer(client);
|
1210
915
|
}, { isolationLevel: transaction_1.IsolationLevel.ReadCommitted });
|
1211
916
|
wfCtx.resultBuffer.clear();
|
1212
917
|
// Check if this execution previously happened, returning its original result if it did.
|