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

# Diagnose common SmithDB issues

> How to find the cause of the SmithDB issues that occur most often in production on self-hosted LangSmith, and what to change.

Use this page when an alert fires or users report a problem. Each issue lists how to find the cause and what to change. For when to alert, see [Recommended SmithDB alerts](https://docs.langchain.com/langsmith/self-host-smithdb-alerts.md). For what each metric measures, see [Essential SmithDB metrics](https://docs.langchain.com/langsmith/self-host-smithdb-metrics.md).

## Start from a symptom

If users report a problem, find the symptom below. Then go to the issue that it links to.

* **Traces appear late after the SDK sends them**: [`langsmith_ingestion_e2e_latency_seconds`](https://docs.langchain.com/langsmith/self-host-smithdb-metrics#langsmith_ingestion_e2e_latency_seconds). See [LangSmith ingestion falls behind](#langsmith-ingestion-falls-behind).
* **Writes fail and keep retrying**: [`langsmith_asynq_ingestion_queue_retry`](https://docs.langchain.com/langsmith/self-host-smithdb-metrics#langsmith_asynq_ingestion_queue_retry). See [Writes to SmithDB fail or are slow](#writes-to-smithdb-fail-or-are-slow).
* **New runs take a long time to become durable in SmithDB**: [`ingest_batch_latency`](https://docs.langchain.com/langsmith/self-host-smithdb-metrics#ingest_batch_latency). See [Writes to SmithDB fail or are slow](#writes-to-smithdb-fail-or-are-slow).
* **SmithDB ingestion backlog grows and does not drain**: [`ingest_pending_segment_entry_count`](https://docs.langchain.com/langsmith/self-host-smithdb-metrics#ingest_pending_segment_entry_count). See [Writes to SmithDB fail or are slow](#writes-to-smithdb-fail-or-are-slow).
* **UI or API reads of traces are slow or fail**: [`server_requests_duration` on query pods](https://docs.langchain.com/langsmith/self-host-smithdb-metrics#server_requests_duration-on-query-pods). See [Compaction falls behind and queries get slow](#compaction-falls-behind-and-queries-get-slow) and [One kind of query load slows down other queries](#one-kind-of-query-load-slows-down-other-queries).
* **Compaction stays behind for hours, or one job kind fails again and again**: [`compaction_queue_job_count`](https://docs.langchain.com/langsmith/self-host-smithdb-metrics#compaction_queue_job_count) and [`compaction_job_completion`](https://docs.langchain.com/langsmith/self-host-smithdb-metrics#compaction_job_completion). See [Compaction falls behind and queries get slow](#compaction-falls-behind-and-queries-get-slow).
* **Ingestion, queries, and compaction are slow at the same time**: PostgreSQL CPU, connections, and storage. See [The metastore runs out of capacity](#the-metastore-runs-out-of-capacity).
* **SmithDB pods restart, crash, or do not start**: See [SmithDB pods are not healthy](#smithdb-pods-are-not-healthy).

## LangSmith ingestion falls behind

LangSmith keeps each new run in Redis until an ingest queue worker writes it to SmithDB. If ingestion cannot keep up, the queue in Redis increases, and users see their runs late. LangSmith deletes run data in Redis after the time set by `config.settings.redisRunsExpirySeconds`, 6 hours by default. Retries do not extend this time. If the queue gets too old, or Redis gets full, LangSmith loses runs.

**Alerts**: [1. Runs are lost](https://docs.langchain.com/langsmith/self-host-smithdb-alerts.md#1-runs-are-lost), [3. The ingestion backlog gets old](https://docs.langchain.com/langsmith/self-host-smithdb-alerts.md#3-the-ingestion-backlog-gets-old), [4. Redis is almost full](https://docs.langchain.com/langsmith/self-host-smithdb-alerts.md#4-redis-is-almost-full).

### Find the cause of the backlog

| What you see | Cause |
| - | - |
| The pending queue and [`langsmith_ingestion_api_to_worker_latency_seconds`](https://docs.langchain.com/langsmith/self-host-smithdb-metrics#langsmith_ingestion_api_to_worker_latency_seconds) increase. Retries and [`langsmith_ingestion_worker_to_store_latency_seconds`](https://docs.langchain.com/langsmith/self-host-smithdb-metrics#langsmith_ingestion_worker_to_store_latency_seconds) stay stable. | There are not enough ingest queue workers. |
| Retries or `langsmith_ingestion_worker_to_store_latency_seconds` increase. | Writes are slow or fail. See [Writes to SmithDB fail or are slow](#writes-to-smithdb-fail-or-are-slow). |
| Redis memory is near its limit, or Redis evicts keys. | Redis is too small for the backlog. |
| One Redis shard uses much more CPU than the others. | The queue load is on one shard. More workers add more connections to that shard. |

### Reduce the backlog

* **Scale ingest queue workers on the queue length.** The workers mostly wait for the network, so their CPU stays low while the queue increases. An autoscaler that uses CPU does not add workers. Enable [KEDA for the ingest queue](https://docs.langchain.com/langsmith/self-host-scale.md#keda-autoscaling-for-langsmith-queues), which scales on the queue length. If a NetworkPolicy limits traffic in the namespace, make sure that KEDA can still read the queue length. If it cannot, KEDA does not scale the workers, and it does not show an error.
* **Set the maximum replica count from your peak load.** The chart's default maximum is a starting point, not a value for your load. Each worker opens connections to Redis, so increase the maximum in small steps and monitor the CPU of the busiest Redis shard.
* **Size Redis for the backlog.** Redis must hold all pending runs until the workers write them, including while writes are slow. If its memory gets near the limit, or it evicts keys, increase its memory.

## Writes to SmithDB fail or are slow

SmithDB ingestion writes runs to object storage as segments and records the metadata of each segment in the metastore. A write is durable only when both steps succeed. If writes fail, LangSmith tries them again from Redis, and the ingestion backlog increases.

**Alerts**: [5. Writes fail](https://docs.langchain.com/langsmith/self-host-smithdb-alerts.md#5-writes-fail), [8. Writes are slow](https://docs.langchain.com/langsmith/self-host-smithdb-alerts.md#8-writes-are-slow).

| What you see | Cause |
| - | - |
| [`ingest_flush_count`](https://docs.langchain.com/langsmith/self-host-smithdb-metrics#ingest_flush_count) shows failures, and [`object_store_op_duration`](https://docs.langchain.com/langsmith/self-host-smithdb-metrics#object_store_op_duration) shows `put` errors. | Object storage rejects writes. Examine the bucket, its access permissions, and the network to it. |
| The `put` latency of `object_store_op_duration` increases together with [`ingest_batch_latency`](https://docs.langchain.com/langsmith/self-host-smithdb-metrics#ingest_batch_latency). | Object storage, or the network to it, is slow. |
| [`ingest_flush_duration`](https://docs.langchain.com/langsmith/self-host-smithdb-metrics#ingest_flush_duration) increases, but object storage stays fast. | The metastore is slow. See [The metastore runs out of capacity](#the-metastore-runs-out-of-capacity). |
| The [flush semaphores](https://docs.langchain.com/langsmith/self-host-smithdb-metrics.md#semaphore_permits_in_use-semaphore_max_permits) are full, or the ingestion pods are CPU throttled. | Ingestion pods are too small for the load. Add replicas, or select a larger [tier](https://docs.langchain.com/langsmith/self-host-smithdb-scale.md#baseline-tiers). |
| Ingestion pods restart. | Requests that a pod holds fail when it restarts. See [SmithDB pods are not healthy](#smithdb-pods-are-not-healthy). |
| LangSmith retries increase, but ingestion pods report no failed requests. | The ingest queue cannot connect to SmithDB. Search the ingest queue logs for `Unavailable` errors, and examine all proxies and service meshes between them. |

## The metastore runs out of capacity

The metastore is the PostgreSQL database of SmithDB. SmithDB records the metadata of each segment that it writes in the metastore. The metastore also holds new feedback until compaction moves it. A slow metastore makes ingestion, queries, and compaction slow at the same time. When there are no more connections or no more storage, writes fail.

**Alert**: [7. The metastore is saturated](https://docs.langchain.com/langsmith/self-host-smithdb-alerts.md#7-the-metastore-is-saturated).

| What you see | Cause |
| - | - |
| Connections are near `max_connections`. | Each SmithDB pod has its own connection pool, so more replicas use more connections. Increase `max_connections`, or add a connection pooler. |
| CPU stays high. | Find slow queries in your database monitoring. Then scale the instance. |
| Storage is almost full. | Increase the storage, unless storage on Aurora or AlloyDB increases automatically. |

To size the metastore, see [Metastore capacity](https://docs.langchain.com/langsmith/self-host-smithdb-scale.md#metastore-capacity).

## Compaction falls behind and queries get slow

SmithDB ingestion writes many small segments. Compaction merges them into fewer, larger segments. If compaction falls behind, each query must open more segments. Queries then get slow, time out, or SmithDB rejects them.

**Alerts**: [6. Queries fail](https://docs.langchain.com/langsmith/self-host-smithdb-alerts.md#6-queries-fail), [9. Queries are slow](https://docs.langchain.com/langsmith/self-host-smithdb-alerts.md#9-queries-are-slow), [10. Compaction falls behind](https://docs.langchain.com/langsmith/self-host-smithdb-alerts.md#10-compaction-falls-behind), [11. Compaction stops or fails](https://docs.langchain.com/langsmith/self-host-smithdb-alerts.md#11-compaction-stops-or-fails).

### Find the cause of late compaction

| What you see | Cause |
| - | - |
| Pending jobs increase, and the compaction workers are at their maximum replica count. | There are not enough compaction workers. |
| Most workers stay near their [capacity limit](https://docs.langchain.com/langsmith/self-host-smithdb-metrics.md#compaction_worker_capacity_used-compaction_worker_capacity_limit), and the [oldest pending job](https://docs.langchain.com/langsmith/self-host-smithdb-metrics.md#compaction_queue_oldest_pending_created_at_seconds) gets older. | Large jobs wait for a worker with sufficient free capacity. The workers need more memory. |
| One job kind fails again and again in [`compaction_job_completion`](https://docs.langchain.com/langsmith/self-host-smithdb-metrics#compaction_job_completion), and compaction workers are OOM-killed. | The jobs of that kind are too large for the worker memory. Search the compaction worker logs for `Job failed` and the `job_kind`. |
| Jobs wait, but [`compaction_worker_running_tasks`](https://docs.langchain.com/langsmith/self-host-smithdb-metrics#compaction_worker_running_tasks) stays 0. | The workers do not run, or they cannot connect to the compaction scheduler. Examine the worker pods and the scheduler pod for restarts. |

### Find the cause of slow or failed queries

Queries can also get slow or fail for other reasons. Before you scale compaction, compare these signals:

| What you see | Cause |
| - | - |
| [Scan partitions](https://docs.langchain.com/langsmith/self-host-smithdb-metrics.md#query_fanout_partitions) and pending compaction jobs increase. | Compaction is late. |
| [`query_fanout_limit_exceeded_total`](https://docs.langchain.com/langsmith/self-host-smithdb-metrics#query_fanout_limit_exceeded_total) increases. | Queries must open more than 10,000 scan partitions. Compaction is late, or clients query very wide time ranges. |
| The [admission queue](https://docs.langchain.com/langsmith/self-host-smithdb-metrics.md#query_admission_queue_length) is not empty, it [rejects requests](https://docs.langchain.com/langsmith/self-host-smithdb-metrics.md#query_admission_queue_rejections_total), or query pods are OOM-killed. | Query pods do not have enough memory. See [One kind of query load slows down other queries](#one-kind-of-query-load-slows-down-other-queries). |
| SmithDB rejects queries (`status` `8`), but neither rejection counter above increases. | One query needs more memory than one operation can use. Split the failures by `path` to find the request type before you increase the limit. |
| [`object_store_op_duration`](https://docs.langchain.com/langsmith/self-host-smithdb-metrics#object_store_op_duration) increases on all components at the same time. | Object storage, or the network to it, is slow. |
| Query pods restart. | Requests that a pod holds fail when it restarts. See [SmithDB pods are not healthy](#smithdb-pods-are-not-healthy). |
| Only some requests are slow, and they cover a wide time range. | The queries read too much data. |

### Help compaction keep up

* **Add compaction workers.** By default, the autoscaler scales compaction workers on CPU, not on pending jobs. To scale on pending jobs, see [Scale with KEDA instead](https://docs.langchain.com/langsmith/self-host-smithdb-scale.md#scale-with-keda-instead). If the workers are at their maximum replica count, increase the maximum.
* **Give compaction workers more memory** if they are OOM-killed, or if most of them stay near their capacity limit. Worker capacity is 80% of the pod memory limit, so more memory lets larger jobs run. Select a larger [tier](https://docs.langchain.com/langsmith/self-host-smithdb-scale.md#baseline-tiers) or set the resources of the compaction worker.
* **Limit the time range of queries.** Scripts and API clients that query without a start time make SmithDB read data from all days.
* **Use time-based trace IDs.** If your application sets its own run or trace IDs, use UUIDv7 values. SmithDB uses the time in the ID to find the data of a trace. Random IDs, such as UUIDv4, make queries and deletes read much more data.

## One kind of query load slows down other queries

In cluster mode, the query service serves all SmithDB reads. A heavy load of one kind, such as run statistics on a large project, can slow down all other queries. [Dedicated query services](https://docs.langchain.com/langsmith/self-host-smithdb-scale.md#dedicated-query-services) move one kind of load to its own pods, so you can size and scale it separately.

**Alert**: [2. Feedback is lost](https://docs.langchain.com/langsmith/self-host-smithdb-alerts.md#2-feedback-is-lost).

For large deployments, such as the large [tier](https://docs.langchain.com/langsmith/self-host-smithdb-scale.md#baseline-tiers), enable the dedicated query services. Each service needs its own replicas, with the resources of the query tier.

For smaller deployments, enable a service when you see its signals in the following table. To find which kind of request uses the query pods, split [`server_requests_duration` on query pods](https://docs.langchain.com/langsmith/self-host-smithdb-metrics#server_requests_duration-on-query-pods) by `path`.

| Service | Enable it when |
| - | - |
| Stats query | Project pages and dashboards load slowly, and other queries get slow at the same time. Query pods run out of memory, or SmithDB rejects queries with [`query_fanout_limit_exceeded_total`](https://docs.langchain.com/langsmith/self-host-smithdb-metrics#query_fanout_limit_exceeded_total), when users open projects with many runs or long time ranges. |
| Mutations | Feedback and run deletions fail or are late while query pods are under load. Ingest queue logs show `IngestFeedback` errors with code `Unavailable`. Without this service, feedback writes and deletions run on the query pods. When those pods restart, feedback writes also fail. |
| Run rules | You have many automation rules or online evaluators, and query latency increases when the rules run. Rule queries that time out are tried again, which adds load to SmithDB and to the LangSmith PostgreSQL database. |

Query pods often use all their memory while their CPU stays low. An autoscaler that uses CPU does not add replicas in this case. Set a minimum replica count that holds your normal load, or give the pods more memory.

## SmithDB pods are not healthy

A SmithDB pod that restarts stops its work in progress: writes, queries, and compaction jobs. A component without available pods sends no metrics, so the alerts that use its metrics do not fire.

**Alerts**: [12. A component has no pods](https://docs.langchain.com/langsmith/self-host-smithdb-alerts.md#12-a-component-has-no-pods), [13. Pods restart often](https://docs.langchain.com/langsmith/self-host-smithdb-alerts.md#13-pods-restart-often), [14. SmithDB panics](https://docs.langchain.com/langsmith/self-host-smithdb-alerts.md#14-smithdb-panics).

Run `kubectl describe pod <pod>`, and read the logs of the previous container with `kubectl logs -p <pod>`. Then compare with this table:

| What you see | Cause |
| - | - |
| `Last State` is `OOMKilled`. | The memory limit is too low for the load. Increase the memory of that component, or select a larger [tier](https://docs.langchain.com/langsmith/self-host-smithdb-scale.md#baseline-tiers). Compare [`sys_jemalloc_resident_bytes`](https://docs.langchain.com/langsmith/self-host-smithdb-metrics#sys_jemalloc_resident_bytes) with the limit. |
| The pod stays `Pending`. | Kubernetes cannot schedule it. The CPU, memory, or storage requests do not fit on a node. |
| The pod runs, but its readiness probe fails. | The SmithDB process does not answer its health check in time. The health check tests only that the process answers. Read the logs of the pod, and examine its CPU and memory use. |
| The pod cannot pull its image. | The cluster cannot reach the image registry, or it has no access to it. |
| The pod crashes when it starts, and its logs show refused metastore connections or denied object storage access. | The connection to the supporting infrastructure fails. See [Supporting infrastructure](https://docs.langchain.com/langsmith/self-host-smithdb-troubleshooting.md#supporting-infrastructure). |
| SmithDB logs a line with a `backtrace` field, or a line that contains `thread panicked`. | A panic: an internal SmithDB defect. |

***

[Connect these docs](https://docs.langchain.com/use-these-docs.md) to your agent of choice via MCP for real-time answers.

[Edit this page on GitHub](https://github.com/langchain-ai/docs/edit/main/src/langsmith/self-host-smithdb-common-issues.mdx) or [file an issue](https://github.com/langchain-ai/docs/issues/new/choose).
