Manu <[email protected]> wrote: > Thanks for v03. Both problems I reported are gone: a failed nested > COPY no longer leaves a row behind or leaks memory, and REPACK keeps > its row while it rebuilds the indexes. > > I did find a few more cases where a row gets stuck or lost. > > On Mon, Nov 23, 2026 at 7:29 PM Antonin Houska <[email protected]> wrote: > > Thanks for finding this problem. v03 should handle errors in file_fdw > > correctly. > > It does with one scan, but not when two file_fdw scans are running > and one of them fails. With ft_bad being a file_fdw table whose last > line is bad: > > SELECT (SELECT count(*) FROM ft_bad) + (SELECT count(*) FROM ft); > > After this error the session reports no progress for anything that > follows, and with asserts enabled the next commit fails the Assert in > xact_callback(). The callback only undoes one of the two scans, so > active_nodes stays at 1.
Should work in v04 [1]. > Two related ones: if a COPY fails while one of its triggers is inside > a file_fdw scan, the COPY's row is never removed, because the abort > ends progress before the callback turns tracking back on. And a > two-scan query that succeeds inside a COPY trigger removes the outer > COPY's row, because the scan resumes tracking before EndCopyFrom(). > > > Likewise, error handling fixed in v03. > > The case that still breaks here is a cursor closed in a > subtransaction: > > BEGIN; DECLARE c CURSOR FOR SELECT * FROM ft; FETCH c; > SAVEPOINT s; CLOSE c; RELEASE s; COMMIT; > > The cursor's COPY row is still there after the COMMIT, survives later > errors, and hides the next CREATE INDEX. As far as I can tell, CLOSE > sees progress_depth 0 in the subtransaction, and nothing carries the > depth over when the subtransaction commits. This should also work in v04. Thanks for finding these non-trivial problems. [1] https://www.postgresql.org/message-id/115231.1795710799@chrudos -- Antonin Houska Web: https://www.cybertec-postgresql.com
