CodeVetter
← All unpacks
CodeVetter · Repo Unpack evidence

redis/redis

Scanned commit c3215f019a dated 2026-09-22 — last upstream commit. Generated by codevetter 1.12.0 on 2026-09-22.

github.com/redis/redis ↗ · 1866 files · 20.8 MB

This document serves as both a quick start guide to Redis and a detailed resource for building it from source.

Deep analysis by claude-opus-5 via the claude CLI on 2026-09-22 (476s) — every claim below links to its cited source files.

Overview

This is the Redis Open Source server (`src/version.h` reports 8.9.241, branch `unstable`) — a single-process, event-loop-driven in-memory data structure server written in C99/gnu11, plus its CLI, benchmark, sentinel, and RDB/AOF checking tools. Beyond upstream Redis it carries a substantial in-tree feature layer: a new `OBJ_ARRAY` sparse-array type (`src/t_array.c`, `src/sparsearray.c`), key eviction protection (`src/bless.c`), CuckooHeavyKeeper hot-key tracking (`src/chk.c`, `src/hotkeys.c`), atomic cluster slot migration (`src/cluster_asm.c`), zstd replication/client compression (`src/client_comp.c`), and multi-threaded IO (`src/iothread.c`). It also ships a bespoke top-level Makefile + `scripts/` orchestration layer that clones, builds, deploys, and tests four external Redis modules (RediSearch, RedisJSON, RedisBloom, RedisTimeSeries) pinned by `modules/modules.yaml`, which upstream Redis does not have.

System map

The runtime is one `redis-server` binary whose `main()` in `src/server.c` initializes config, ACL, the module system and connection types, then hands control to the `ae` event loop (`aeMain`). The same binary multiplexes into sentinel, `redis-check-rdb` and `redis-check-aof` modes by argv[0] inspection. Storage is entirely in-process (`kvstore`/`dict`/`listpack`/`quicklist`/`rax`/`ebuckets`), persisted by RDB snapshot and/or AOF manifest, and replicated over a custom PSYNC protocol. Build is GNU Make: `src/Makefile` compiles the core and vendored `deps/`, while the top-level `Makefile` delegates to `scripts/*.sh` for the module-bundle workflow. Deployment shape is a bare binary + `redis.conf` (or the generated `redis-full.conf`), with an Ubuntu 24.04 build image in `docker/Dockerfile.noble`.

All 14 system map claims →

Feature catalog

User-facing surface is the RESP command set — 464 JSON command specs under `src/commands/` compiled into the 13k-line `src/commands.def`. Alongside the classic types (string/list/set/zset/hash/stream/HLL/geo/bitmap) this tree adds a first-class array type (AR* commands), key-blessing (BLESS), hot-key tracking (HOTKEYS), INCREX, hash-field expiration (HEXPIRE family), and a compiled-out GCRA rate limiter. Administrative surface spans ACL, CLIENT, CLUSTER (including atomic slot migration), CONFIG, FUNCTION, DEBUG, and the Sentinel command set. Client-side tooling ships as `redis-cli` (with a full cluster manager and ~60 flags), `redis-benchmark`, and the two check tools.

All 15 feature catalog claims →

Data flow

Input arrives on a connection abstraction (`connection.h` over socket/unix/TLS), is read into a per-client or thread-reusable query buffer by `readQueryFromClient()`, parsed into `pendingCommand` structs by `processInlineBuffer()`/`processMultibulkBuffer()`, dispatched by `processCommand()` and executed by `call()`. Command handlers mutate the authoritative state owner — `server.db[j]` kvstores — and any side effects are queued through `alsoPropagate()`. At the end of the execution unit `propagateNow()` fans out to exactly three sinks: the AOF buffer, the replica stream, and the atomic-slot-migration client. Replies accumulate in per-client output buffers and are flushed in `beforeSleep()` by `handleClientsWithPendingWrites()`, strictly after `flushAppendOnlyFile()` so `appendfsync=always` is honoured before acknowledgement.

All 15 data flow claims →

Behavior traces

