Override completion on OOM crashes

This commit is contained in:
nicktrn
2024-07-01 13:22:35 +01:00
parent 0e77e7ef7d
commit cd5d2ae92b
2 changed files with 11 additions and 4 deletions
+5 -1
View File
@@ -344,7 +344,7 @@ export class EventRepository {
});
}
async queryIncompleteEvents(queryOptions: QueryOptions) {
async queryIncompleteEvents(queryOptions: QueryOptions, allowCompleteDuplicate = false) {
// First we will find all the events that match the query options (selecting minimal data).
const taskEvents = await this.readReplica.taskEvent.findMany({
where: queryOptions,
@@ -362,6 +362,10 @@ export class EventRepository {
// If the event is cancelled, it is not incomplete
if (event.isCancelled) return false;
if (allowCompleteDuplicate) {
return true;
}
// There must not be another complete event with the same spanId
const hasCompleteDuplicate = taskEvents.some(
(otherEvent) =>
@@ -75,9 +75,12 @@ export class CrashTaskRunService extends BaseService {
},
});
const inProgressEvents = await eventRepository.queryIncompleteEvents({
runId: taskRun.friendlyId,
});
const inProgressEvents = await eventRepository.queryIncompleteEvents(
{
runId: taskRun.friendlyId,
},
options?.overrideCompletion
);
logger.debug("Crashing in-progress events", {
inProgressEvents: inProgressEvents.map((event) => event.id),