Repository navigation
fix: bound ClickHouse system log retention - #13735
Conversation
|
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
The script ran outside CI and restated the retention config it checked; docs/tutorials holds maintainer guides, not self-hosting notes.
Give each <log>_<N> table the TTL of the log that replaced it instead of repeating the retention rules in SQL, so logs.xml is the only place they are defined. SYSTEM FLUSH LOGS already replaces every configured log, so current tables need no ALTER. Leave asynchronous_insert_log at its 3-day default.
Keep it at the 3-day server default, but set it in logs.xml so retention does not depend on that default surviving an image upgrade. Matching the default leaves existing tables in place.
Move the retention config and init script out of inline Compose configs into clickhouse-config.xml and clickhouse-init.sh. They are bind-mounted, copied into the image and by the installer, and rewritten to the host path, the same way as mongo-init.js and mongo-entrypoint.sh. This drops the Compose 2.23.1 requirement.
Docker Desktop bind mounts report every file as executable to bash, so the entrypoint executed the non-executable script and ClickHouse exited with 'bad interpreter: Permission denied'. The installer's copy() also dropped the mode, so installs now keep it.
…-idle-cpu # Conflicts: # clickhouse-init.sh
…on' into fix/clickhouse-idle-cpu # Conflicts: # clickhouse-config.xml
🟢 Tier S · Ready to merge
The PR configures retention for the bundled ClickHouse system logs, disables several high-volume logs that Appwrite does not consume, and applies retention to stale log tables left behind across restarts. It ships the configuration and initialization script through Docker and the installer, including preserving the script's executable mode when copied. Latest changes: The newest commits disable the unused per-second and verbose logs, and extend initialization to apply a seven-day fallback TTL to stale log tables whose active counterpart is no longer configured.
📂 Walkthrough · 6
Reviewed the commits since |
Security rulesNo new WARNING or ERROR findings from security rules. 32 existing findings tracked in
|
What does this PR do?
Bounds the bundled ClickHouse server's own diagnostic logs on self-hosted installations. Most of them have no TTL by default, so
trace_log,text_log,metric_logand the rest keep growing: the reporter saw a 10 GB volume fill in two weeks with about 1.5 GB of Appwrite data.clickhouse-config.xmlis mounted intoconfig.dand sets a TTL of 3 days fortext_log,trace_logandasynchronous_insert_log, 14 days forerror_log, and 7 days for the other listed logs.asynchronous_insert_logalready defaults to 3 days; setting it explicitly means retention no longer depends on that default surviving an image upgrade.ALTERon its own, for example fromusage-setup, is undone by the next restart: ClickHouse moves the altered table toquery_log_0and creates a newquery_logwith no TTL.usage-setupalso runs against whatever_APP_CONNECTIONS_DB_USAGEpoints to, including external ClickHouse servers.<log>_<N>with all of its rows, so existing volumes would never get the space back.clickhouse-init.shruns on every start (CLICKHOUSE_ALWAYS_RUN_INITDB_SCRIPTS): it flushes the logs, then gives each old table the TTL of the log that replaced it. Old tables that already have a TTL and Appwrite's own tables are left alone. Nothing is truncated; ClickHouse deletes expired rows in the background.clickhouse-init.shis committed as executable. On Docker Desktop bind mounts bash's-xcheck reports every file as executable, so the entrypoint executed the non-executable script and ClickHouse exited withbad interpreter: Permission denied. The installer'scopyFiles()now keeps the source file's mode, becausecopy()drops it.Both files ship like
mongo-init.jsandmongo-entrypoint.sh: copied into the image, copied into the install directory by the installer on every install and upgrade, bind-mounted fromdocker-compose.yml, and rewritten to the host path by the compose generator. External ClickHouse deployments are not affected.Test Plan
Ran the
clickhouseservice from thisdocker-compose.yml, with its bind mounts, onclickhouse/clickhouse-server:26.4.3-alpine:<log>_<N>tables, and a restart replaces no tables.query_logand 5-day-old rows intrace_log. The 12 listed logs without a matching TTL were replaced and each<log>_0got its log's TTL (processors_profile_log_0kept its existing 30 days).asynchronous_insert_logalready matched and was not replaced. The old rows were deleted and today's rows remained. A<log>_<N>table with its own 21-day TTL and a table in theappwritedatabase were unchanged.clickhouse-init.shagain and restarting changed nothing.ALTERonly: on a plain volume,ALTER TABLE system.query_log MODIFY TTL ...followed by a restart left a newquery_logwithout a TTL.hostPathfor released and local versions.GeneratorTestpasses, and PHPStan and Pint pass on the changed PHP files. A full installer upgrade was not run.Related PRs and Issues
Checklist