Skip to content

Use priority offsets in MarQS and schedule future messages using redis worker #1720

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions apps/webapp/app/v3/legacyRunEngineWorker.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { singleton } from "~/utils/singleton";
import { TaskRunHeartbeatFailedService } from "./taskRunHeartbeatFailed.server";
import { completeBatchTaskRunItemV3 } from "./services/batchTriggerV3.server";
import { prisma } from "~/db.server";
import { marqs } from "./marqs/index.server";

function initializeWorker() {
const redisOptions = {
Expand Down Expand Up @@ -49,6 +50,15 @@ function initializeWorker() {
maxAttempts: 10,
},
},
scheduleRequeueMessage: {
schema: z.object({
messageId: z.string(),
}),
visibilityTimeoutMs: 60_000,
retry: {
maxAttempts: 5,
},
},
},
concurrency: {
workers: env.LEGACY_RUN_ENGINE_WORKER_CONCURRENCY_WORKERS,
Expand All @@ -74,6 +84,9 @@ function initializeWorker() {
attempt
);
},
scheduleRequeueMessage: async ({ payload }) => {
await marqs.requeueMessageById(payload.messageId);
},
},
});

Expand Down
4 changes: 4 additions & 0 deletions apps/webapp/app/v3/marqs/constants.server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const MARQS_RESUME_PRIORITY_TIMESTAMP_OFFSET = 31_556_952 * 1000; // 1 year
export const MARQS_RETRY_PRIORITY_TIMESTAMP_OFFSET = 15_778_476 * 1000; // 6 months
export const MARQS_DELAYED_REQUEUE_THRESHOLD_IN_MS = 500;
export const MARQS_SCHEDULED_REQUEUE_AVAILABLE_AT_THRESHOLD_IN_MS = 500;
95 changes: 0 additions & 95 deletions apps/webapp/app/v3/marqs/envPriorityDequeuingStrategy.server.ts

This file was deleted.

Loading
Loading