docs/sources/reference-pyroscope-v2-architecture/components/metastore/index.md
The metastore is the only stateful component in the Pyroscope v2 architecture. It maintains the metadata index for all data objects stored in object storage and coordinates the compaction process.
The metastore service is responsible for:
The metastore uses the Raft protocol for consensus and replication, ensuring:
| Cluster size | Tolerated failures |
|---|---|
| 3 nodes | 1 node |
| 5 nodes | 2 nodes |
Even at large scale, the metastore only needs a few gigabytes of disk space for the metadata index. The index is implemented using BoltDB as the underlying key-value store.
For better performance, the index database can be stored on an in-memory volume, as it's recovered from the Raft log and snapshot on startup. Durable storage is not required for the index itself—only for the Raft log.
The metadata index stores information about data objects (blocks and segments) including:
The index is partitioned by time, with each partition covering a 6-hour window. Within each partition, data is organized by tenant and shard.
For detailed information about the metadata index structure, refer to Metadata index.
The metastore coordinates the compaction process by:
The compaction service uses a lease-based ownership model with fencing tokens to prevent conflicts when workers fail or become unresponsive.
For detailed information about the compaction process, refer to Compaction.
If the metastore is temporarily unavailable, segment writers fall back to writing metadata to a dead letter queue (DLQ) directory in object storage. The metastore recovers these entries in the background once it becomes available again.
The metastore enforces time-based retention policies on a per-tenant basis. Retention operates at the partition level: entire partitions are removed when they exceed the configured retention period, rather than evaluating individual blocks. When partitions are deleted, tombstones are created for the underlying data objects, which are eventually cleaned up by compaction workers.
The metastore provides linearizable reads for query operations, ensuring that:
One metastore instance is elected as the leader through Raft consensus. The leader is responsible for:
Follower replicas can serve read requests, distributing the query load across the cluster.