Three flows dominate. Startup: `main()` → config → subsystem init → `initServer()` → `InitServerLast()` → `loadDataFromDisk()` → AOF reconciliation → `aeMain()`. Command execution: socket readable → `readQueryFromClient()` → `processInputBuffer()` → `processCommandAndResetClient()` → `processCommand()` → `call()` → handler → `alsoPropagate()` → `propagatePendingCommands()` → `propagateNow()`. Replica bootstrap: `replicaofCommand()` → `replicationSetMaster()` → `connectWithMaster()` → `syncWithMaster()` handshake → `slaveTryPartialResynchronization()` → full sync via `readSyncBulkPayload()`, with the master side running `syncCommand()` → `startBgsaveForReplication()` → `rdbSaveToSlavesSockets()`.

All 17 behavior traces claims →

Testing signals

Testing is a Tcl integration suite: `tests/test_helper.tcl` globs `tests/{unit,unit/type,unit/moduleapi,unit/cluster,integration}/*.tcl` into `::all_tests` and runs them against real spawned `redis-server` processes on ports from 21111. There are no C-level unit test files, but the binary embeds a `REDIS_TEST` mode invoked as `redis-server test <name>|all` for data-structure self-tests. Module API coverage is unusually deep — 48 C test modules under `tests/modules/` paired with 48 `unit/moduleapi/*.tcl` suites. CI runs eight build matrices plus an ASAN build and a commands.def drift check, with lcov/Codecov, CodeQL, Coverity, and a reply-schema linter on separate workflows.

All 16 testing signals claims →

Risk map

The dominant risk class is memory-safety in hand-written C parsing code reachable pre-authentication: the RESP parser, the cluster bus packet decoder, and the RDB/DUMP loader all consume untrusted bytes. Authentication is layered and easy to misconfigure — protected-mode, ACL, an auto-generated cluster internal secret, and module-supplied auth callbacks. A second class is coupling risk: the propagation invariants in `call()`/`propagateNow()`, the ordering contract inside `beforeSleep()`, and the object-type registration checklist all fail silently or assert if a contributor misses a step. Finally, there is genuinely dead code — GCRA is compiled out and its test file is `if 0`'d — and a large `DEBUG` surface with 50+ subcommands guarded only by a config flag.

All 17 risk map claims →

Extension points

Redis has four first-class extension mechanisms. New commands are added declaratively: drop a JSON spec in `src/commands/`, implement the proc, and regenerate `src/commands.def`. New configuration parameters are appended to the `static_configs[]` table in `src/config.c` using the `create*Config` macro family. New runtime behaviour is added out-of-process via the module API (`RM_CreateCommand`/`RM_CreateSubcommand` plus data types, filters, and hooks). New scripting languages plug into `functionsRegisterEngine()`. On top of these, this tree adds a fifth: `modules/modules.yaml` as a declarative registry for bundled external modules.

All 16 extension points claims →

Contributor handoff

Read `src/server.h` (the 4,976-line master header that every `.c` file includes) and `src/server.c` before touching anything — nearly all global state hangs off the `server` struct declared there. Never hand-edit `src/commands.def`; edit the JSON spec and regenerate. Prefer adding config via the `static_configs[]` table and features via the module API over touching the dispatch path. Build with `make REDIS_CFLAGS='-Werror'` to match CI, and validate with `./runtest --tags -slow` plus `./runtest-moduleapi` if you touched `src/module.c`. Be aware this tree's root `Makefile` is not upstream's: plain `make` runs `scripts/build.sh`, which builds `src/` and then every cloned external module.

All 16 contributor handoff claims →

Languages

LanguageFilesShare of source
C78882%
JSON465docs/config
Shell839%
Python485%
Markdown27docs/config
YAML22docs/config
Lua202%
Ruby91%

Start reading here

Probable source entrypoint: src/ — inferred from the directory tree and manifest, not the upstream docs.

Source roots

src/ (693 files)

Repository structure

Top-level pathFiles
deps/707
src/693
tests/306
modules/66
utils/40
.github/16
scripts/13
tools/1

Docs found: CONTRIBUTING.mdREADME.md

CI & config entrypoints

Structural health signals

Average score 7.9/10 across 23 analyzed source files; 3 hotspots surfaced.

These are deterministic review leads — size, churn, and structural signals — not proof of a bug in this project.

Recent history