Skip to content

Commit 0725466

Browse files
committed
feat(webapp): add RUN_REPLICATION_RUN_OPS_DATABASE_URL for the runs-replication source
The run-ops runs-replication source now takes its connection URL from RUN_REPLICATION_RUN_OPS_DATABASE_URL, falling back to RUN_OPS_DATABASE_URL when unset. The runs replicator speaks the Postgres streaming replication protocol, which cannot run through a transaction pooler. A dedicated URL lets the replication connection use a direct endpoint even when RUN_OPS_DATABASE_URL points at a pooler. Unset preserves existing behaviour (self-host, where RUN_OPS_DATABASE_URL is a direct connection).
1 parent b31ded7 commit 0725466

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

apps/webapp/app/env.server.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1713,9 +1713,14 @@ const EnvironmentSchema = z
17131713

17141714
// --- Run-ops DB split — second replication source (the NEW dedicated run-ops DB). ---
17151715
// Cloud-only; only consulted when isSplitEnabled() is true. Self-host never sets these.
1716-
// The NEW source's connection URL is RUN_OPS_DATABASE_URL; these add the NEW source's replication
1717-
// slot/publication and an explicit per-source enable so it can be brought up independently of the
1718-
// legacy source during the transition.
1716+
// Connection URL for the run-ops DB used by the NEW runs-replication source: if set, else
1717+
// RUN_OPS_DATABASE_URL. Separate from the app's RUN_OPS_DATABASE_URL because the replication
1718+
// protocol can't run over a transaction pooler, so it needs a direct endpoint even when the app's
1719+
// URL is pooled; unset → RUN_OPS_DATABASE_URL (direct on self-host).
1720+
RUN_REPLICATION_RUN_OPS_DATABASE_URL: z
1721+
.string()
1722+
.refine(isValidDatabaseUrl, "RUN_REPLICATION_RUN_OPS_DATABASE_URL is invalid")
1723+
.optional(),
17191724
RUN_REPLICATION_NEW_SLOT_NAME: z.string().default("task_runs_to_clickhouse_v2"),
17201725
RUN_REPLICATION_NEW_PUBLICATION_NAME: z
17211726
.string()

apps/webapp/app/services/runsReplicationInstance.server.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ export class SplitReplicationMisconfiguredError extends Error {
7171
'RUN_OPS_SPLIT_ENABLED is on but the runs-replication sources[] has no "new" source: ' +
7272
"run-ops runs on the new DB would not replicate to ClickHouse, under-counting every " +
7373
"ClickHouse-fronted aggregate. Enable the new replication source " +
74-
"(RUN_REPLICATION_NEW_ENABLED / RUN_OPS_DATABASE_URL) or turn the split off."
74+
"(RUN_REPLICATION_NEW_ENABLED / RUN_REPLICATION_RUN_OPS_DATABASE_URL or RUN_OPS_DATABASE_URL) " +
75+
"or turn the split off."
7576
);
7677
this.name = "SplitReplicationMisconfiguredError";
7778
}
@@ -172,7 +173,7 @@ function initializeRunsReplicationInstance() {
172173
const sources = buildReplicationSources({
173174
splitEnabled,
174175
legacyUrl: DATABASE_URL,
175-
newUrl: env.RUN_OPS_DATABASE_URL,
176+
newUrl: env.RUN_REPLICATION_RUN_OPS_DATABASE_URL ?? env.RUN_OPS_DATABASE_URL,
176177
newSourceOverride: env.RUN_REPLICATION_NEW_ENABLED === "disabled" ? false : undefined,
177178
legacySlotName: env.RUN_REPLICATION_SLOT_NAME,
178179
legacyPublicationName: env.RUN_REPLICATION_PUBLICATION_NAME,

0 commit comments

Comments
 (0)