Redis and Postgres persister integration tests fail when re-run against the same databases

Abierto Apto para principiantes
#1,034 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 3 días

@YongGoose ya está trabajando en esto.

Desde el 8/11/2026.

  • #1035 de @YongGoose — abierto

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
78/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
docker, postgresql, python, redis

Línea de trabajo

Empieza por los fixtures de integración de Redis y Postgres en tests/integrations/persisters/b_redis.py, b_psycopg2.py y b_asyncpg.py. Después, inspecciona test_redis_persister_class_backwards_compatible, que no tiene fixture. Comprueba cómo limpian los fixtures los datos persistidos y evitan borrados generales como Redis FLUSHDB. El objetivo se alcanza cuando las 68 pruebas de integración de persisters pasan al ejecutarse repetidamente contra las mismas bases de datos.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

status/needs-triage

The Redis and PostgreSQL persister integration tests leave their data behind, so running them a second time against the same databases fails 22 tests. CI doesn't hit this because every job starts fresh service containers, but it breaks the usual local loop of keeping the databases up and re-running the tests.

Current behavior

Against fresh Postgres/MongoDB/Redis instances, tests/integrations/persisters passes (68 passed). Every later run against the same databases fails the same 22 tests: 13 in test_b_redis.py and 9 in test_postgresql.py.

Stack Traces

psycopg2.errors.UniqueViolation: duplicate key value violates unique constraint "testtable_pkey"
asyncpg.exceptions.UniqueViolationError: duplicate key value violates unique constraint "testtable_async_pkey"
ValueError: partition_key:app_id:sequence_id[pk:app_id:1] already exists.

Steps to replicate behavior

  1. Start the same services the CI persister job uses:
    docker run -d --rm --name burr-pg -e POSTGRES_PASSWORD=postgres -p 5432:5432 postgres:15
    docker run -d --rm --name burr-mongo -p 27017:27017 mongo:7.0
    docker run -d --rm --name burr-redis -p 6379:6379 redis:7
    
  2. BURR_CI_INTEGRATION_TESTS=true pytest tests/integrations/persisters: 68 passed
  3. Run the same command again: 22 failed, 46 passed (and the same on every run after that)

After one clean run, Redis holds 25 keys (15 in db 0, 10 in db 1) and Postgres holds 15 rows (testtable: 8, testtable_async: 7). MongoDB is empty.

Library & System Information

burr main at 36e3ff3 (0.43.0). Python 3.12 on macOS, and Python 3.12 in a linux/arm64 container. postgres:15, mongo:7.0 and redis:7, the same images CI uses.

Expected behavior

The tests clean up after themselves, so they pass on every run, not only the first.

Additional context

The persisters intentionally reject saving a step that already exists: Redis and MongoDB raise ValueError, and Postgres hits the primary key. The tests use fixed keys such as ("pk", "app_id", 1).

  • The MongoDB fixture tears down with persister.collection.drop(), which is why it isn't affected.
  • The Redis and Postgres fixtures only call persister.cleanup(), which just closes the connection (b_redis.py, b_psycopg2.py, b_asyncpg.py), so their data stays.
  • test_redis_persister_class_backwards_compatible doesn't use a fixture and never cleans up either.

A fix shouldn't use FLUSHDB: the Redis tests use db 0, which is Redis' default and may hold a developer's own data. I'll open a PR for this.

Lenguaje dominante
Python
Estrellas
2.6k
Forks
218
Merge medio
4 d 8 h
PR fusionados (30 d)
35

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de apache/burr

Todos los issues de apache/burr

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.