Skip to content

Commit 7be07b4

Browse files
authored
allow configuring the replication leader lock settings (#2042)
1 parent bb96e84 commit 7be07b4

File tree

4 files changed

+10
-0
lines changed

4 files changed

+10
-0
lines changed

apps/webapp/app/env.server.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,8 @@ const EnvironmentSchema = z.object({
766766
RUN_REPLICATION_LEADER_LOCK_EXTEND_INTERVAL_MS: z.coerce.number().int().default(10_000),
767767
RUN_REPLICATION_ACK_INTERVAL_SECONDS: z.coerce.number().int().default(10),
768768
RUN_REPLICATION_LOG_LEVEL: z.enum(["log", "error", "warn", "info", "debug"]).default("info"),
769+
RUN_REPLICATION_LEADER_LOCK_RETRY_COUNT: z.coerce.number().int().default(240),
770+
RUN_REPLICATION_LEADER_LOCK_RETRY_INTERVAL_MS: z.coerce.number().int().default(500),
769771
});
770772

771773
export type Environment = z.infer<typeof EnvironmentSchema>;

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ function initializeRunsReplicationInstance() {
4545
flushBatchSize: env.RUN_REPLICATION_FLUSH_BATCH_SIZE,
4646
leaderLockTimeoutMs: env.RUN_REPLICATION_LEADER_LOCK_TIMEOUT_MS,
4747
leaderLockExtendIntervalMs: env.RUN_REPLICATION_LEADER_LOCK_EXTEND_INTERVAL_MS,
48+
leaderLockRetryCount: env.RUN_REPLICATION_LEADER_LOCK_RETRY_COUNT,
49+
leaderLockRetryIntervalMs: env.RUN_REPLICATION_LEADER_LOCK_RETRY_INTERVAL_MS,
4850
ackIntervalSeconds: env.RUN_REPLICATION_ACK_INTERVAL_SECONDS,
4951
logLevel: env.RUN_REPLICATION_LOG_LEVEL,
5052
});

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ export type RunsReplicationServiceOptions = {
4343
flushBatchSize?: number;
4444
leaderLockTimeoutMs?: number;
4545
leaderLockExtendIntervalMs?: number;
46+
leaderLockRetryCount?: number;
47+
leaderLockRetryIntervalMs?: number;
4648
ackIntervalSeconds?: number;
4749
acknowledgeTimeoutMs?: number;
4850
logger?: Logger;
@@ -103,6 +105,8 @@ export class RunsReplicationService {
103105
leaderLockTimeoutMs: options.leaderLockTimeoutMs ?? 30_000,
104106
leaderLockExtendIntervalMs: options.leaderLockExtendIntervalMs ?? 10_000,
105107
ackIntervalSeconds: options.ackIntervalSeconds ?? 10,
108+
leaderLockRetryCount: options.leaderLockRetryCount ?? 240,
109+
leaderLockRetryIntervalMs: options.leaderLockRetryIntervalMs ?? 500,
106110
});
107111

108112
this._concurrentFlushScheduler = new ConcurrentFlushScheduler<TaskRunInsert>({

internal-packages/replication/src/client.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,8 @@ export class LogicalReplicationClient {
593593
table: this.options.table,
594594
slotName: this.options.slotName,
595595
publicationName: this.options.publicationName,
596+
retryCount: this.leaderLockRetryCount,
597+
retryIntervalMs: this.leaderLockRetryIntervalMs,
596598
error: err,
597599
});
598600

0 commit comments

Comments
 (0)