[30.2] typesense_memory_resident_bytes reports stats.active instead of stats.resident
I maintainer di solito rispondono entro 2 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 75/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- cpp
- Ambito
- backend, observability
Direzione di ricerca
Il bug si trova in src/system_metrics.cpp righe 49-59, dove il valore stats.resident viene letto ma stats.active viene serializzato in modo errato come typesense_memory_resident_bytes. Inizia esaminando quel file e la logica di raccolta delle metriche circostante. Verifica la correzione compilando Typesense, eseguendo lo script di riproduzione fornito e controllando che l'endpoint /metrics.json ora riporti il valore corretto della memoria residente. Assicurati che la modifica compili e che i test esistenti passino.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Bug Description
On Typesense 30.2, GET /metrics.json publishes jemalloc's stats.active as typesense_memory_resident_bytes, even though it separately reads stats.resident.
This reproduces with zero collections and zero documents on the official image. The runtime symptom is identical active/resident values; the 30.2 source assignment establishes why they are identical.
Reproduction Steps
Requirements: Docker, Bash, curl and jq. No Typesense client library, credentials or dataset are needed.
Complete standalone Docker/curl reproduction (GitHub blob) · captured raw responses and environment
curl -fL 'https://raw.githubusercontent.com/colophon-group/jobseek/ba2a4212efdfe8125e3ae33050de72b76afc9b4e/scripts/repro-typesense-resident-metric.sh' \
-o repro-typesense-resident-metric.sh
bash repro-typesense-resident-metric.sh
The script starts a disposable server on a dynamically assigned loopback port, waits for health, verifies /debug reports 30.2 and /collections is empty, then requests /metrics.json three times. It retains the results and removes its own container on exit.
The relevant API call is:
curl -fsS -H 'X-TYPESENSE-API-KEY: repro-key' "$base/metrics.json" |
jq '{typesense_memory_active_bytes, typesense_memory_resident_bytes,
typesense_memory_allocated_bytes, typesense_memory_metadata_bytes}'
Here base is the disposable server's URL, determined by the script.
Expected vs Actual
Expected: typesense_memory_resident_bytes contains the successfully retrieved jemalloc stats.resident value.
Actual: it contains stats.active. Fresh measurements on 30.2:
| Request | active bytes | reported resident bytes | metadata bytes |
|---|---|---|---|
| 1 | 32,698,368 | 32,698,368 | 10,013,632 |
| 2 | 33,005,568 | 33,005,568 | 10,045,504 |
| 3 | 33,320,960 | 33,320,960 | 10,077,632 |
The first response, projected to the relevant fields:
{
"typesense_memory_active_bytes": "32698368",
"typesense_memory_resident_bytes": "32698368",
"typesense_memory_allocated_bytes": "31400368",
"typesense_memory_metadata_bytes": "10013632"
}
Absolute byte counts can vary by machine and run. Equality alone would not identify the cause; the source reads stats.resident into resident on line 51, then serializes active for the resident field on line 59. The apparent assignment correction is:
- result["typesense_memory_resident_bytes"] = std::to_string(active);
+ result["typesense_memory_resident_bytes"] = std::to_string(resident);
A regression test should verify that the response maps to the resident allocator statistic, with successful statistics retrieval, rather than merely asserting that two live measurements differ.
Environment
- Typesense: 30.2, the latest stable release when checked on 2026-09-23;
/debugreturned{"state":1,"version":"30.2"}. - Official image:
typesense/typesense:30.2@sha256:610f2d34b1f93d00762869da2c67736775e5798d19a2c8b91b014b8a0cc1e110. - Server: Linux
6.8.0-64-generic, aarch64; Docker Engine 28.4.0, image architecture arm64. - Client: curl 8.4.0 on macOS, jq 1.8.1; no SDK.
Schema / Configuration
No schema or documents. The official image runs with --data-dir=/tmp --api-key=repro-key, otherwise default server configuration. The key is a public local reproduction value.
Additional Context
The jemalloc documentation distinguishes allocator resident memory from active allocation pages and from operating-system process RSS. This report asks for the allocator statistic already being read; it does not ask for equality with Linux RSS.
The incorrect mapping can mislead memory-capacity and before/after optimization measurements. It is a reporting defect, not evidence of a leak or the cause of an OOM.
Related discussions: #366, #1595. I did not find a dedicated report of this assignment when searching issues and PRs for the metric name and stats.resident.
- Lingua principale
- C++
- Stelle
- 27.1k
- Fork
- 1k
- Merge medio
- 4g 4h
- PR unite (30g)
- 15
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di typesense/typesense
-
Bundled OpenSSL is pinned to 3.0.5, and the 3.0 branch reached end of life on 7 September 2026Forse già presa @mbkkong l’ha presa 40 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 2 giorni
-
Match scoring loop performs a heap allocation per window iteration for every candidate documentApertafeature-request
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 2 giorni
-
[Feature Request] Skip regenerating auto-embeddings on update when the source fields haven't changedApertafeature-request
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 2 giorni
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
typesense/typesense#2932 · 1 reazione ·
I maintainer di solito rispondono entro 2 giorni
-
question
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di typesense/typesense
Issue simili
-
Issue-Bug Needs-Triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
microsoft/winget-cli#6645 ·
I maintainer di solito rispondono entro 2 giorni
-
cleanup help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
ESPresense/ESPresense#2602 ·
I maintainer di solito rispondono entro 1 giorno
-
devex good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno
-
artifact:simulation-scenario domain:physics good first issue help wanted role:validation testing
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 3 giorni