=== Applying patches on top of PostgreSQL commit ID fc069a3a6319b5bf40d2f0f1efceae1c9b7a68a8 === /etc/rc.d/jail: WARNING: Per-jail configuration via jail_* variables is obsolete. Please consider migrating to /etc/jail.conf. Mon Feb 17 10:55:25 UTC 2025 On branch cf/5560 nothing to commit, working tree clean === applying patch ./v2-0001-Add-injection-points-for-hash-aggregation.patch Applied patch to 'src/backend/executor/nodeAgg.c' with conflicts. Applied patch to 'src/test/modules/injection_points/Makefile' cleanly. Performing three-way merge... Applied patch to 'src/test/modules/injection_points/expected/hashagg.out' cleanly. Applied patch to 'src/test/modules/injection_points/meson.build' cleanly. Performing three-way merge... Applied patch to 'src/test/modules/injection_points/sql/hashagg.sql' cleanly. U src/backend/executor/nodeAgg.c diff --cc src/backend/executor/nodeAgg.c index ae9cc256b8,35cf18e528..0000000000 --- a/src/backend/executor/nodeAgg.c +++ b/src/backend/executor/nodeAgg.c @@@ -1870,28 -1870,32 +1870,51 @@@ hash_agg_check_limits(AggState *aggstat Size hashkey_mem = MemoryContextMemAllocated(aggstate->hashcontext->ecxt_per_tuple_memory, true); bool do_spill = false; ++<<<<<<< ours + +#ifdef USE_INJECTION_POINTS + if (ngroups >= 1000) + { + if (IS_INJECTION_POINT_ATTACHED("hash-aggregate-spill-1000")) + { + do_spill = true; + INJECTION_POINT_CACHED("hash-aggregate-spill-1000"); + } + } +#endif ++======= ++>>>>>>> theirs /* - * Don't spill unless there's at least one group in the hash table so we - * can be sure to make progress even in edge cases. + * Spill if exceeding memory limit. Don't spill unless there's at least + * one group in the hash table so we can be sure to make progress even in + * edge cases. */ - if (aggstate->hash_ngroups_current > 0 && - (meta_mem + hashkey_mem > aggstate->hash_mem_limit || - ngroups > aggstate->hash_ngroups_limit)) + if (ngroups > 0 && (meta_mem + hashkey_mem > aggstate->hash_mem_limit)) + do_spill = true; + + /* + * Spill if exceeding ngroups limit. This is important if transition + * values may grow, e.g. for ARRAY_AGG(). + */ + if (ngroups > aggstate->hash_ngroups_limit) + do_spill = true; + + #ifdef USE_INJECTION_POINTS + if (ngroups > 1000) { ++<<<<<<< ours + do_spill = true; + } ++======= + if (IS_INJECTION_POINT_ATTACHED("hash-aggregate-spill-1000")) + { + do_spill = true; + INJECTION_POINT_CACHED("hash-aggregate-spill-1000"); + } + } + #endif ++>>>>>>> theirs if (do_spill) hash_agg_enter_spill_mode(aggstate);