---
title: "chDB Kernel Upgrade Journey: Upgrading ClickHouse to v25.8.2.29"
description: "Upgrading chDB's embedded ClickHouse kernel from v25.5 to v25.8.2.29 surfaced allocator conflicts rooted in chDB's dual-library design: a stable-ABI `_chdb.abi3.so` holding the ~120MB engine plus small per-Python-version pybind11 binding libraries."
url: "https://swe.quest/articles/chdb-kernel-upgrade-journey-upgrading-clickhouse-to-v25-8-2-29-3cca5f2ad115d794"
canonical: "https://clickhouse.com/blog/chdb-kernel-update-25.8"
source: "ClickHouse"
published: "2025-11-19"
difficulty: "hard"
kind: "Case study"
reading_minutes: 16
tags: ["memory-management","c-cpp","python","analytics","performance"]
---

# chDB Kernel Upgrade Journey: Upgrading ClickHouse to v25.8.2.29

A post on [ClickHouse](https://swe.quest/sources/clickhouse.md), published 2025-11-19, 16 min read, Case study. Original: [https://clickhouse.com/blog/chdb-kernel-update-25.8](https://clickhouse.com/blog/chdb-kernel-update-25.8)

## Summary

Upgrading chDB's embedded ClickHouse kernel from v25.5 to v25.8.2.29 surfaced allocator conflicts rooted in chDB's dual-library design: a stable-ABI \`\_chdb.abi3.so\` holding the ~120MB engine plus small per-Python-version pybind11 binding libraries. Mixing jemalloc with glibc-allocated memory from Python and third-party libraries causes crashes, so chDB wraps \`free\` and \`operator delete\` with the linker's \`--wrap\` mechanism and uses jemalloc's \`arenas.lookup\` to send each pointer to \`je\_free\` or glibc's \`\_\_real\_free\`. The new ClickHouse version added its own \`\_\_wrap\_free\` for MemoryTracker accounting, so the two were merged into one implementation. The upgrade also exposed a ClickBench Q29 regression in a regex- and string-heavy query that stresses allocation and deallocation.

Written by swe.quest, not by the author.

**Difficulty:** Hard: written for specialists in the field

## Topics

- [Memory management](https://swe.quest/tags/memory-management.md) (Compilers & runtimes)
- [C & C++](https://swe.quest/tags/c-cpp.md) (Languages)
- [Python](https://swe.quest/tags/python.md) (Languages)
- [Analytics & OLAP](https://swe.quest/tags/analytics.md) (Data & databases)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)

## Prerequisites

- C/C++ memory allocators ([easy posts on C & C++](https://swe.quest/tags/c-cpp.md?difficulty=easy))
- dynamic linking and symbols
- Python C extensions ([easy posts on Python](https://swe.quest/tags/python.md?difficulty=easy))
- jemalloc basics

## Keywords

chDB, ClickHouse, jemalloc, pybind11, Python Limited API, ClickBench, glibc

## Related posts

- [chDB - A Rocket Engine on a Bicycle](https://swe.quest/articles/chdb-a-rocket-engine-on-a-bicycle-951148e84c12126b.md): ClickHouse · 2023-09-29 · Hard · 9 min read · Analytics & OLAP, Memory management, C & C++, Python, Performance engineering
  chDB embeds the ClickHouse engine as an in-process Python module instead of shelling out to the 500MB clickhouse-local binary, using WriteBufferFromVector, Python memoryview and Pybind11 for zero-copy result retrieval.
- [A Year of Rust in ClickHouse](https://swe.quest/articles/a-year-of-rust-in-clickhouse-fadc1c7501c80398.md): ClickHouse · 2025-04-01 · Medium · 12 min read · Rust, C & C++, Build systems, Testing, Supply chain security
  ClickHouse added Rust to its C++ codebase as an option for new components rather than a rewrite, starting with BLAKE3, then skim for clickhouse-client history, PRQL as a switchable query dialect, and Databricks' delta-kernel-rs replacing a sketchy C++ Delta Lake implementation.
- [How to use Rust in ClickHouse: avoiding a full rewrite](https://swe.quest/articles/how-to-use-rust-in-clickhouse-avoiding-a-full-rewrite-e470754e07a213d4.md): ClickHouse · 2025-12-17 · Medium · 13 min read · Rust, C & C++, Build systems, Refactoring & migrations, Testing
  ClickHouse, a 1.5M-line C++ analytic database, is adopting Rust incrementally rather than rewriting.
- [The case of the vanishing CPU: A Linux kernel debugging story](https://swe.quest/articles/the-case-of-the-vanishing-cpu-a-linux-kernel-debugging-story-3db1aa1b81ec8319.md): ClickHouse · 2025-03-05 · Hard · 32 min read · Linux, Memory management, Debugging, Performance engineering, Incidents & postmortems
  Intermittent, indefinite CPU saturation of ClickHouse Cloud pods, seen only on GCP, turned out to be a Linux kernel memory-management livelock.
- [Debugging Systems in the Cloud: MySQL, Kubernetes, and Cgroups](https://swe.quest/articles/debugging-systems-in-the-cloud-mysql-kubernetes-and-cgroups-a5ded3f862ca5b21.md): Shopify Engineering · 2021-10-21 · Hard · 8 min read · Debugging, Linux, MySQL, Kubernetes, Performance engineering
  Slow MySQL Pod startup and degraded query performance on long-running GKE nodes in Shopify's KateSQL platform traced back to a Linux kernel memory cgroup leak: roughly 50K zombie memory cgroups made mem\_cgroup\_commit\_charge slow, so each 128MB mmap during InnoDB buffer pool initialization took about 100 ms. The investigation used strace, perf flamegraphs, slabtop and /proc/cgroups, and Google kernel engineers confirmed it as a side effect of slab reparenting on cgroup removal.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
