borgbackupserver icon indicating copy to clipboard operation
borgbackupserver copied to clipboard

ClickHouse TSV failed to connect / File catalog browsing is not available

Open bekaha opened this issue 7 months ago • 7 comments

Description

Hi,

with the new update ClichHose is not working and file catalog browsing ist not working.

Error: Catalog import failed: ClickHouse TSV upload failed: Failed to connect to localhost port 8123

Cheers

Steps to Reproduce

Start a backup ...

Installation Type

Docker

BBS Version

v2.28.0

Agent Version (if applicable)

v2.25.0

Agent OS (if applicable)

Ubuntu / Debian

Relevant Logs

Error: Catalog import failed: ClickHouse TSV upload failed: Failed to connect to localhost port 8123

bekaha avatar Apr 17 '26 23:04 bekaha

Workaroud as mentioned here @ #88 does not solve the issue. On my system there ist only one container (bbs) no Clickhouse container. I restarted bbs but connection to Clickhouse is not working.

bekaha avatar Apr 17 '26 23:04 bekaha

Can't reproduce locally — tested fresh v2.28.0 install and an upgrade from v2.27.1 → v2.28.0 reusing the same data volume. ClickHouse starts and binds port 8123 in both cases. ClickHouse version is the same (26.3.9.8) in v2.27.1 and v2.28.0 too, so no upstream version bump is involved.

To narrow this down, please run these from the host and paste the output:

1. Is ClickHouse actually running inside the container?

docker exec <container> sh -c 'pgrep -a clickhouse-server; curl -s http://localhost:8123/ping; echo'

If pgrep returns nothing, ClickHouse crashed during startup. Continue to step 2.

2. What did ClickHouse say when it tried to start?

docker exec <container> tail -200 /var/log/clickhouse-server/clickhouse-server.err.log

This will show the actual reason — usually permission errors, OOM, or config errors.

3. Container resource limits

docker stats --no-stream <container>

ClickHouse needs ~1 GB RAM minimum to start. If your host or container limit is lower, ClickHouse will OOM-kill itself silently.

4. Volume / bind mount type

What does your docker-compose.yml volumes: line look like? Specifically, is /var/bbs a Docker named volume or a bind mount to a host path?

5. What version did you upgrade from?

If it was pre-v2.27.0-beta1 (before the dynamic UID detection landed), there's a chance your existing /var/bbs/clickhouse data dir contents are owned by an old UID that the new container can't write to.


Quick fix if you don't need the existing catalog data:

