Agent-Hellboy / Agent-Hellboy/pg_retry

Explore the flaky `test_concurrent_deadlocks_are_retried` system test

Ouverte
#7 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
Python
Étoiles
3
Forks
0
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

```
=================================== FAILURES ===================================
____________________ test_concurrent_deadlocks_are_retried _____________________

pg_cluster =

def test_concurrent_deadlocks_are_retried(pg_cluster):
"""Use many workers grabbing advisory locks in opposite order."""
dsn = pg_cluster.dsn()
pg_cluster.truncate_log()
pg_cluster.run_sql("SELECT retry.configure_failure_plan('forced_deadlock', '40P01', 12)")

deadlocks_before = fetch_scalar(
dsn,
"""
SELECT pg_stat_get_db_deadlocks(oid)
FROM pg_database
WHERE datname = current_database()
""",
)

statements = [
"SELECT retry.transfer_with_advisory(1, 2, 1, 30, 'forced_deadlock')",
"SELECT retry.transfer_with_advisory(2, 1, 1, 30, NULL)",
] * 6
random.shuffle(statements)

with ThreadPoolExecutor(max_workers=len(statements)) as pool:
futures = [pool.submit(run_retry_sql, dsn, stmt) for stmt in statements]
for future in futures:
> future.result(timeout=60)

system_tests/test_retry_concurrency.py:32:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3.12/concurrent/futures/_base.py:449: in result
return self.__get_result()
^^^^^^^^^^^^^^^^^^^
/usr/lib/python3.12/concurrent/futures/_base.py:401: in __get_result
raise self._exception
/usr/lib/python3.12/concurrent/futures/thread.py:58: in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
system_tests/utils.py:20: in run_retry_sql
cur.execute(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self =
query = 'SELECT retry.retry(%s, %s, %s, %s)'
params = ('SELECT retry.transfer_with_advisory(2, 1, 1, 30, NULL)', 16, 5, 250)

def execute(
self,
query: Query,
params: Params | None = None,
*,
prepare: bool | None = None,
binary: bool | None = None,
) -> Self:
"""
Execute a query or command to the database.
"""
try:
with self._conn.lock:
self._conn.wait(
self._execute_gen(query, params, prepare=prepare, binary=binary)
)
except e._NO_TRACEBACK as ex:
> raise ex.with_traceback(None)
E psycopg.errors.DeadlockDetected: deadlock detected
E DETAIL: Process 6339 waits for ExclusiveLock on advisory lock [16384,0,1,1]; blocked by process 6336.
E Process 6336 waits for ExclusiveLock on advisory lock [16384,0,2,1]; blocked by process 6339.
E HINT: See server log for query details.
E CONTEXT: SQL statement "SELECT pg_advisory_xact_lock(second_id)"
E PL/pgSQL function retry.transfer_with_advisory(integer,integer,integer,integer,text) line 15 at PERFORM
E SQL statement "SELECT retry.transfer_with_advisory(2, 1, 1, 30, NULL)"

../../../.local/lib/python3.12/site-packages/psycopg/cursor.py:97: DeadlockDetected
----------------------------- Captured stdout call -----------------------------
configure_failure_plan
------------------------

(1 row)

----------------------------- Captured stderr call -----------------------------
NOTICE: schema "retry" already exists, skipping
=========================== short test summary info ============================
FAILED system_tests/test_retry_concurrency.py::test_concurrent_deadlocks_are_retried - psycopg.errors.DeadlockDetected: deadlock detected
DETAIL: Process 6339 waits for ExclusiveLock on advisory lock [16384,0,1,1]; blocked by process 6336.
Process 6336 waits for ExclusiveLock on advisory lock [16384,0,2,1]; blocked by process 6339.
HINT: See server log for query details.
CONTEXT: SQL statement "SELECT pg_advisory_xact_lock(second_id)"
PL/pgSQL function retry.transfer_with_advisory(integer,integer,integer,integer,text) line 15 at PERFORM
SQL statement "SELECT retry.transfer_with_advisory(2, 1, 1, 30, NULL)"
======================== 1 failed, 26 passed in 38.01s =========================
make: *** [Makefile:56: systemtest] Error 1
Error: Process completed with exit code 2.
```

https://github.com/Agent-Hellboy/pg_retry/actions/runs/19405445879/job/55519391799

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.