From: adityashankarv (@adityashankarv) <noreply+adityashankarv@github.com>
To: psycopg/psycopg <noreply+psycopg-psycopg@github.com>
Subject: Re: [psycopg/psycopg] issue #1497: Race condition in test_copy_concurrency causing tests fail randomly
Date: Tue, 17 Nov 2026 02:47:15 +0000
Message-ID: <gh-psycopg-psycopg-1497-c6936452920@github.com> (raw)
In-Reply-To: <gh-psycopg-psycopg-1497@github.com>
References: <gh-psycopg-psycopg-1497@github.com>
Thanks for the write-up and the patch. I agree the assertion is checking an ordering the lock doesn't guarantee, since `exited_copy` is logged after `copy()` has already released `conn.lock`. I'd like to open a PR with your change: record `copy_body_done` inside the `with cur.copy(...)` block in `tests/test_copy_async.py`, then regenerate the sync test with `tools/async_to_sync.py`, so the test only requires workers to run after the COPY body. I'll credit you in the PR.