The catalog can be rebuilt from your borg repos (it's just a search index, not source-of-truth backup data). Resetting it won't lose any backup:

docker compose stop
sudo rm -rf /path/to/your/var/bbs/clickhouse
docker compose start

ClickHouse will reinitialize. After it's running, the next backup will start populating the catalog automatically. If you want to backfill catalogs for existing archives, go to each client → Catalog → Rebuild Catalog.

This is a workaround until we identify the root cause from the diagnostics above.

marcpope avatar Apr 18 '26 05:04 marcpope

Thanks for replying.

Ok, lets narrow down:

### Step 1:

docker exec bbs sh -c 'pgrep -a clickhouse-server; curl -s http://localhost:8123/ping; echo'

shows:

pgrep: pattern that searches for process name longer than 15 characters will result in zero matches Try pgrep -f' option to match against the complete command line.`

so i did a:

docker exec bbs sh -c 'pgrep -fa clickhouse-server; curl -s http://localhost:8123/ping; echo'

which shows:

1142 sh -c pgrep -fa clickhouse-server; curl -s http://localhost:8123/ping; echo As i was not satisfied with this outcome i switched into the container:

docker exec -it <container> /bin/bash

there i did:

root@37205ffb203d:/var/www/html# clickhouse-server

an got this:

`Processing configuration file 'config.xml'. There is no file 'config.xml', will use embedded config. 2026.04.18 09:52:38.308316 [ 1181 ] {} CrashWriter: Sending crash reports is initialized with https://crash.clickhouse.com/ endpoint (anonymized) 2026.04.18 09:52:38.308323 [ 1181 ] {} Application: Sending logical errors is enabled 2026.04.18 09:52:38.308353 [ 1181 ] {} Pipe: Pipe capacity is 1.00 MiB 2026.04.18 09:52:38.438398 [ 1181 ] {} Application: Starting ClickHouse 26.3.9.8 (revision: 54516, git hash: 0d82c1998e3b4d54e110dd8a77a64d247c4bff4a, build id: C7775EA72E670FCAB1173A380CAF57F4CFE62DA1), PID 1181 2026.04.18 09:52:38.438428 [ 1181 ] {} Application: starting up 2026.04.18 09:52:38.438442 [ 1181 ] {} Application: OS name: Linux, version: 6.12.74+deb13+1-amd64, architecture: x86_64 2026.04.18 09:52:38.438618 [ 1181 ] {} Application: Available RAM: 15.62 GiB; logical cores: 12; used cores: 12. 2026.04.18 09:52:38.438660 [ 1181 ] {} Application: Available CPU instruction sets: SSE, SSE2, SSE3, SSSE3, SSE41, SSE42, F16C, POPCNT, BMI1, BMI2, LZCNT, MOVBE, PCLMUL, AES, AVX, FMA, AVX2, AVX512F, AVX512DQ, AVX512IFMA, AVX512CD, AVX512BW, AVX512VL, AVX512VBMI, AVX512VBMI2, AVX512VNNI, AVX512BITALG, AVX512VPOPCNTDQ, AVX512BF16, SHA, ADX, RDRAND, RDSEED, RDTSCP, CLFLUSHOPT, CLWB, XSAVE, OSXSAVE, GFNI, VAES, VPCLMULQDQ 2026.04.18 09:52:38.438884 [ 1181 ] {} Application: It looks like the process has no CAP_IPC_LOCK capability, binary mlock will be disabled. It could happen due to incorrect ClickHouse package installation. You could resolve the problem manually with 'sudo setcap cap_ipc_lock=+ep /usr/bin/clickhouse'. Note that it will not work on 'nosuid' mounted filesystems. 2026.04.18 09:52:38.457491 [ 1181 ] {} CgroupsReader: Will create cgroup reader from '/sys/fs/cgroup/' (cgroups version: v2) 2026.04.18 09:52:38.457723 [ 1181 ] {} AsynchronousMetrics: Will use cgroup reader from '/sys/fs/cgroup/' (cgroups version: v2) 2026.04.18 09:52:38.457834 [ 1181 ] {} AsynchronousMetrics: Scanning /sys/class/thermal 2026.04.18 09:52:38.457873 [ 1181 ] {} AsynchronousMetrics: Scanning /sys/block 2026.04.18 09:52:38.457956 [ 1181 ] {} AsynchronousMetrics: Scanning /sys/devices/system/edac 2026.04.18 09:52:38.457984 [ 1181 ] {} AsynchronousMetrics: Scanning /sys/class/hwmon 2026.04.18 09:52:38.458243 [ 1181 ] {} Application: Shutting down storages. 2026.04.18 09:52:38.458260 [ 1181 ] {} Context: Shutting down named sessions 2026.04.18 09:52:38.458269 [ 1181 ] {} Context: Shutting down object storage queue streaming 2026.04.18 09:52:38.458276 [ 1181 ] {} StreamingStorageRegistry: There are no queue storages to shutdown 2026.04.18 09:52:38.458279 [ 1181 ] {} Context: Shutting down database catalog 2026.04.18 09:52:38.458282 [ 1181 ] {} DatabaseCatalog: Shutting down system logs 2026.04.18 09:52:38.458290 [ 1181 ] {} DatabaseCatalog: Shutting down system databases 2026.04.18 09:52:38.458309 [ 1181 ] {} Context: Shutting down caches 2026.04.18 09:52:38.458315 [ 1181 ] {} Context: Shutting down AccessControl 2026.04.18 09:52:38.458344 [ 1181 ] {} Application: Shut down storages. 2026.04.18 09:52:38.458374 [ 1181 ] {} Application: Destroyed global context. 2026.04.18 09:52:38.458430 [ 1181 ] {} Application: Waiting for background threads 2026.04.18 09:52:38.458436 [ 1181 ] {} Application: Background threads finished in 0 ms 2026.04.18 09:52:38.458775 [ 1181 ] {} Application: Code: 430. DB::Exception: Effective user of the process (root) does not match the owner of the data (www-data). Run under 'sudo -u www-data'. (MISMATCHING_USERS_FOR_PROCESS_AND_DATA), Stack trace (when copying this message, always include the lines below):

  1. DB::Exception::Exception(DB::Exception::MessageMasked&&, int, bool) @ 0x000000001782e22a
  2. DB::Exception::Exception(String&&, int, String, bool) @ 0x000000000faf504e
  3. DB::Exception::Exception(PreformattedMessage&&, int) @ 0x000000000faf4989
  4. DB::Exception::Exception<String&>(int, FormatStringHelperImpl<std::type_identity<String&>::type>, String&) @ 0x000000000fb208b6
  5. DB::assertProcessUserMatchesDataOwner(String const&, std::function<void (PreformattedMessage const&)>) @ 0x00000000179d2d66
  6. DB::Server::main(std::vector<String, std::allocator> const&) @ 0x0000000017bee2d8
  7. Poco::Util::Application::run() @ 0x0000000023cb9971
  8. DB::Server::run() @ 0x0000000017be1cfa
  9. mainEntryClickHouseServer(int, char**) @ 0x0000000017bde709
  10. main @ 0x000000000faec5ea
  11. ? @ 0x0000000000029ca8
  12. __libc_start_main @ 0x0000000000029d65
  13. _start @ 0x0000000009627a2e (version 26.3.9.8 (official build)) 2026.04.18 09:52:38.458788 [ 1181 ] {} Application: shutting down 2026.04.18 09:52:38.458790 [ 1181 ] {} Application: Uninitializing subsystem: Logging Subsystem 2026.04.18 09:52:38.462831 [ 1185 ] {} BaseDaemon: Received signal -2 2026.04.18 09:52:38.462839 [ 1185 ] {} BaseDaemon: Stop SignalListener thread`

--> I think this is a permission problem?

### Step 2:

docker exec <container> tail -200 /var/log/clickhouse-server/clickhouse-server.err.log

shows nothing.

### Step 3:

docker stats --no-stream <container>

shows

CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS 37205ffb203d bbs 1.20% 305.4MiB / 15.62GiB 1.91% 12.1MB / 2.61MB 100MB / 19.8MB 40

### Step 4:

I only use named volumes, my docker-compose.yaml looks like this:

`services: bbs: image: marcpope/borgbackupserver:latest # build: . # uncomment to build locally instead of pulling from Docker Hub container_name: bbs ports: - "${WEB_PORT:-8080}:80" # Web UI - "${SSH_PORT:-2222}:22" # SSH for borg agent connections environment: - APP_URL=${APP_URL:-http://localhost:8080} - SSH_PORT=${SSH_PORT:-2222} # Admin password — only used on first run. Omit to auto-generate (shown in logs). # - ADMIN_PASS=${ADMIN_PASS} volumes: - bbs-data:/var/bbs - bbs-storage-st01:/mnt/bbs-storage-st01 # To store backups on a specific disk or path instead of Docker's internal storage, # replace the line above with a bind mount: # - /mnt/backups:/var/bbs restart: unless-stopped

volumes: bbs-data: # Remove this 'volumes' section entirely if using a bind mount above bbs-storage-st01: driver: local driver_opts: type: nfs o: addr=192.168.10.10,rw,nfsvers=3,nolock device: ":/volume1/BBS-STORAGE"`

### Step 5:

I upgraded from v2.27.0.

Thanks for helping me out and for pointing out the workaround. I think its better to identify the root cause so i'm waiting for your response.

bekaha avatar Apr 18 '26 10:04 bekaha

Hi,

I've been following this discussion and I’d like to share my findings as well, as they might help narrow down the root cause.

I am running BBS in a Docker environment using bind-mounts, while @bekaha is using named volumes. Since we are both seeing the same error, it's possible that the issue is independent of the volume driver or mount type.

In my environment:

  • I first noticed the catalog browsing issue on v2.28.0 and v2.28.1.
  • I tried the suggested downgrade to v2.27.0, but the problem persisted for me.
  • The catalog only became functional again after I downgraded to v2.26.7.

Based on the logs shared above, there might be a regression or a slight conflict in the UID/GID logic introduced in recent versions (perhaps around the v2.27.0-beta changes). It seems the ClickHouse process is struggling to reconcile its effective user with the data ownership on disk, regardless of how the storage is mounted.

I hope this helps in identifying where the issue might be.

erycsonero avatar Apr 18 '26 13:04 erycsonero

Thanks to both of you — the detail made this reproducible. Fix is in 6cddc98 on main (not released yet).

Root cause: /var/bbs/clickhouse/* on your persistent volume is owned by www-data instead of clickhouse. An older image build ran chown -R www-data:www-data /var/bbs at some point, and those ownerships carried forward across container rebuilds. ClickHouse refuses to start when it's asked to run as clickhouse but the data is owned by a different user:

Code: 430. DB::Exception: Effective user of the process (clickhouse) does not match the owner of the data (www-data). (MISMATCHING_USERS_FOR_PROCESS_AND_DATA)

The current entrypoint's ensure_dir only chowns the top-level directory, and the UID migration only triggers when the recorded .ownership file disagrees with env vars, so the filesystem-level mismatch slipped through. The 2>/dev/null on the startup line then hid the error, which is why @bekaha saw nothing in the logs.

What the fix does: on every container start, scan /var/bbs/clickhouse and /var/bbs/mysql with find for any entry owned by the wrong user/group. If found, repair it recursively. On a clean volume the check short-circuits in ~4ms and does nothing. Also stops swallowing ClickHouse's stderr and adds an explicit post-start ping check, so the next time something like this happens the logs will say so.

Immediate workaround (no need to wait for the next release):

docker exec <container> chown -R clickhouse:clickhouse /var/bbs/clickhouse
docker restart <container>

@erycsonero — this explains why 2.26.7 worked for you: before that version's UID changes, clickhouse was running as whatever user owned the data by happenstance; after, it became strict about the mismatch. Same underlying volume state, same fix.

marcpope avatar Apr 18 '26 15:04 marcpope

I applied your immediate workaround. After restarting the docker container catalog rebuilding started immediately. This fixed it for me. Thanks

bekaha avatar Apr 18 '26 15:04 bekaha

Thank you for the quick turnaround and the detailed explanation, @marcpope!

I can confirm that the fix in v2.28.2 works perfectly. Instead of applying the manual workaround, I updated my image tag from :v2.26.7 to :latest (v2.28.2), and the entrypoint successfully repaired the ownership issues on my bind-mount setup.

The file catalog is now fully functional again, and the transition from v2.26.7 to the latest version was seamless. I really appreciate the prompt fix and the improved error logging—it makes the project much more robust for those of us managing larger infrastructures.

Great job!

erycsonero avatar Apr 18 '26 22:04 erycsonero