🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
chore: drop queue backup option in bullmq (#6141)
Steffen Schmitz65cdd75282c0
diff --git a/packages/shared/prisma/generated/types.ts b/packages/shared/prisma/generated/types.tsindex 092ffd7c38..be20605635 100644--- a/packages/shared/prisma/generated/types.ts+++ b/packages/shared/prisma/generated/types.ts@@ -502,13 +502,6 @@ export type PromptDependency = {child_label: string | null;child_version: number | null;};-export type QueueBackUp = {- id: string;- project_id: string | null;- queue_name: string;- content: unknown;- created_at: Generated<Timestamp>;-};export type ScoreConfig = {id: string;created_at: Generated<Timestamp>;@@ -602,7 +595,6 @@ export type DB = {projects: Project;prompt_dependencies: PromptDependency;prompts: Prompt;- queue_backups: QueueBackUp;score_configs: ScoreConfig;scores: LegacyPrismaScore;Session: Session;diff --git a/packages/shared/prisma/migrations/20250321102240_drop_queue_backup_table/migration.sql b/packages/shared/prisma/migrations/20250321102240_drop_queue_backup_table/migration.sqlnew file mode 100644index 0000000000..87ab6d5f6e--- /dev/null+++ b/packages/shared/prisma/migrations/20250321102240_drop_queue_backup_table/migration.sql@@ -0,0 +1,2 @@+-- DropTable+DROP TABLE "queue_backups";diff --git a/packages/shared/prisma/schema.prisma b/packages/shared/prisma/schema.prismaindex 569e3ab27a..b64b9d0d78 100644--- a/packages/shared/prisma/schema.prisma+++ b/packages/shared/prisma/schema.prisma@@ -675,8 +675,8 @@ model PromptDependency {childLabel String? @map("child_label")childVersion Int? @map("child_version")- @@index([projectId, parentId])- @@index([projectId, childName])+ @@index([projectId, parentId], map: "prompt_dependencies_project_id_parent_id")+ @@index([projectId, childName], map: "prompt_dependencies_project_id_child_name")@@map("prompt_dependencies")}@@ -953,17 +953,6 @@ model ObservationMedia {@@map("observation_media")}-model QueueBackUp {- id String @id @default(cuid())- projectId String? @map("project_id")- queueName String @map("queue_name")- content Json-- createdAt DateTime @default(now()) @map("created_at")-- @@map("queue_backups")-}-model BillingMeterBackup {// uniquestripeCustomerId String @map("stripe_customer_id")diff --git a/web/src/pages/api/admin/bullmq/index.ts b/web/src/pages/api/admin/bullmq/index.tsindex 6526b0a2d8..b21118d76d 100644--- a/web/src/pages/api/admin/bullmq/index.ts+++ b/web/src/pages/api/admin/bullmq/index.ts@@ -2,7 +2,6 @@ import { type NextApiRequest, type NextApiResponse } from "next";import { z } from "zod";import { logger, QueueName, getQueue } from "@langfuse/shared/src/server";import { env } from "@/src/env.mjs";-import { prisma } from "@langfuse/shared/src/db";/*This API route is used by Langfuse Cloud to retry failed bullmq jobs.@@ -28,17 +27,6 @@ const ManageBullBody = z.discriminatedUnion("action", [queueNames: z.array(z.string()),bullStatus: BullStatus,}),- z.object({- action: z.literal("backup"),- queueName: z.string(),- bullStatus: BullStatus,- numberOfEvents: z.number(),- }),- z.object({- action: z.literal("restore"),- queueName: z.string(),- numberOfEvents: z.number(),- }),]);export default async function handler(@@ -176,21 +164,6 @@ export default async function handler(return res.status(200).json({ message: "Retried all jobs" });}- if (req.method === "POST" && body.data.action === "backup") {- await backUpEvents(- body.data.queueName as QueueName,- body.data.numberOfEvents,- body.data.bullStatus,- );- }-- if (req.method === "POST" && body.data.action === "restore") {- await restoreEvents(- body.data.queueName as QueueName,- body.data.numberOfEvents,- );- }-// return not implemented errorres.status(404).json({ error: "Action does not exist" });} catch (e) {@@ -198,69 +171,3 @@ export default async function handler(res.status(500).json({ error: e });}}--const backUpEvents = async (- queueName: QueueName,- numberOfEvents: number,- bullStatus: z.infer<typeof BullStatus>,-) => {- const queue = getQueue(queueName);- let processedEvents = 0;- const batchSize = 1000;-- while (processedEvents < numberOfEvents) {- const remainingEvents = numberOfEvents - processedEvents;- const currentBatchSize = Math.min(batchSize, remainingEvents);-- const events = await queue?.getJobs(- [bullStatus],- 0,- currentBatchSize,- true,- );-- if (!events || events.length === 0) {- break;- }-- await prisma.queueBackUp.createMany({- data: events.map((event) => ({- queueName,- content: event,- projectId: event.data.projectId ?? undefined,- createdAt: new Date(),- })),- });-- // remove events from the queue but might throw in case if the job is already processing- await Promise.all(- events.map(async (event) => {- try {- await event.remove();- } catch (error) {- logger.error(`Failed to remove event ${event.id}:`, error);- }- }),- );-- processedEvents += events.length;- }-};--const restoreEvents = async (queueName: QueueName, numberOfEvents: number) => {- const queue = getQueue(queueName);-- const queueBackUp = await prisma.queueBackUp.findMany({- where: {- queueName,- },- orderBy: {- createdAt: "desc",- },- take: numberOfEvents,- });-- await queue?.addBulk(- queueBackUp.map((event) => ({ name: queueName, data: event.content })),- );-};