fix: 修复小程序构建进度死锁
This commit is contained in:
1 parent
f7be18a35e
commit
a933e1feb6
2 files changed
+8
-7
No files matched your search
@@ -151,13 +151,13 @@ export class AdminMiniAppReleaseService {
|
|||||||
buildLogs?: unknown;
|
buildLogs?: unknown;
|
||||||
},
|
},
|
||||||
): Promise<unknown> {
|
): Promise<unknown> {
|
||||||
return this.prisma.$transaction(
|
const task = await this.prisma.miniAppReleaseTask.findFirst({
|
||||||
async (tx) => {
|
where: { id: taskId, brandId },
|
||||||
const task = await tx.miniAppReleaseTask.findFirst({ where: { id: taskId, brandId } });
|
});
|
||||||
if (!task) throw new NotFoundException("小程序发布任务不存在");
|
if (!task) throw new NotFoundException("小程序发布任务不存在");
|
||||||
const buildStatusChanged =
|
const buildStatusChanged =
|
||||||
input.buildStatus !== undefined && input.buildStatus !== task.buildStatus;
|
input.buildStatus !== undefined && input.buildStatus !== task.buildStatus;
|
||||||
return tx.miniAppReleaseTask.update({
|
return this.prisma.miniAppReleaseTask.update({
|
||||||
where: { id: task.id },
|
where: { id: task.id },
|
||||||
data: {
|
data: {
|
||||||
...(input.error !== undefined ? { error: input.error } : {}),
|
...(input.error !== undefined ? { error: input.error } : {}),
|
||||||
@@ -178,9 +178,6 @@ export class AdminMiniAppReleaseService {
|
|||||||
: {}),
|
: {}),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
},
|
|
||||||
{ isolationLevel: Prisma.TransactionIsolationLevel.Serializable },
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private audit(value: Prisma.JsonValue | null, entry: Record<string, unknown>) {
|
private audit(value: Prisma.JsonValue | null, entry: Record<string, unknown>) {
|
||||||
|
|||||||
@@ -9,6 +9,10 @@ const actorId = "admin-1";
|
|||||||
|
|
||||||
function createService(task: Record<string, unknown> | null): AdminMiniAppReleaseService {
|
function createService(task: Record<string, unknown> | null): AdminMiniAppReleaseService {
|
||||||
const prisma = {
|
const prisma = {
|
||||||
|
miniAppReleaseTask: {
|
||||||
|
findFirst: async () => task,
|
||||||
|
update: async ({ data }: { data: Record<string, unknown> }) => ({ ...task, ...data }),
|
||||||
|
},
|
||||||
$transaction: async (callback: (tx: unknown) => unknown) =>
|
$transaction: async (callback: (tx: unknown) => unknown) =>
|
||||||
callback({
|
callback({
|
||||||
miniAppReleaseTask: {
|
miniAppReleaseTask: {
|
||||||
|
|||||||
Reference in new issue
Block a user