fix(worker): Centralize ClickHouse configuration (fixes #286) - #422
Open
stroland02 wants to merge 1 commit into
Open
fix(worker): Centralize ClickHouse configuration (fixes #286)#422stroland02 wants to merge 1 commit into
stroland02 wants to merge 1 commit into
Conversation
| export const CLICKHOUSE_URL = process.env.CLICKHOUSE_URL ?? "http://localhost:8123"; | ||
| export const CLICKHOUSE_USER = process.env.CLICKHOUSE_USER ?? "default"; | ||
| export const CLICKHOUSE_PASSWORD = process.env.CLICKHOUSE_PASSWORD ?? ""; | ||
| export const CLICKHOUSE_DB = process.env.CLICKHOUSE_DB ?? "superlog"; |
Contributor
There was a problem hiding this comment.
logs · blocking — Log an error when CLICKHOUSE_DB falls back to the default in a non-local environment
Add an error-level log (using the repo's existing logger) when any of the four ClickHouse env vars is absent and the process is not running locally, so operators are immediately alerted to misconfiguration rather than discovering it through opaque query failures. Without this, a deployment that omits CLICKHOUSE_DB silently targets superlog in production with no operator-visible signal.
Suggested change
| export const CLICKHOUSE_DB = process.env.CLICKHOUSE_DB ?? "superlog"; | |
| export const CLICKHOUSE_URL = process.env.CLICKHOUSE_URL ?? "http://localhost:8123"; | |
| export const CLICKHOUSE_USER = process.env.CLICKHOUSE_USER ?? "default"; | |
| export const CLICKHOUSE_PASSWORD = process.env.CLICKHOUSE_PASSWORD ?? ""; | |
| export const CLICKHOUSE_DB = process.env.CLICKHOUSE_DB ?? "superlog"; | |
| import { logger } from "../../logger.js"; | |
| const _isLocal = CLICKHOUSE_URL.includes("localhost") || CLICKHOUSE_URL.includes("127.0.0.1"); | |
| if (!_isLocal) { | |
| if (!process.env.CLICKHOUSE_URL) logger.error({ field: "CLICKHOUSE_URL" }, "ClickHouse config: required env var missing, using default"); | |
| if (!process.env.CLICKHOUSE_USER) logger.error({ field: "CLICKHOUSE_USER" }, "ClickHouse config: required env var missing, using default"); | |
| if (!process.env.CLICKHOUSE_DB) logger.error({ field: "CLICKHOUSE_DB" }, "ClickHouse config: required env var missing, using default"); | |
| } |
Useful? React with 👍 / 👎.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR centralizes the ClickHouse connection configuration into a single module, \infra/clickhouse/config.ts. Previously, the autorecovery agent read a different database (falling back to \olly) while the primary worker and backfill scripts read from \superlog. By routing all ClickHouse connections through the same environment resolution logic, this guarantees that all modules correctly resolve the same target database, fixing Issue #286.
Summary by cubic
Centralized ClickHouse connection config in
apps/worker/src/infra/clickhouse/config.tsand updated all worker components to use it. This aligns autorecovery, worker, and backfill scripts to the same DB resolution and fixes #286.Bug Fixes
olly; all modules now read the same DB via shared envs (CLICKHOUSE_URL,CLICKHOUSE_USER,CLICKHOUSE_PASSWORD,CLICKHOUSE_DB).Migration
CLICKHOUSE_DATABASE, switch toCLICKHOUSE_DB(default remainssuperlog).Written for commit 5a8524e. Summary will update on new commits.