Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Denis Bykhov <[email protected]>
  • Loading branch information
BykhovDenis committed Oct 28, 2024
1 parent 416b5d6 commit 93c6cb5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
14 changes: 7 additions & 7 deletions server/postgres/src/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,17 @@ abstract class PostgresAdapterBase implements DbAdapter {
this._helper = new DBCollectionHelper(this.client, this.workspaceId)
}

protected async withConnection (
protected async withConnection<T>(
ctx: MeasureContext,
operation: (client: postgres.ReservedSql) => Promise<any>
): Promise<void> {
operation: (client: postgres.ReservedSql) => Promise<T>
): Promise<T> {
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()
}
Expand Down Expand Up @@ -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 {}
Expand All @@ -1441,8 +1441,8 @@ class PostgresAdapter extends PostgresAdapterBase {
if (tx.retrieve === true && doc !== undefined) {
return { object: doc }
}
return {}
})
return {}
}
)
} else {
Expand Down
4 changes: 3 additions & 1 deletion server/tool/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand Down
4 changes: 2 additions & 2 deletions server/workspace-service/src/ws-operations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -304,7 +304,7 @@ export async function upgradeWorkspaceWith (
{ targets: {}, txes: [] },
wsUrl,
null,
false,
true,
new Map(),
new Map(),
pipeline.context.modelDb
Expand Down

0 comments on commit 93c6cb5

Please sign in to comment.