$ show mariadb-corporation/galera
Galera is a synchronous multi-master replication middleware for transactional databases, primarily MySQL and MariaDB, implemented as a wsrep provider shared library (libgalera_smm.so). The codebase provides total-order multicast group communication via a layered protocol stack (GCS/gcomm), conflict detection through certification of write-sets, incremental state transfer (IST) with a multi-tier cache (gcache), and an arbitrator daemon (garbd) for quorum maintenance. Architecturally, it is structured as a set of cooperating C++ libraries: galerautils (memory allocators, configuration, threading, hashing), gcs (group communication service with membership and flow control), gcomm (transport abstraction with EVS/PC/GMCast protocols), galera (replication engine with certification and write-set handling), and gcache (write-set caching in memory, ring buffer, and memory-mapped pages). The code is well-tested with unit tests (Check framework), regression tests, and integration test scripts. While the core replication logic and utility libraries are well-crafted and modular, the project bundles an older version of the ASIO networking library and retains C++03 compatibility shims, contributing to moderate technical drift. The repository is actively maintained with regular commits and issue triage.
The LLM identified 4 files worth highlighting for reuse:
Provides an Allocator template that uses a reserved buffer (typically stack-allocated) before falling back to heap pages, with optional disk-page fallback. This is a generic, reusable allocation strategy that avoids heap fragmentation in performance-critical paths and can be extracted for any C++ project needing low-overhead, bounded allocation.
Implements a thread-safe key-value configuration system with type checking, suffix parsing (K/M/G/T), flags for deprecation/hidden/read-only, and a registration API. It is self-contained and can be reused in any application needing a flexible, typed configuration manager.
Provides a runtime-dispatched CRC-32C implementation that selects between software variants (Sarwate, slicing-by-4/8) and hardware-accelerated paths (x86 SSE4.2, ARM64 CRC). The interface is simple and self-contained; it can be extracted for any project requiring high-performance integrity checksums.
Implements a segment-aware, fair send queue that partitions outgoing messages by source and uses round-robin to prevent starvation. It is isolated from the rest of gcomm (only depends on standard containers) and can be reused in any networking or scheduling layer needing fair queuing.