=== Applying patches on top of PostgreSQL commit ID 9018c7d37bb464cd53567c0b553a6f49b50bec78 === /etc/rc.d/jail: WARNING: Per-jail configuration via jail_* variables is obsolete. Please consider migrating to /etc/jail.conf. Sun Apr 19 16:58:22 UTC 2026 On branch cf/5526 nothing to commit, working tree clean === using 'git am' to apply patch ./v10-0001-Add-storage-I-O-tracking-to-BUFFERS-option.patch === Applying: Add storage I/O tracking to 'BUFFERS' option .git/rebase-apply/patch:866: trailing whitespace. .git/rebase-apply/patch:874: trailing whitespace. .git/rebase-apply/patch:880: trailing whitespace. warning: 3 lines add whitespace errors. Using index info to reconstruct a base tree... M doc/src/sgml/ref/explain.sgml M src/backend/access/brin/brin.c M src/backend/access/gin/gininsert.c M src/backend/access/nbtree/nbtsort.c M src/backend/commands/explain.c M src/backend/commands/vacuumparallel.c M src/backend/executor/execParallel.c M src/backend/executor/instrument.c M src/include/executor/instrument.h M src/tools/pgindent/typedefs.list Falling back to patching base and 3-way merge... Auto-merging src/tools/pgindent/typedefs.list Auto-merging src/include/executor/instrument.h CONFLICT (content): Merge conflict in src/include/executor/instrument.h Auto-merging src/backend/executor/instrument.c CONFLICT (content): Merge conflict in src/backend/executor/instrument.c Auto-merging src/backend/executor/execParallel.c Auto-merging src/backend/commands/vacuumparallel.c Auto-merging src/backend/commands/explain.c Auto-merging src/backend/access/nbtree/nbtsort.c Auto-merging src/backend/access/gin/gininsert.c Auto-merging src/backend/access/brin/brin.c Auto-merging doc/src/sgml/ref/explain.sgml error: Failed to merge in the changes. hint: Use 'git am --show-current-patch=diff' to see the failed patch Patch failed at 0001 Add storage I/O tracking to 'BUFFERS' option When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort". === using patch(1) to apply patch ./v10-0001-Add-storage-I-O-tracking-to-BUFFERS-option.patch === patching file doc/src/sgml/ref/explain.sgml Hunk #1 succeeded at 208 with fuzz 2 (offset 4 lines). patching file src/backend/access/brin/brin.c Hunk #2 succeeded at 2936 (offset 1 line). Hunk #3 succeeded at 2951 (offset 1 line). patching file src/backend/access/gin/gininsert.c Hunk #2 succeeded at 2186 (offset 1 line). Hunk #3 succeeded at 2201 (offset 1 line). patching file src/backend/access/nbtree/nbtsort.c patching file src/backend/commands/explain.c Hunk #1 succeeded at 33 (offset 1 line). Hunk #2 succeeded at 149 (offset 3 lines). Hunk #3 succeeded at 334 (offset 3 lines). Hunk #4 succeeded at 357 (offset 3 lines). Hunk #5 succeeded at 375 (offset 3 lines). Hunk #6 succeeded at 512 (offset 3 lines). Hunk #7 succeeded at 522 (offset 3 lines). Hunk #8 succeeded at 532 with fuzz 1 (offset 3 lines). Hunk #9 succeeded at 630 (offset 5 lines). Hunk #10 succeeded at 644 (offset 5 lines). Hunk #11 succeeded at 704 (offset 5 lines). Hunk #12 succeeded at 4510 (offset 177 lines). patching file src/backend/commands/prepare.c patching file src/backend/commands/vacuumparallel.c Hunk #1 succeeded at 945 (offset 207 lines). Hunk #2 succeeded at 1305 (offset 221 lines). Hunk #3 succeeded at 1313 (offset 221 lines). patching file src/backend/executor/execParallel.c Hunk #2 succeeded at 664 (offset 41 lines). Hunk #3 succeeded at 746 (offset 41 lines). Hunk #4 succeeded at 848 (offset 41 lines). Hunk #5 succeeded at 1270 (offset 47 lines). Hunk #6 succeeded at 1530 (offset 62 lines). Hunk #7 succeeded at 1585 (offset 62 lines). Hunk #8 succeeded at 1605 (offset 62 lines). patching file src/backend/executor/instrument.c Hunk #1 FAILED at 13. Hunk #2 succeeded at 276 (offset 78 lines). Hunk #3 succeeded at 368 with fuzz 2 (offset 78 lines). 1 out of 3 hunks FAILED -- saving rejects to file src/backend/executor/instrument.c.rej patching file src/include/commands/explain.h patching file src/include/executor/execParallel.h patching file src/include/executor/instrument.h Hunk #2 succeeded at 134 with fuzz 1 (offset 25 lines). Hunk #3 FAILED at 120. 1 out of 3 hunks FAILED -- saving rejects to file src/include/executor/instrument.h.rej patching file src/include/port/win32/sys/resource.h patching file src/port/win32getrusage.c patching file src/test/modules/test_misc/t/011_explain_storage_io.pl patching file src/test/regress/expected/explain_1.out patching file src/tools/pgindent/typedefs.list Hunk #1 succeeded at 2762 (offset 40 lines). Unstaged changes after reset: M doc/src/sgml/ref/explain.sgml M src/backend/access/brin/brin.c M src/backend/access/gin/gininsert.c M src/backend/access/nbtree/nbtsort.c M src/backend/commands/explain.c M src/backend/commands/prepare.c M src/backend/commands/vacuumparallel.c M src/backend/executor/execParallel.c M src/backend/executor/instrument.c M src/include/commands/explain.h M src/include/executor/execParallel.h M src/include/executor/instrument.h M src/include/port/win32/sys/resource.h M src/port/win32getrusage.c M src/tools/pgindent/typedefs.list Removing src/backend/executor/instrument.c.rej Removing src/include/executor/instrument.h.rej Removing src/test/modules/test_misc/t/011_explain_storage_io.pl Removing src/test/regress/expected/explain_1.out === using 'git apply' to apply patch ./v10-0001-Add-storage-I-O-tracking-to-BUFFERS-option.patch === /work/patches/./v10-0001-Add-storage-I-O-tracking-to-BUFFERS-option.patch:893: trailing whitespace. /work/patches/./v10-0001-Add-storage-I-O-tracking-to-BUFFERS-option.patch:901: trailing whitespace. /work/patches/./v10-0001-Add-storage-I-O-tracking-to-BUFFERS-option.patch:907: trailing whitespace. Applied patch to 'doc/src/sgml/ref/explain.sgml' cleanly. Applied patch to 'src/backend/access/brin/brin.c' cleanly. Applied patch to 'src/backend/access/gin/gininsert.c' cleanly. Applied patch to 'src/backend/access/nbtree/nbtsort.c' cleanly. Applied patch to 'src/backend/commands/explain.c' cleanly. Applied patch to 'src/backend/commands/prepare.c' cleanly. Applied patch to 'src/backend/commands/vacuumparallel.c' cleanly. Applied patch to 'src/backend/executor/execParallel.c' cleanly. Applied patch to 'src/backend/executor/instrument.c' with conflicts. Applied patch to 'src/include/commands/explain.h' cleanly. Applied patch to 'src/include/executor/execParallel.h' cleanly. Applied patch to 'src/include/executor/instrument.h' with conflicts. Applied patch to 'src/include/port/win32/sys/resource.h' cleanly. Applied patch to 'src/port/win32getrusage.c' cleanly. Falling back to direct application... Falling back to direct application... Applied patch to 'src/tools/pgindent/typedefs.list' cleanly. U src/backend/executor/instrument.c U src/include/executor/instrument.h warning: 3 lines add whitespace errors. diff --cc src/backend/executor/instrument.c index ffbcd572133,3d91f77d6ff..00000000000 --- a/src/backend/executor/instrument.c +++ b/src/backend/executor/instrument.c @@@ -13,14 -13,11 +13,19 @@@ */ #include "postgres.h" + #include #include +#include "executor/executor.h" #include "executor/instrument.h" ++<<<<<<< ours +#include "executor/tuptable.h" +#include "nodes/execnodes.h" +#include "portability/instr_time.h" +#include "utils/guc_hooks.h" ++======= + #include "storage/aio_subsys.h" ++>>>>>>> theirs BufferUsage pgBufferUsage; static BufferUsage save_pgBufferUsage; @@@ -352,8 -301,59 +382,59 @@@ BufferUsageAccumDiff(BufferUsage *dst add->temp_blk_write_time, sub->temp_blk_write_time); } + /* helper functions for StorageIOUsage usage accumulation */ + void + StorageIOUsageAdd(StorageIOUsage *dst, const StorageIOUsage *add) + { + dst->inblock += add->inblock; + dst->outblock += add->outblock; + } + + /* dst += add - sub */ + void + StorageIOUsageAccumDiff(StorageIOUsage *dst, const StorageIOUsage *add, const StorageIOUsage *sub) + { + dst->inblock += add->inblock - sub->inblock; + dst->outblock += add->outblock - sub->outblock; + } + + /* dst -= sub */ + void + StorageIOUsageDiff(StorageIOUsage *dst, const StorageIOUsage *sub) + { + dst->inblock -= sub->inblock; + dst->outblock -= sub->outblock; + } + + /* Captures the current storage I/O usage statistics */ + void + GetStorageIOUsage(StorageIOUsage *usage) + { + struct rusage rusage; + + /* + * Since getting the I/O excluding AIO workers underestimates the total + * I/O, don't get the I/O usage statistics when AIO worker is enabled. + */ + if (pgaio_workers_enabled()) + { + usage->inblock = 0; + usage->outblock = 0; + return; + } + + if (getrusage(RUSAGE_SELF, &rusage)) + { + ereport(ERROR, + (errcode(ERRCODE_SYSTEM_ERROR), + errmsg("getrusage() failed: %m"))); + } + usage->inblock = rusage.ru_inblock; + usage->outblock = rusage.ru_oublock; + } + /* helper functions for WAL usage accumulation */ -static void +static inline void WalUsageAdd(WalUsage *dst, WalUsage *add) { dst->wal_bytes += add->wal_bytes; diff --cc src/include/executor/instrument.h index f093a52aae0,b95157d5588..00000000000 --- a/src/include/executor/instrument.h +++ b/src/include/executor/instrument.h @@@ -110,48 -98,38 +118,68 @@@ typedef struct NodeInstrumentatio double nloops; /* # of run cycles for this node */ double nfiltered1; /* # of tuples removed by scanqual or joinqual */ double nfiltered2; /* # of tuples removed by "other" quals */ - BufferUsage bufusage; /* total buffer usage */ - WalUsage walusage; /* total WAL usage */ -} Instrumentation; +} NodeInstrumentation; -typedef struct WorkerInstrumentation +typedef struct WorkerNodeInstrumentation { int num_workers; /* # of structures that follow */ - Instrumentation instrument[FLEXIBLE_ARRAY_MEMBER]; -} WorkerInstrumentation; + NodeInstrumentation instrument[FLEXIBLE_ARRAY_MEMBER]; +} WorkerNodeInstrumentation; + +typedef struct TriggerInstrumentation +{ + Instrumentation instr; + int64 firings; /* number of times the instrumented trigger + * was fired */ +} TriggerInstrumentation; extern PGDLLIMPORT BufferUsage pgBufferUsage; + extern PGDLLIMPORT StorageIOUsage pgStorageIOUsageParallel; extern PGDLLIMPORT WalUsage pgWalUsage; ++<<<<<<< ours +extern Instrumentation *InstrAlloc(int instrument_options); +extern void InstrInitOptions(Instrumentation *instr, int instrument_options); +extern void InstrStart(Instrumentation *instr); +extern void InstrStop(Instrumentation *instr); + +extern NodeInstrumentation *InstrAllocNode(int instrument_options, + bool async_mode); +extern void InstrInitNode(NodeInstrumentation *instr, int instrument_options, + bool async_mode); +extern void InstrStartNode(NodeInstrumentation *instr); +extern void InstrStopNode(NodeInstrumentation *instr, double nTuples); +extern void InstrUpdateTupleCount(NodeInstrumentation *instr, double nTuples); +extern void InstrEndLoop(NodeInstrumentation *instr); +extern void InstrAggNode(NodeInstrumentation *dst, NodeInstrumentation *add); + +extern TriggerInstrumentation *InstrAllocTrigger(int n, int instrument_options); +extern void InstrStartTrigger(TriggerInstrumentation *tginstr); +extern void InstrStopTrigger(TriggerInstrumentation *tginstr, int64 firings); + +extern void InstrStartParallelQuery(void); +extern void InstrEndParallelQuery(BufferUsage *bufusage, WalUsage *walusage); +extern void InstrAccumParallelQuery(BufferUsage *bufusage, WalUsage *walusage); ++======= + extern Instrumentation *InstrAlloc(int n, int instrument_options, + bool async_mode); + extern void InstrInit(Instrumentation *instr, int instrument_options); + extern void InstrStartNode(Instrumentation *instr); + extern void InstrStopNode(Instrumentation *instr, double nTuples); + extern void InstrUpdateTupleCount(Instrumentation *instr, double nTuples); + extern void InstrEndLoop(Instrumentation *instr); + extern void InstrAggNode(Instrumentation *dst, Instrumentation *add); + extern void InstrStartParallelQuery(StorageIOUsage *storageiousage); + extern void InstrEndParallelQuery(BufferUsage *bufusage, StorageIOUsage *storageiousage, WalUsage *walusage, StorageIOUsage *storageiousage_start); + extern void InstrAccumParallelQuery(BufferUsage *bufusage, StorageIOUsage *storageiousage, WalUsage *walusage); ++>>>>>>> theirs extern void BufferUsageAccumDiff(BufferUsage *dst, const BufferUsage *add, const BufferUsage *sub); + extern void StorageIOUsageAccumDiff(StorageIOUsage *dst, + const StorageIOUsage *add, const StorageIOUsage *sub); + extern void StorageIOUsageDiff(StorageIOUsage *dst, const StorageIOUsage *sub); + extern void StorageIOUsageAdd(StorageIOUsage *dst, const StorageIOUsage *add); + extern void GetStorageIOUsage(StorageIOUsage *usage); extern void WalUsageAccumDiff(WalUsage *dst, const WalUsage *add, const WalUsage *sub);