fix(acquisition): 同一作品并发评估时只建一个新作品订阅
新作品收录在事务里按作品加咨询锁并复查已有订阅;否则后建的订阅收录版本同名冲突、没有版本, 现在会被补建出一个多余的默认版本。 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Cxwgnn2pbzQ7rXv3rq7fei
This commit is contained in:
1 parent
0bbf5885aa
commit
19d6de9891
1 file changed
+8
@@ -580,6 +580,14 @@ async function evaluateRelease(c: Ctx, rel: SourceReleaseRow, eventUnits: readon
|
||||
.executeTakeFirst();
|
||||
if (!grant) return skip("no_automation_grant");
|
||||
await db.transaction().execute(async (trx) => {
|
||||
// 同一作品的几条资源并发评估时只建一个新作品订阅(否则后建的订阅收录版本同名冲突,被补建成默认版本)
|
||||
await sql`select pg_advisory_xact_lock(hashtextextended(${`new_title:${entity.id}`}, 0))`.execute(trx);
|
||||
const exists = await trx
|
||||
.selectFrom("subscription")
|
||||
.select("id")
|
||||
.where("media_entity_id", "=", entity.id)
|
||||
.executeTakeFirst();
|
||||
if (exists) return;
|
||||
const sub = await trx
|
||||
.insertInto("subscription")
|
||||
.values({
|
||||
|
||||
Reference in new issue
Block a user