DEV Community

Franck Pachot for YugabyteDB

Posted on Edited on

Native GLIBC instead of Linuxbrew since 2.21

TL;DR: Compiling PostgreSQL extensions is much easier in YugabyteDB versions 2.21 and above, as native OS libraries are used.


YugabyteDB initially used Linuxbrew to create a consistent, portable build environment across various Linux distributions. Linuxbrew allowed the bundling of dependencies like GCC and Glibc, ensuring controlled builds across systems, including non-Glibc-based ones. This approach simplified dependency management and testing by allowing complete control over the build environment.

However, several challenges arose with Linuxbrew, like performance overhead (relying on outdated libraries), compatibility issues (especially when compiling PostgreSQL extensions to run on yugabyteDB), and maintenance complexity.

YugabyteDB used Linuxbrew only for x86_64 builds, but aarch64 used native OS libraries. Starting with version 2.21, YugabyteDB transitioned to native libraries for all builds.

Here are the supported Operating Systems:

Operating system support | YugabyteDB Docs

Operating systems supported by YugabyteDB and YugabyteDB Anywhere.

favicon docs.yugabyte.com

Here is how to see the difference by running dd on two x86_64 images.

Version 2.19 used linuxbrew:

-bash-4.2# docker run --rm -it yugabytedb/yugabyte:2.19.3.0-b140 \
           ldd /home/yugabyte/bin/yb-tserver

        linux-vdso.so.1 (0x00007ffcbfb98000)
        librt.so.1 => /home/yugabyte/linuxbrew/lib/librt.so.1 (0x00007f5c9d7a5000)
        libresolv.so.2 => /home/yugabyte/linuxbrew/lib/libresolv.so.2 (0x00007f5c9d58d000)
        libm.so.6 => /home/yugabyte/linuxbrew/lib/libm.so.6 (0x00007f5c9d288000)
        libc.so.6 => /home/yugabyte/linuxbrew/lib/libc.so.6 (0x00007f5c9c8e7000)
        /home/yugabyte/lib/ld.so => /lib64/ld-linux-x86-64.so.2 (0x00007f5cb9a47000)
        libpthread.so.0 => /home/yugabyte/linuxbrew/lib/libpthread.so.0 (0x00007f5c9c6c8000)
        libdl.so.2 => /home/yugabyte/linuxbrew/lib/libdl.so.2 (0x00007f5c9c4c3000)

Enter fullscreen mode Exit fullscreen mode

Version 2.23 uses native libraries from (AlmaLinux 8 used for this image) :

-bash-4.2# docker run --rm -it yugabytedb/yugabyte:2.23.0.0-b710 \
           ldd /home/yugabyte/bin/yb-tserver

        linux-vdso.so.1 (0x00007ffcea370000)
        librt.so.1 => /lib64/librt.so.1 (0x00007f4a4f00d000)
        libresolv.so.2 => /lib64/libresolv.so.2 (0x00007f4a4edf5000)
        libm.so.6 => /lib64/libm.so.6 (0x00007f4a4ea73000)
        libc.so.6 => /lib64/libc.so.6 (0x00007f4a4e69d000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f4a54f53000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f4a4e47d000)
        libdl.so.2 => /lib64/libdl.so.2 (0x00007f4a4e279000)
Enter fullscreen mode Exit fullscreen mode

The image is slightly smaller (you can strip the executables if the image size matters, but then you will not have all debug symbols to troubleshoot errors):

-bash-4.2# docker image ls
REPOSITORY            TAG             IMAGE ID       CREATED         SIZE
yugabytedb/yugabyte   2.23.0.0-b710   254a05710594   4 weeks ago     2.1GB
yugabytedb/yugabyte   2.19.3.0-b140   9474f15f0653   11 months ago   2.28GB
Enter fullscreen mode Exit fullscreen mode

Here is how to check the version of GLIBC (GNU libc):

-bash-4.2# docker run --rm -it yugabytedb/yugabyte:2.23.0.0-b710 \
           ldd --version

ldd (GNU libc) 2.28
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.

Enter fullscreen mode Exit fullscreen mode

YugabyteDB uses the native GLIBC libraries, so Yugabyte will validate the collations that depend on it. Most use 'libicu', but here are the collations provided by GLIBC:

yugabyte=# select collname from pg_collation 
           where collprovider = 'c';

  collname
------------
 C
 POSIX
 ucs_basic
 en_US.utf8
 en_US
Enter fullscreen mode Exit fullscreen mode

Jeremy Schneider has built an excellent tool to validate this:

Collation Changes Across Linux Versions

flowchart TD
    A["Table with 25 million strings"] --> B["SELECT ... ORDER BY d1 COLLATE {locale}"]
    B --> C["md5(string_agg(...))"]
Loading

Summary Results

This README shows how PostgreSQL sorts the same 25 million strings with a particular collation implementation and OS or ICU version. The checksum is a compact fingerprint of the complete sorted result: matching checksums indicate the same ordering, while a changed checksum means that at least one string moved. Only the final six checksum characters are shown in each cell, with the same value used as its badge color. This matters because PostgreSQL ORDER BY, indexes, and other comparisons can depend on the collation supplied by the OS or ICU; the tables make changes in that behavior visible across versions.

If PostgreSQL data files are moved to a different operating system (or the base container used to build PostgreSQL is changed) without rebuilding…

Top comments (0)