-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
feat(run-ops): ClickHouse multi-source replication fan-in + admin ops #4119
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
+1,766
−138
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
57db55f
feat(run-ops): ClickHouse multi-source replication fan-in + admin ops
d-cs 8844bd6
chore(run-ops split): strip plan-enumeration labels from replication …
d-cs e543aed
style(run-ops): apply oxfmt
d-cs ab014a7
fix(run-ops): align single-source leader-lock id, guard shutdown stop…
d-cs 6fcf188
chore(run-ops split): add server-changes entry for ClickHouse replica…
d-cs 766138c
chore(run-ops): fix lint/format for main lint rules
d-cs 29bd826
fix(run-ops replication): shut down bootstrap replication instance be…
d-cs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| area: webapp | ||
| type: feature | ||
| --- | ||
|
|
||
| Replicate task runs into ClickHouse from multiple source databases so the run-ops DB split can fan both databases into analytics, with an admin status endpoint reporting per-source replication leadership. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
apps/webapp/app/routes/admin.api.v1.runs-replication.status.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| import { type LoaderFunctionArgs, json } from "@remix-run/server-runtime"; | ||
| import Redis from "ioredis"; | ||
| import { env } from "~/env.server"; | ||
| import { requireAdminApiRequest } from "~/services/personalAccessToken.server"; | ||
| import { getRunsReplicationConfiguredSources } from "~/services/runsReplicationGlobal.server"; | ||
|
|
||
| /** | ||
| * Probes per-source replication leadership via the redlock leader-lock key, which | ||
| * is DOUBLE-PREFIXED with `logical-replication-client:` — once from the connection's | ||
| * keyPrefix and once from redlock's resource string. So we prefix this connection | ||
| * with `runs-replication:logical-replication-client:` and EXISTS on the resource | ||
| * `logical-replication-client:runs-replication:<id>`, resolving to: | ||
| * runs-replication:logical-replication-client:logical-replication-client:runs-replication:<id> | ||
| */ | ||
| async function probeLeadership(sourceIds: string[]): Promise<Map<string, boolean>> { | ||
| const leaders = new Map<string, boolean>(); | ||
|
|
||
| const redis = new Redis({ | ||
| keyPrefix: "runs-replication:logical-replication-client:", | ||
| port: env.RUN_REPLICATION_REDIS_PORT ?? undefined, | ||
| host: env.RUN_REPLICATION_REDIS_HOST ?? undefined, | ||
| username: env.RUN_REPLICATION_REDIS_USERNAME ?? undefined, | ||
| password: env.RUN_REPLICATION_REDIS_PASSWORD ?? undefined, | ||
| enableAutoPipelining: true, | ||
| ...(env.RUN_REPLICATION_REDIS_TLS_DISABLED === "true" ? {} : { tls: {} }), | ||
| }); | ||
|
|
||
| try { | ||
| for (const id of sourceIds) { | ||
| const exists = await redis.exists(`logical-replication-client:runs-replication:${id}`); | ||
| leaders.set(id, exists === 1); | ||
| } | ||
| } finally { | ||
| await redis.quit(); | ||
| } | ||
|
|
||
| return leaders; | ||
| } | ||
|
|
||
| export async function loader({ request }: LoaderFunctionArgs) { | ||
| await requireAdminApiRequest(request); | ||
|
|
||
| const sources = getRunsReplicationConfiguredSources(); | ||
|
|
||
| if (!sources || sources.length === 0) { | ||
| return json({ enabled: false, sources: [] }); | ||
| } | ||
|
|
||
| const leaders = await probeLeadership(sources.map((s) => s.id)); | ||
|
|
||
| return json({ | ||
| enabled: env.RUN_REPLICATION_ENABLED === "1" && sources.length > 0, | ||
| sources: sources.map((s) => ({ | ||
| id: s.id, | ||
| slotName: s.slotName, | ||
| originGeneration: s.originGeneration, | ||
| leader: leaders.get(s.id) ?? false, | ||
| })), | ||
| }); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.