diff options
author | Michael Paquier <michael@paquier.xyz> | 2025-05-10 06:56:26 +0900 |
---|---|---|
committer | Michael Paquier <michael@paquier.xyz> | 2025-05-10 06:56:26 +0900 |
commit | 371f2db8b05e4d46cbf489f05cbfc4d6ed6976d4 (patch) | |
tree | af10abf135f4a14534d31c7d8f95d7bed9b4e949 /src/backend | |
parent | 89372d0aaa4a6f0e560acdf9014c5ad66fdde1b1 (diff) | |
download | postgresql-371f2db8b05e4d46cbf489f05cbfc4d6ed6976d4.tar.gz postgresql-371f2db8b05e4d46cbf489f05cbfc4d6ed6976d4.zip |
Add support for runtime arguments in injection points
The macros INJECTION_POINT() and INJECTION_POINT_CACHED() are extended
with an optional argument that can be passed down to the callback
attached when an injection point is run, giving to callbacks the
possibility to manipulate a stack state given by the caller. The
existing callbacks in modules injection_points and test_aio have their
declarations adjusted based on that.
da7226993fd4 (core AIO infrastructure) and 93bc3d75d8e1 (test_aio) and
been relying on a set of workarounds where a static variable called
pgaio_inj_cur_handle is used as runtime argument in the injection point
callbacks used by the AIO tests, in combination with a TRY/CATCH block
to reset the argument value. The infrastructure introduced in this
commit will be reused for the AIO tests, simplifying them.
Reviewed-by: Greg Burd <greg@burd.me>
Discussion: https://postgr.es/m/Z_y9TtnXubvYAApS@paquier.xyz
Diffstat (limited to 'src/backend')
-rw-r--r-- | src/backend/access/gin/ginbtree.c | 6 | ||||
-rw-r--r-- | src/backend/access/heap/heapam.c | 2 | ||||
-rw-r--r-- | src/backend/access/index/genam.c | 2 | ||||
-rw-r--r-- | src/backend/access/transam/multixact.c | 4 | ||||
-rw-r--r-- | src/backend/access/transam/xlog.c | 2 | ||||
-rw-r--r-- | src/backend/commands/indexcmds.c | 4 | ||||
-rw-r--r-- | src/backend/executor/nodeAgg.c | 10 | ||||
-rw-r--r-- | src/backend/libpq/be-secure-gssapi.c | 2 | ||||
-rw-r--r-- | src/backend/libpq/be-secure.c | 2 | ||||
-rw-r--r-- | src/backend/postmaster/autovacuum.c | 2 | ||||
-rw-r--r-- | src/backend/storage/aio/aio.c | 2 | ||||
-rw-r--r-- | src/backend/tcop/backend_startup.c | 2 | ||||
-rw-r--r-- | src/backend/tcop/postgres.c | 6 | ||||
-rw-r--r-- | src/backend/utils/cache/catcache.c | 2 | ||||
-rw-r--r-- | src/backend/utils/cache/inval.c | 2 | ||||
-rw-r--r-- | src/backend/utils/cache/typcache.c | 2 | ||||
-rw-r--r-- | src/backend/utils/init/postinit.c | 2 | ||||
-rw-r--r-- | src/backend/utils/misc/injection_point.c | 8 |
18 files changed, 31 insertions, 31 deletions
diff --git a/src/backend/access/gin/ginbtree.c b/src/backend/access/gin/ginbtree.c index 26a0bdc2063..644d484ea53 100644 --- a/src/backend/access/gin/ginbtree.c +++ b/src/backend/access/gin/ginbtree.c @@ -685,9 +685,9 @@ ginFinishSplit(GinBtree btree, GinBtreeStack *stack, bool freestack, #ifdef USE_INJECTION_POINTS if (GinPageIsLeaf(BufferGetPage(stack->buffer))) - INJECTION_POINT("gin-leave-leaf-split-incomplete"); + INJECTION_POINT("gin-leave-leaf-split-incomplete", NULL); else - INJECTION_POINT("gin-leave-internal-split-incomplete"); + INJECTION_POINT("gin-leave-internal-split-incomplete", NULL); #endif /* search parent to lock */ @@ -778,7 +778,7 @@ ginFinishSplit(GinBtree btree, GinBtreeStack *stack, bool freestack, static void ginFinishOldSplit(GinBtree btree, GinBtreeStack *stack, GinStatsData *buildStats, int access) { - INJECTION_POINT("gin-finish-incomplete-split"); + INJECTION_POINT("gin-finish-incomplete-split", NULL); elog(DEBUG1, "finishing incomplete split of block %u in gin index \"%s\"", stack->blkno, RelationGetRelationName(btree->index)); diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c index c1a4de14a59..9ec8cda1c68 100644 --- a/src/backend/access/heap/heapam.c +++ b/src/backend/access/heap/heapam.c @@ -3304,7 +3304,7 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup, interesting_attrs = bms_add_members(interesting_attrs, id_attrs); block = ItemPointerGetBlockNumber(otid); - INJECTION_POINT("heap_update-before-pin"); + INJECTION_POINT("heap_update-before-pin", NULL); buffer = ReadBuffer(relation, block); page = BufferGetPage(buffer); diff --git a/src/backend/access/index/genam.c b/src/backend/access/index/genam.c index 8f532e14590..0cb27af1310 100644 --- a/src/backend/access/index/genam.c +++ b/src/backend/access/index/genam.c @@ -851,7 +851,7 @@ systable_inplace_update_begin(Relation relation, if (retries++ > 10000) elog(ERROR, "giving up after too many tries to overwrite row"); - INJECTION_POINT("inplace-before-pin"); + INJECTION_POINT("inplace-before-pin", NULL); scan = systable_beginscan(relation, indexId, indexOK, snapshot, nkeys, unconstify(ScanKeyData *, key)); oldtup = systable_getnext(scan); diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c index ef91e70f41d..3c06ac45532 100644 --- a/src/backend/access/transam/multixact.c +++ b/src/backend/access/transam/multixact.c @@ -872,7 +872,7 @@ MultiXactIdCreateFromMembers(int nmembers, MultiXactMember *members) */ multi = GetNewMultiXactId(nmembers, &offset); - INJECTION_POINT_CACHED("multixact-create-from-members"); + INJECTION_POINT_CACHED("multixact-create-from-members", NULL); /* Make an XLOG entry describing the new MXID. */ xlrec.mid = multi; @@ -1486,7 +1486,7 @@ retry: LWLockRelease(lock); CHECK_FOR_INTERRUPTS(); - INJECTION_POINT("multixact-get-members-cv-sleep"); + INJECTION_POINT("multixact-get-members-cv-sleep", NULL); ConditionVariableSleep(&MultiXactState->nextoff_cv, WAIT_EVENT_MULTIXACT_CREATION); diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 2d4c346473b..1914859b2ee 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -7882,7 +7882,7 @@ CreateRestartPoint(int flags) * This location needs to be after CheckPointGuts() to ensure that some * work has already happened during this checkpoint. */ - INJECTION_POINT("create-restart-point"); + INJECTION_POINT("create-restart-point", NULL); /* * Remember the prior checkpoint's redo ptr for diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 33c2106c17c..d962fe392cd 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -3892,9 +3892,9 @@ ReindexRelationConcurrently(const ReindexStmt *stmt, Oid relationOid, const Rein #ifdef USE_INJECTION_POINTS if (idx->safe) - INJECTION_POINT("reindex-conc-index-safe"); + INJECTION_POINT("reindex-conc-index-safe", NULL); else - INJECTION_POINT("reindex-conc-index-not-safe"); + INJECTION_POINT("reindex-conc-index-not-safe", NULL); #endif idx->tableId = RelationGetRelid(heapRel); diff --git a/src/backend/executor/nodeAgg.c b/src/backend/executor/nodeAgg.c index f83fc16c5c8..377e016d732 100644 --- a/src/backend/executor/nodeAgg.c +++ b/src/backend/executor/nodeAgg.c @@ -1492,7 +1492,7 @@ build_hash_tables(AggState *aggstate) if (IS_INJECTION_POINT_ATTACHED("hash-aggregate-oversize-table")) { nbuckets = memory / TupleHashEntrySize(); - INJECTION_POINT_CACHED("hash-aggregate-oversize-table"); + INJECTION_POINT_CACHED("hash-aggregate-oversize-table", NULL); } #endif @@ -1882,7 +1882,7 @@ hash_agg_check_limits(AggState *aggstate) if (IS_INJECTION_POINT_ATTACHED("hash-aggregate-spill-1000")) { do_spill = true; - INJECTION_POINT_CACHED("hash-aggregate-spill-1000"); + INJECTION_POINT_CACHED("hash-aggregate-spill-1000", NULL); } } #endif @@ -1910,7 +1910,7 @@ hash_agg_check_limits(AggState *aggstate) static void hash_agg_enter_spill_mode(AggState *aggstate) { - INJECTION_POINT("hash-aggregate-enter-spill-mode"); + INJECTION_POINT("hash-aggregate-enter-spill-mode", NULL); aggstate->hash_spill_mode = true; hashagg_recompile_expressions(aggstate, aggstate->table_filled, true); @@ -2739,7 +2739,7 @@ agg_refill_hash_table(AggState *aggstate) */ hashagg_recompile_expressions(aggstate, true, true); - INJECTION_POINT("hash-aggregate-process-batch"); + INJECTION_POINT("hash-aggregate-process-batch", NULL); for (;;) { TupleTableSlot *spillslot = aggstate->hash_spill_rslot; @@ -2995,7 +2995,7 @@ hashagg_spill_init(HashAggSpill *spill, LogicalTapeSet *tapeset, int used_bits, { npartitions = 1; partition_bits = 0; - INJECTION_POINT_CACHED("hash-aggregate-single-partition"); + INJECTION_POINT_CACHED("hash-aggregate-single-partition", NULL); } #endif diff --git a/src/backend/libpq/be-secure-gssapi.c b/src/backend/libpq/be-secure-gssapi.c index a3d610b1373..717ba9824f9 100644 --- a/src/backend/libpq/be-secure-gssapi.c +++ b/src/backend/libpq/be-secure-gssapi.c @@ -500,7 +500,7 @@ secure_open_gssapi(Port *port) minor; gss_cred_id_t delegated_creds; - INJECTION_POINT("backend-gssapi-startup"); + INJECTION_POINT("backend-gssapi-startup", NULL); /* * Allocate subsidiary Port data for GSSAPI operations. diff --git a/src/backend/libpq/be-secure.c b/src/backend/libpq/be-secure.c index 91576f94285..d723e74e813 100644 --- a/src/backend/libpq/be-secure.c +++ b/src/backend/libpq/be-secure.c @@ -131,7 +131,7 @@ secure_open_server(Port *port) } Assert(pq_buffer_remaining_data() == 0); - INJECTION_POINT("backend-ssl-startup"); + INJECTION_POINT("backend-ssl-startup", NULL); r = be_tls_open_server(port); diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c index 16756152b71..4d4a1a3197e 100644 --- a/src/backend/postmaster/autovacuum.c +++ b/src/backend/postmaster/autovacuum.c @@ -1922,7 +1922,7 @@ do_autovacuum(void) * This injection point is put in a transaction block to work with a wait * that uses a condition variable. */ - INJECTION_POINT("autovacuum-worker-start"); + INJECTION_POINT("autovacuum-worker-start", NULL); /* * Compute the multixact age for which freezing is urgent. This is diff --git a/src/backend/storage/aio/aio.c b/src/backend/storage/aio/aio.c index 57b9cf3dcab..04268e77ec2 100644 --- a/src/backend/storage/aio/aio.c +++ b/src/backend/storage/aio/aio.c @@ -1275,7 +1275,7 @@ pgaio_io_call_inj(PgAioHandle *ioh, const char *injection_point) PG_TRY(); { - InjectionPointCached(injection_point); + InjectionPointCached(injection_point, NULL); } PG_FINALLY(); { diff --git a/src/backend/tcop/backend_startup.c b/src/backend/tcop/backend_startup.c index dde8d5b3517..a7d1fec981f 100644 --- a/src/backend/tcop/backend_startup.c +++ b/src/backend/tcop/backend_startup.c @@ -234,7 +234,7 @@ BackendInitialize(ClientSocket *client_sock, CAC_state cac) /* For testing client error handling */ #ifdef USE_INJECTION_POINTS - INJECTION_POINT("backend-initialize"); + INJECTION_POINT("backend-initialize", NULL); if (IS_INJECTION_POINT_ATTACHED("backend-initialize-v2-error")) { /* diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index dc4c600922d..1ae51b1b391 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -3482,7 +3482,7 @@ ProcessInterrupts(void) IdleInTransactionSessionTimeoutPending = false; if (IdleInTransactionSessionTimeout > 0) { - INJECTION_POINT("idle-in-transaction-session-timeout"); + INJECTION_POINT("idle-in-transaction-session-timeout", NULL); ereport(FATAL, (errcode(ERRCODE_IDLE_IN_TRANSACTION_SESSION_TIMEOUT), errmsg("terminating connection due to idle-in-transaction timeout"))); @@ -3495,7 +3495,7 @@ ProcessInterrupts(void) TransactionTimeoutPending = false; if (TransactionTimeout > 0) { - INJECTION_POINT("transaction-timeout"); + INJECTION_POINT("transaction-timeout", NULL); ereport(FATAL, (errcode(ERRCODE_TRANSACTION_TIMEOUT), errmsg("terminating connection due to transaction timeout"))); @@ -3508,7 +3508,7 @@ ProcessInterrupts(void) IdleSessionTimeoutPending = false; if (IdleSessionTimeout > 0) { - INJECTION_POINT("idle-session-timeout"); + INJECTION_POINT("idle-session-timeout", NULL); ereport(FATAL, (errcode(ERRCODE_IDLE_SESSION_TIMEOUT), errmsg("terminating connection due to idle-session timeout"))); diff --git a/src/backend/utils/cache/catcache.c b/src/backend/utils/cache/catcache.c index 6e3cad454c0..657648996c2 100644 --- a/src/backend/utils/cache/catcache.c +++ b/src/backend/utils/cache/catcache.c @@ -1926,7 +1926,7 @@ SearchCatCacheList(CatCache *cache, /* Injection point to help testing the recursive invalidation case */ if (first_iter) { - INJECTION_POINT("catcache-list-miss-systable-scan-started"); + INJECTION_POINT("catcache-list-miss-systable-scan-started", NULL); first_iter = false; } diff --git a/src/backend/utils/cache/inval.c b/src/backend/utils/cache/inval.c index fa7b4d7e303..02505c88b8e 100644 --- a/src/backend/utils/cache/inval.c +++ b/src/backend/utils/cache/inval.c @@ -1207,7 +1207,7 @@ AtEOXact_Inval(bool isCommit) /* Must be at top of stack */ Assert(transInvalInfo->my_level == 1 && transInvalInfo->parent == NULL); - INJECTION_POINT("transaction-end-process-inval"); + INJECTION_POINT("transaction-end-process-inval", NULL); if (isCommit) { diff --git a/src/backend/utils/cache/typcache.c b/src/backend/utils/cache/typcache.c index e359da09ec9..f9aec38a11f 100644 --- a/src/backend/utils/cache/typcache.c +++ b/src/backend/utils/cache/typcache.c @@ -952,7 +952,7 @@ lookup_type_cache(Oid type_id, int flags) load_domaintype_info(typentry); } - INJECTION_POINT("typecache-before-rel-type-cache-insert"); + INJECTION_POINT("typecache-before-rel-type-cache-insert", NULL); Assert(in_progress_offset + 1 == in_progress_list_len); in_progress_list_len--; diff --git a/src/backend/utils/init/postinit.c b/src/backend/utils/init/postinit.c index 28f09a27001..89d72cdd5ff 100644 --- a/src/backend/utils/init/postinit.c +++ b/src/backend/utils/init/postinit.c @@ -747,7 +747,7 @@ InitPostgres(const char *in_dbname, Oid dboid, if (!bootstrap) { pgstat_bestart_initial(); - INJECTION_POINT("init-pre-auth"); + INJECTION_POINT("init-pre-auth", NULL); } /* diff --git a/src/backend/utils/misc/injection_point.c b/src/backend/utils/misc/injection_point.c index 97ab851f0a6..f58ebc8ee52 100644 --- a/src/backend/utils/misc/injection_point.c +++ b/src/backend/utils/misc/injection_point.c @@ -541,14 +541,14 @@ InjectionPointLoad(const char *name) * Execute an injection point, if defined. */ void -InjectionPointRun(const char *name) +InjectionPointRun(const char *name, void *arg) { #ifdef USE_INJECTION_POINTS InjectionPointCacheEntry *cache_entry; cache_entry = InjectionPointCacheRefresh(name); if (cache_entry) - cache_entry->callback(name, cache_entry->private_data); + cache_entry->callback(name, cache_entry->private_data, arg); #else elog(ERROR, "Injection points are not supported by this build"); #endif @@ -558,14 +558,14 @@ InjectionPointRun(const char *name) * Execute an injection point directly from the cache, if defined. */ void -InjectionPointCached(const char *name) +InjectionPointCached(const char *name, void *arg) { #ifdef USE_INJECTION_POINTS InjectionPointCacheEntry *cache_entry; cache_entry = injection_point_cache_get(name); if (cache_entry) - cache_entry->callback(name, cache_entry->private_data); + cache_entry->callback(name, cache_entry->private_data, arg); #else elog(ERROR, "Injection points are not supported by this build"); #endif |