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

Aperta Adatta ai principianti
#1,034 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 3 giorni

@YongGoose ci sta già lavorando.

Dal 8/11/2026.

  • #1035 di @YongGoose — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
docker, postgresql, python, redis
Ambito
databases, testing

Direzione di ricerca

Inizia con i fixture di integrazione Redis e Postgres in tests/integrations/persisters/b_redis.py, b_psycopg2.py e b_asyncpg.py, poi esamina test_redis_persister_class_backwards_compatible, che non ha un fixture. Verifica come i fixture ripuliscono i dati persistiti evitando eliminazioni estese come Redis FLUSHDB. Il lavoro è completato quando tutti i 68 test di integrazione dei persister passano se eseguiti ripetutamente sugli stessi database.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Python
Stelle
2.6k
Fork
218
Merge medio
4g 8h
PR unite (30g)
35

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di apache/burr

Tutte le issue di apache/burr

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.