@dbos-inc/dbos-sdk 5.6.4-preview → 5.6.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/client.d.ts +2 -0
- package/dist/src/client.d.ts.map +1 -1
- package/dist/src/client.js +1 -1
- package/dist/src/client.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 +84 -59
- package/dist/src/dbos.js.map +1 -1
- package/dist/src/system_database.d.ts +3 -3
- package/dist/src/system_database.d.ts.map +1 -1
- package/dist/src/system_database.js +35 -22
- package/dist/src/system_database.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -4
|
@@ -1296,7 +1296,7 @@ class SystemDatabase {
|
|
|
1296
1296
|
serialization: resRow.serialization,
|
|
1297
1297
|
};
|
|
1298
1298
|
}
|
|
1299
|
-
/**
|
|
1299
|
+
/** Dead-letter claimed workflows that exhausted their attempts, keeping their queue; rows others have moved on are left alone. */
|
|
1300
1300
|
async deadLetterWorkflows(workflowIDs, minRecoveryAttempts) {
|
|
1301
1301
|
if (workflowIDs.length === 0)
|
|
1302
1302
|
return;
|
|
@@ -1306,7 +1306,6 @@ class SystemDatabase {
|
|
|
1306
1306
|
owner_xid = NULL,
|
|
1307
1307
|
deduplication_id = NULL,
|
|
1308
1308
|
started_at_epoch_ms = NULL,
|
|
1309
|
-
queue_name = NULL,
|
|
1310
1309
|
updated_at = (EXTRACT(EPOCH FROM now()) * 1000)::bigint,
|
|
1311
1310
|
completed_at = (EXTRACT(EPOCH FROM now()) * 1000)::bigint
|
|
1312
1311
|
WHERE ${this.wfIn(undefined, workflowIDs, params)} AND status = $2 AND recovery_attempts >= $3`, params);
|
|
@@ -1898,7 +1897,7 @@ class SystemDatabase {
|
|
|
1898
1897
|
async #cancelWorkflows(workflowIDs) {
|
|
1899
1898
|
const params = [workflow_1.StatusString.CANCELLED, workflow_1.StatusString.SUCCESS, workflow_1.StatusString.ERROR];
|
|
1900
1899
|
await this.pool.query(`UPDATE "${this.schemaName}".workflow_status
|
|
1901
|
-
SET status = $1, owner_xid = NULL,
|
|
1900
|
+
SET status = $1, owner_xid = NULL, deduplication_id = NULL, started_at_epoch_ms = NULL,
|
|
1902
1901
|
suspend_key = NULL,
|
|
1903
1902
|
updated_at = (EXTRACT(EPOCH FROM now()) * 1000)::bigint,
|
|
1904
1903
|
completed_at = (EXTRACT(EPOCH FROM now()) * 1000)::bigint
|
|
@@ -1909,7 +1908,7 @@ class SystemDatabase {
|
|
|
1909
1908
|
// The caller's own workflow, even where a same-ID workflow is bound as a target.
|
|
1910
1909
|
await this.ownKey(workflowID, undefined, () => this.#checkIfCanceled(this.pool, workflowID));
|
|
1911
1910
|
}
|
|
1912
|
-
async resumeWorkflows(workflowIDs, queueName) {
|
|
1911
|
+
async resumeWorkflows(workflowIDs, queueName, queuePartitionKey) {
|
|
1913
1912
|
const client = await this.connect();
|
|
1914
1913
|
try {
|
|
1915
1914
|
await client.query('BEGIN ISOLATION LEVEL READ COMMITTED');
|
|
@@ -1921,14 +1920,18 @@ class SystemDatabase {
|
|
|
1921
1920
|
if (missing.length > 0) {
|
|
1922
1921
|
throw new error_1.DBOSNonExistentWorkflowError(`Workflow ${missing.join(', ')} does not exist`);
|
|
1923
1922
|
}
|
|
1923
|
+
// Only what is passed changes: the row keeps its queue (the internal one if it has none) and key.
|
|
1924
1924
|
const updateParams = [
|
|
1925
1925
|
workflow_1.StatusString.ENQUEUED,
|
|
1926
|
-
queueName ??
|
|
1926
|
+
queueName ?? null,
|
|
1927
1927
|
workflow_1.StatusString.SUCCESS,
|
|
1928
1928
|
workflow_1.StatusString.ERROR,
|
|
1929
|
+
utils_1.INTERNAL_QUEUE_NAME,
|
|
1930
|
+
queuePartitionKey ?? null,
|
|
1929
1931
|
];
|
|
1930
1932
|
await client.query(`UPDATE "${this.schemaName}".workflow_status
|
|
1931
|
-
SET status = $1, owner_xid = NULL, queue_name = $2,
|
|
1933
|
+
SET status = $1, owner_xid = NULL, queue_name = COALESCE($2::text, queue_name, $5::text),
|
|
1934
|
+
queue_partition_key = COALESCE($6::text, queue_partition_key), recovery_attempts = 0,
|
|
1932
1935
|
workflow_deadline_epoch_ms = NULL, deduplication_id = NULL,
|
|
1933
1936
|
started_at_epoch_ms = NULL, suspend_key = NULL,
|
|
1934
1937
|
updated_at = (EXTRACT(EPOCH FROM now()) * 1000)::bigint,
|
|
@@ -2191,19 +2194,21 @@ class SystemDatabase {
|
|
|
2191
2194
|
AND (consumed_by_function_id >= $1 OR consumed = false)`, messageParams);
|
|
2192
2195
|
const outputParams = [];
|
|
2193
2196
|
await client.query(`DELETE FROM "${schema}".workflow_output WHERE ${this.wf(undefined, workflowID, outputParams)}`, outputParams);
|
|
2194
|
-
// Re-enqueue the workflow. Re-asserting the status
|
|
2195
|
-
// moved on underneath us from being resurrected.
|
|
2197
|
+
// Re-enqueue the workflow, keeping its queue and key unless given. Re-asserting the status
|
|
2198
|
+
// we read keeps a workflow that moved on underneath us from being resurrected.
|
|
2196
2199
|
const params = [
|
|
2197
2200
|
workflow_1.StatusString.ENQUEUED,
|
|
2198
|
-
options.queueName ??
|
|
2201
|
+
options.queueName ?? null,
|
|
2199
2202
|
options.queuePartitionKey ?? null,
|
|
2200
2203
|
status,
|
|
2204
|
+
utils_1.INTERNAL_QUEUE_NAME,
|
|
2201
2205
|
];
|
|
2202
2206
|
const setVersion = options.applicationVersion !== undefined
|
|
2203
2207
|
? `, application_version = $${params.push(options.applicationVersion)}`
|
|
2204
2208
|
: '';
|
|
2205
2209
|
const { rowCount } = await client.query(`UPDATE "${schema}".workflow_status
|
|
2206
|
-
SET status = $1, owner_xid = NULL, queue_name = $2,
|
|
2210
|
+
SET status = $1, owner_xid = NULL, queue_name = COALESCE($2::text, queue_name, $5::text),
|
|
2211
|
+
queue_partition_key = COALESCE($3::text, queue_partition_key), recovery_attempts = 0,
|
|
2207
2212
|
workflow_deadline_epoch_ms = NULL, deduplication_id = NULL, started_at_epoch_ms = NULL,
|
|
2208
2213
|
suspend_key = NULL, completed_at = NULL, output = NULL, error = NULL,
|
|
2209
2214
|
updated_at = (EXTRACT(EPOCH FROM now()) * 1000)::bigint${setVersion}
|
|
@@ -2241,7 +2246,8 @@ class SystemDatabase {
|
|
|
2241
2246
|
const { rows: statusRows } = await client.query(`SELECT ws.workflow_uuid, ws.name, ws.class_name, ws.config_name, ws.application_id,
|
|
2242
2247
|
ws.authenticated_user, ws.authenticated_roles, ws.assumed_role,
|
|
2243
2248
|
COALESCE(wi.inputs, ws.inputs) AS inputs, ws.serialization,
|
|
2244
|
-
ws.application_version, ws.attributes, ws.application_name
|
|
2249
|
+
ws.application_version, ws.attributes, ws.application_name,
|
|
2250
|
+
ws.queue_name, ws.queue_partition_key, ws.priority
|
|
2245
2251
|
FROM "${this.schemaName}".workflow_status ws
|
|
2246
2252
|
LEFT JOIN "${this.schemaName}".workflow_input wi ON ${this.wfJoin('ws', 'wi')}
|
|
2247
2253
|
WHERE ${this.wfIn('ws', originalWorkflowIDs, statusParams)}`, statusParams);
|
|
@@ -2251,7 +2257,6 @@ class SystemDatabase {
|
|
|
2251
2257
|
throw new error_1.DBOSNonExistentWorkflowError(`Workflow ${wid} does not exist`);
|
|
2252
2258
|
}
|
|
2253
2259
|
}
|
|
2254
|
-
const queueName = options.queueName ?? utils_1.INTERNAL_QUEUE_NAME;
|
|
2255
2260
|
// Bulk insert all forked workflow status rows.
|
|
2256
2261
|
const insertCols = [
|
|
2257
2262
|
'workflow_uuid',
|
|
@@ -2271,6 +2276,7 @@ class SystemDatabase {
|
|
|
2271
2276
|
'serialization',
|
|
2272
2277
|
'attributes',
|
|
2273
2278
|
'application_name',
|
|
2279
|
+
'priority',
|
|
2274
2280
|
];
|
|
2275
2281
|
if (options.timeoutMS !== undefined) {
|
|
2276
2282
|
insertCols.push('workflow_timeout_ms');
|
|
@@ -2291,7 +2297,8 @@ class SystemDatabase {
|
|
|
2291
2297
|
ws.name,
|
|
2292
2298
|
ws.class_name ?? null,
|
|
2293
2299
|
ws.config_name ?? null,
|
|
2294
|
-
|
|
2300
|
+
// A fork inherits its original's queue, key, and priority, except what is passed.
|
|
2301
|
+
options.queueName ?? ws.queue_name ?? utils_1.INTERNAL_QUEUE_NAME,
|
|
2295
2302
|
ws.authenticated_user,
|
|
2296
2303
|
ws.assumed_role,
|
|
2297
2304
|
ws.authenticated_roles,
|
|
@@ -2299,11 +2306,12 @@ class SystemDatabase {
|
|
|
2299
2306
|
ws.application_id,
|
|
2300
2307
|
// Legacy column: the payload lives in workflow_input.
|
|
2301
2308
|
null,
|
|
2302
|
-
options.queuePartitionKey ?? null,
|
|
2309
|
+
options.queuePartitionKey ?? ws.queue_partition_key ?? null,
|
|
2303
2310
|
origID,
|
|
2304
2311
|
ws.serialization,
|
|
2305
2312
|
ws.attributes ? JSON.stringify(ws.attributes) : null,
|
|
2306
2313
|
forkOwners.get(forkID) ?? null,
|
|
2314
|
+
ws.priority ?? 0,
|
|
2307
2315
|
...(options.timeoutMS !== undefined ? [options.timeoutMS] : []),
|
|
2308
2316
|
];
|
|
2309
2317
|
}));
|
|
@@ -3299,7 +3307,7 @@ class SystemDatabase {
|
|
|
3299
3307
|
// Literal statuses let the planner match idx_workflow_status_deadline_v2 under any plan mode.
|
|
3300
3308
|
// SKIP LOCKED leaves a row a dequeue or a peer's sweep holds for the next sweep.
|
|
3301
3309
|
const { rows } = await this.pool.query(`UPDATE "${this.schemaName}".workflow_status
|
|
3302
|
-
SET status = $1, owner_xid = NULL,
|
|
3310
|
+
SET status = $1, owner_xid = NULL, deduplication_id = NULL, started_at_epoch_ms = NULL,
|
|
3303
3311
|
suspend_key = NULL,
|
|
3304
3312
|
updated_at = (EXTRACT(EPOCH FROM now()) * 1000)::bigint,
|
|
3305
3313
|
completed_at = (EXTRACT(EPOCH FROM now()) * 1000)::bigint
|
|
@@ -4216,11 +4224,13 @@ class SystemDatabase {
|
|
|
4216
4224
|
* Promote a version to latest. Promoting a peer's is a collision, not a retiming;
|
|
4217
4225
|
* promotion claims an unclaimed row, which would otherwise be every peer's latest.
|
|
4218
4226
|
*/
|
|
4219
|
-
async updateApplicationVersionTimestamp(versionName, newTimestamp, applicationName) {
|
|
4227
|
+
async updateApplicationVersionTimestamp(versionName, newTimestamp, applicationName, txnClient) {
|
|
4220
4228
|
const owner = applicationName ?? this.appName;
|
|
4221
|
-
|
|
4229
|
+
// A caller-supplied client is already in a transaction, which owns BEGIN and COMMIT.
|
|
4230
|
+
const client = txnClient ?? (await this.connect());
|
|
4222
4231
|
try {
|
|
4223
|
-
|
|
4232
|
+
if (!txnClient)
|
|
4233
|
+
await client.query('BEGIN');
|
|
4224
4234
|
const resolved = await this.#resolveRowOwner(client, 'application_versions', 'version_name', versionName, owner, 'Application version');
|
|
4225
4235
|
// Scoped to the row this writer resolved to: once version_name is no longer globally unique, a bare name match would retime every peer's version.
|
|
4226
4236
|
const scope = resolved === undefined ? 'application_name IS NULL' : '(application_name = $3 OR application_name IS NULL)';
|
|
@@ -4230,14 +4240,17 @@ class SystemDatabase {
|
|
|
4230
4240
|
await client.query(`UPDATE "${this.schemaName}".application_versions
|
|
4231
4241
|
SET version_timestamp = $1, application_name = ${resolved === undefined ? 'application_name' : '$3'}
|
|
4232
4242
|
WHERE ${this.global(undefined, params)} AND version_name = $2 AND ${scope}`, params);
|
|
4233
|
-
|
|
4243
|
+
if (!txnClient)
|
|
4244
|
+
await client.query('COMMIT');
|
|
4234
4245
|
}
|
|
4235
4246
|
catch (e) {
|
|
4236
|
-
|
|
4247
|
+
if (!txnClient)
|
|
4248
|
+
await client.query('ROLLBACK');
|
|
4237
4249
|
throw e;
|
|
4238
4250
|
}
|
|
4239
4251
|
finally {
|
|
4240
|
-
|
|
4252
|
+
if (!txnClient)
|
|
4253
|
+
client.release();
|
|
4241
4254
|
}
|
|
4242
4255
|
}
|
|
4243
4256
|
async listApplicationVersions() {
|
|
@@ -5001,7 +5014,7 @@ __decorate([
|
|
|
5001
5014
|
__decorate([
|
|
5002
5015
|
dbRetry(),
|
|
5003
5016
|
__metadata("design:type", Function),
|
|
5004
|
-
__metadata("design:paramtypes", [Array, String]),
|
|
5017
|
+
__metadata("design:paramtypes", [Array, String, String]),
|
|
5005
5018
|
__metadata("design:returntype", Promise)
|
|
5006
5019
|
], SystemDatabase.prototype, "resumeWorkflows", null);
|
|
5007
5020
|
__decorate([
|