TestMetricTxnAborts is racy: baseline fetchMetrics is not retried while the assertion is
Los mantenedores suelen responder en 10 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 82/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Tranquilo
- Stack tecnológico
- go
- Área
- testing-qa
Línea de trabajo
Empieza en dgraph/cmd/alpha/metrics_test.go, en TestMetricTxnAborts, y compara su llamada baseline a fetchMetrics con retryableFetchMetrics. Comprueba los casos relacionados TestMetricTxnCommits y TestMetricTxnDiscards para ver si siguen el mismo patrón. El trabajo estará terminado cuando la línea base de métricas tolere la exportación asíncrona y las pruebas afectadas pasen sin la condición de carrera por métrica ausente.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Summary
TestMetricTxnAborts reads its baseline metric value with an unretried fetchMetrics, while the assertion that follows uses retryableFetchMetrics. Prometheus metric export is asynchronous, so the baseline read can land before dgraph_txn_aborts_total has been published and the test fails with a message that reads like a missing metric rather than a race.
The code
dgraph/cmd/alpha/metrics_test.go:
func TestMetricTxnAborts(t *testing.T) {
metricName := "dgraph_txn_aborts_total"
...
require.NoError(t, commitWithTs(mr1, false))
require.Error(t, commitWithTs(mr2, false))
metrics := fetchMetrics(t, metricName) // <-- not retried
... second round of mutations ...
require.NoError(t, retryableFetchMetrics(t, map[string]int{
metricName: metrics[metricName] + 1, // <-- retried
}))
}
The asymmetry looks unintentional: the same value is fetched twice, once without tolerance for propagation delay and once with.
Note also that dgraph_txn_aborts_total does not exist on the /metrics endpoint until the first abort is actually exported, so on a fresh cluster the baseline read is the most likely of the two to race — it is the one that has to wait for the counter to appear at all, not merely to increment.
Observed failure
--- FAIL: TestMetricTxnAborts (0.02s)
metrics_test.go:153: the required metric 'dgraph_txn_aborts_total' was not found
Line 153 is inside fetchMetrics, reached from the unretried call. It passes on re-run, which is consistent with a propagation race rather than a functional problem. The preceding require.Error(t, commitWithTs(mr2, false)) passes, so the aborting commit did happen.
Seen once in CI on a fork of this repo; green on re-run of the same commit.
Suggested fix
Use the retrying variant for the baseline too, so the test tolerates propagation in both reads:
require.NoError(t, retryableFetchMetrics(t, map[string]int{metricName: 1}))
metrics := fetchMetrics(t, metricName)
Or have fetchMetrics treat "metric absent" as retryable when the caller is establishing a baseline. Either way the intent is that the test waits for the counter to exist before reading it.
TestMetricTxnCommits and TestMetricTxnDiscards have the same shape and are presumably exposed to the same race, though we have only observed the aborts variant failing.
I'm happy to open a PR for this if it's welcome.
- Lenguaje dominante
- Go
- Estrellas
- 21.8k
- Forks
- 1.6k
- Merge medio
- 11 d 7 h
- PR fusionados (30 d)
- 5
Preparar el entorno
- Incluye un Dockerfile o un archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de dgraph-io/dgraph
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
Los mantenedores suelen responder en 10 días
-
Broken links in the docsAbierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 76/100
Los mantenedores suelen responder en 10 días
-
Stale
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
dgraph-io/dgraph#9810 · 1 comentario ·
Los mantenedores suelen responder en 10 días
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 10 días
-
Dificultad 4/5 3-5 días Aptitud para principiantes 25/100
Los mantenedores suelen responder en 10 días
Todos los issues de dgraph-io/dgraph
Issues similares
-
【文档错误】创建镜像空间步骤中的截图标注与文字描述不一致Abiertoenhancement
Dificultad 1/5 Menos de una hora Aptitud para principiantes 62/100
DaoCloud/DaoCloud-docs#7839 ·
Los mantenedores suelen responder en 1 día
-
Support AlienVault OTX API keysAbiertoType: Enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
projectdiscovery/urlfinder#167 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
peterstace/simplefeatures#726 ·
-
area: import bug go good first issue priority: low
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
fukubie/StockLlama#69 ·
-
Add `rumpty firewall create|rm`Abiertoenhancement help wanted
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
cloverworks-hq/rumpty-cli#95 ·
Los mantenedores suelen responder en 1 día