diff --git a/server/postgres/src/storage.ts b/server/postgres/src/storage.ts index 57e78b8947..67534a8a36 100644 --- a/server/postgres/src/storage.ts +++ b/server/postgres/src/storage.ts @@ -112,17 +112,17 @@ abstract class PostgresAdapterBase implements DbAdapter { this._helper = new DBCollectionHelper(this.client, this.workspaceId) } - protected async withConnection ( + protected async withConnection( ctx: MeasureContext, - operation: (client: postgres.ReservedSql) => Promise - ): Promise { + operation: (client: postgres.ReservedSql) => Promise + ): Promise { const connection = await this.getConnection(ctx) if (connection !== undefined) { - await operation(connection) + return await operation(connection) } else { const client = await this.client.reserve() try { - await operation(client) + return await operation(client) } finally { client.release() } @@ -1419,7 +1419,7 @@ class PostgresAdapter extends PostgresAdapterBase { 'update with operations', { operations: JSON.stringify(Object.keys(tx.operations)) }, async (ctx) => { - await this.withConnection(ctx, async (connection) => { + return await this.withConnection(ctx, async (connection) => { await this.retryTxn(connection, async (client) => { doc = await this.findDoc(ctx, client, tx.objectClass, tx.objectId, true) if (doc === undefined) return {} @@ -1441,8 +1441,8 @@ class PostgresAdapter extends PostgresAdapterBase { if (tx.retrieve === true && doc !== undefined) { return { object: doc } } + return {} }) - return {} } ) } else { diff --git a/server/tool/src/index.ts b/server/tool/src/index.ts index f0af615c6e..46c29b60ce 100644 --- a/server/tool/src/index.ts +++ b/server/tool/src/index.ts @@ -340,7 +340,9 @@ export async function upgradeModel ( let i = 0 for (const op of migrateOperations) { const t = Date.now() - await ctx.with(op[0], {}, async () => { await op[1].upgrade(migrateState, async () => connection, logger) }) + await ctx.with(op[0], {}, async () => { + await op[1].upgrade(migrateState, async () => connection, logger) + }) const tdelta = Date.now() - t if (tdelta > 0) { logger.log('upgrade:', { operation: op[0], time: tdelta, workspaceId: workspaceId.name }) diff --git a/server/workspace-service/src/ws-operations.ts b/server/workspace-service/src/ws-operations.ts index 123811c904..ce451bf8fb 100644 --- a/server/workspace-service/src/ws-operations.ts +++ b/server/workspace-service/src/ws-operations.ts @@ -34,7 +34,7 @@ function wrapPipeline (ctx: MeasureContext, pipeline: Pipeline, wsUrl: Workspace { targets: {}, txes: [] }, wsUrl, null, - false, + true, new Map(), new Map(), pipeline.context.modelDb @@ -304,7 +304,7 @@ export async function upgradeWorkspaceWith ( { targets: {}, txes: [] }, wsUrl, null, - false, + true, new Map(), new Map(), pipeline.context.modelDb