> ## Documentation Index
> Fetch the complete documentation index at: https://docs.magpiedb.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Magpie is a trace store for AI agents, used as a library (crate `magpiedb`, npm `magpiedb`, PyPI `magpiedb`) or as `magpie-server`, which takes OpenTelemetry (OTLP over HTTP on 127.0.0.1:4318 and gRPC on 127.0.0.1:4317 by default).
> Use only the commands, flags, routes and JSON shapes that these pages show. Do not guess a flag or a query field: if a page does not show it, say that the docs do not show it.
> Install the library with `cargo add magpiedb`, `npm install magpiedb` or `pip install magpiedb`. Get the server from the GitHub Releases download or the Docker image `ghcr.io/intojhanurag/magpie-server`, as the quick start shows.
> Only one process may write to a store folder at a time. For many apps, send traces to one `magpie-server`.
> `magpie-server doctor` checks a running server. An AI agent can query the traces over MCP at `/mcp` on the HTTP port (page guides/mcp).

# When the disk is full

> What magpie-server does when the volume of its store fills up, how to see it, and how to make room.

```sh theme={null}
curl -s localhost:4318/healthz    # status 503 while new data is refused
```

```text theme={null}
writes are refused: the disk is nearly full
```

Every store keeps a reserve of free space on its volume: `--min-free-mb`. The default is 5% of the volume, at least 16 MiB and at most 1 GiB.

Under it, the server refuses new spans and scores before the disk is full. Everything else goes on, and writes start again by themselves when there is room.

## See it

| where | what you see |
| - | - |
| a write of spans or scores | `503` (gRPC `UNAVAILABLE`), with a text that starts with `io: DISK_FULL:`. Nothing of the request is stored, and OTLP clients send it again. |
| `GET /healthz` | `503` with `writes are refused: the disk is nearly full`, and `200 ok` again after. A load balancer can send exports elsewhere. |
| the log | One line when the state changes, not one per request: `the disk is nearly full: ... New spans and scores are refused (503)`, then `there is room on the disk again: writes are taken again.` |

Queries, `POST /v1/traces/delete`, `POST /v1/purge`, `--retention`, commits and a restart go on: the reserve is the room for them. A write is refused while the free space is under the reserve plus the room that the accepted spans still need for their commit.

A merge in the background starts only when there is room for its output too. While one runs on a nearly full volume, new data can be refused until it ends.

## Make room

| way | how |
| - | - |
| free space on the volume | A bigger volume, or delete other files. |
| drop old data | `--retention` drops whole old files with no rewrite: the cheap way ([Retention](https://docs.magpiedb.com/operations/data-lifecycle.md)). |
| delete, then purge | The purge writes again the files that hold deleted spans, so it needs room for the spans that stay in them. Delete the oldest traces: their files go whole. A purge with no room fails with its own error and changes nothing. |

The next write passes when there is room. No restart is needed.

> [accordion] The store cannot write at all
>
> Another program filled the volume, `--min-free-mb` is `0`, or the disk had an error. Then `/healthz` says `writes are refused: the store cannot write`, the log says why, writes get `503`, and queries answer from the last commit.
>
> The server opens the store again by itself, as a restart does. It needs room on the volume for two times the write log, and the reserve.
>
> It tries at once, then with a wait that doubles from 1 s to 30 s. Until then the store is open read-only.
>
> No accepted write is lost: one that got `200` is in the write log, and the open applies it. With tenants, a tenant's store opens again at the next request for it.

> [accordion] The server starts on a full disk
>
> When the volume has no room to open the store for writing, the server starts read-only and says so in its log. It opens the store for writing by itself when there is room.
>
> A store that stopped between its two commits opens only for writing, which needs a little room. On a volume with not one block free, the server starts with no store. Every request gets a `503` that says why, and the server opens the store when there is room.
>
> A store that does not open for another reason (another server on it, a damaged store, another format) stops the start.

> [!WARNING]
>
> The reserve is free space, not a file: another program on the same volume can take it. Give the store its own volume. A server with `--s3` as the writer is not opened again by itself after its writer failed: restart it.

Free space is read with `statvfs`. On a system without it, and on a volume that reports no size (some network and FUSE file systems), there is no reserve. Tested on macOS with APFS disk images (`tests/disk_full.rs`), not on Linux.

> [card] [Retention](https://docs.magpiedb.com/operations/data-lifecycle.md)
>
> Drop old spans by themselves.

> [card] [Errors, memory and threads](https://docs.magpiedb.com/operations/errors-memory.md)
>
> What each error means.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.