Skip to content

Commit 49b05a4

Browse files
committed
fix(webhook-engine): remove the startup partition-ensure
Running ensurePartitions at engine startup fired it on every worker instance at boot, and createPartition (partitionExists then CREATE, with no lock) is not safe to run concurrently across instances. The nightly cron already maintains partitions from a single consumer, which is safe. Initial bootstrap will move to an admin-triggered action rather than running on every instance at startup.
1 parent b30bfa5 commit 49b05a4

1 file changed

Lines changed: 1 addition & 14 deletions

File tree

  • internal-packages/webhook-engine/src/engine

internal-packages/webhook-engine/src/engine/index.ts

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,6 @@ export class WebhookEngine {
132132
concurrency: options.worker.concurrency,
133133
pollIntervalMs: options.worker.pollIntervalMs,
134134
});
135-
void this.#ensurePartitions("startup").catch((error) => {
136-
this.logger.error("webhook ensurePartitions (startup) failed", { error });
137-
});
138135
} else {
139136
this.logger.info("Webhook engine worker disabled");
140137
}
@@ -742,15 +739,6 @@ export class WebhookEngine {
742739
async #handleEnsurePartitionsJob(
743740
_job: JobHandlerParams<typeof webhookWorkerCatalog, "ensurePartitions">
744741
) {
745-
return this.#ensurePartitions("cron");
746-
}
747-
748-
/**
749-
* Pre-create dated partitions ahead + drop cold ones. Runs on the nightly cron and once at
750-
* startup: the cron only fires at its next scheduled tick and the table has no default partition,
751-
* so without the startup run a fresh deploy would reject every delivery until the first cron run.
752-
*/
753-
async #ensurePartitions(context: "cron" | "startup") {
754742
return startSpan(this.tracer, "ensurePartitions", async (span) => {
755743
this.ensurePartitionsCounter.add(1);
756744
const result = await ensurePartitions(this.prisma, {
@@ -761,8 +749,7 @@ export class WebhookEngine {
761749
span.setAttribute("created", result.created.length);
762750
span.setAttribute("dropped", result.dropped.length);
763751
span.setAttribute("deferred", result.deferred.length);
764-
span.setAttribute("context", context);
765-
this.logger.info("webhook ensurePartitions", { ...result, context });
752+
this.logger.info("webhook ensurePartitions", result);
766753
});
767754
}
768755

0 commit comments

Comments
 (0)