fix: release concurrency token exhaustion no longer happens on batchTriggerAndWait (#1937)

This commit is contained in:
Eric Allam
2025-04-17 15:07:06 +01:00
committed by GitHub
parent 2aacf76444
commit 4b42f778ce
2 changed files with 27 additions and 4 deletions
@@ -430,6 +430,11 @@ export class WaitpointSystem {
// Let the worker know immediately, so it can suspend the run
await sendNotificationToWorker({ runId, snapshot, eventBus: this.$.eventBus });
if (isRunBlocked) {
//release concurrency
await this.releaseConcurrencySystem.releaseConcurrencyForSnapshot(snapshot);
}
}
if (timeout) {
@@ -448,10 +453,7 @@ export class WaitpointSystem {
//no pending waitpoint, schedule unblocking the run
//debounce if we're rapidly adding waitpoints
if (isRunBlocked) {
//release concurrency
await this.releaseConcurrencySystem.releaseConcurrencyForSnapshot(snapshot);
} else {
if (!isRunBlocked) {
await this.$.worker.enqueue({
//this will debounce the call
id: `continueRunIfUnblocked:${runId}`,
@@ -147,3 +147,24 @@ export const waitReleaseConcurrencyTestTask = task({
};
},
});
export const batchTriggerAndWaitReleaseConcurrency = task({
id: "batch-trigger-and-wait-release-concurrency",
retry: {
maxAttempts: 1,
},
run: async (payload, { ctx }) => {
return await batch.triggerAndWait([
{ id: batchTriggerAndWaitChildTask.id, payload: { waitSeconds: 1 } },
{ id: batchTriggerAndWaitChildTask.id, payload: { waitSeconds: 1 } },
{ id: batchTriggerAndWaitChildTask.id, payload: { waitSeconds: 1 } },
]);
},
});
const batchTriggerAndWaitChildTask = task({
id: "batch-trigger-and-wait-child-task",
run: async (payload: { waitSeconds: number }, { ctx }) => {
await setTimeout(payload.waitSeconds * 1000);
},
});