Re: IO wait events for COPY FROM/TO PROGRAM or file

Поиск
Список
Период
Сортировка
От Michael Paquier
Тема Re: IO wait events for COPY FROM/TO PROGRAM or file
Дата
Msg-id aWBCcFgH87WnMKtA@paquier.xyz
обсуждение исходный текст
Ответ на IO wait events for COPY FROM/TO PROGRAM or file  (Nikolay Samokhvalov <nik@postgres.ai>)
Ответы Re: IO wait events for COPY FROM/TO PROGRAM or file
Список pgsql-hackers
On Thu, Jan 08, 2026 at 01:53:17PM -0800, Nikolay Samokhvalov wrote:
> Following up on the discussion about wait event coverage for COPY
> operations [1], here's a tiny patch that adds two new IO wait events:
> - COPY_DATA_READ: COPY FROM blocking on file/program read
> - COPY_DATA_WRITE: COPY TO blocking on file/program write

         case COPY_FILE:
+            pgstat_report_wait_start(WAIT_EVENT_COPY_DATA_WRITE);
             if (fwrite(fe_msgbuf->data, fe_msgbuf->len, 1,
                        cstate->copy_file) != 1 ||
                 ferror(cstate->copy_file))
@@ -486,6 +487,7 @@ CopySendEndOfRow(CopyToState cstate)
                             (errcode_for_file_access(),
                              errmsg("could not write to COPY file: %m")));
             }
+            pgstat_report_wait_end();

Hmm.  Makes sense to me (perhaps you have played with an LLM to find
out fread() and fwrite() patterns that would need an event?), but I
don't think that the part about COPY TO is done right.  The wait event
should be set during the fwrite() call only, similarly to the COPY
FROM case, by saving the result returned by fwrite() in a separate
variable.
--
Michael

Вложения

В списке pgsql-hackers по дате отправления: