mirror of
https://git.postgresql.org/git/postgresql.git
synced 2026-02-21 05:46:59 +08:00
Avoid including worker_internal.h in pgstat.h.
pgstat.h is a widely included header. Including worker_internal.h there is unnecessary and creates tight coupling. By refactoring pgstat_report_subscription_error() to fetch the required LogicalRepWorkerType internally rather than receiving it as an argument, we can eliminate the need for the internal header. Reported-by: Andres Freund <andres@anarazel.de> Author: Nisha Moond <nisha.moond412@gmail.com> Reviewed-by: vignesh C <vignesh21@gmail.com> Reviewed-by: Amit Kapila <amit.kapila16@gmail.com> Discussion: https://postgr.es/m/aY-UE-4t7FiYgH3t@alap3.anarazel.de
This commit is contained in:
@ -34,6 +34,7 @@
|
||||
|
||||
#include "access/htup_details.h"
|
||||
#include "access/table.h"
|
||||
#include "access/xact.h"
|
||||
#include "catalog/catalog.h"
|
||||
#include "catalog/dependency.h"
|
||||
#include "catalog/indexing.h"
|
||||
|
||||
@ -750,8 +750,7 @@ start_sequence_sync(void)
|
||||
* idle state.
|
||||
*/
|
||||
AbortOutOfAnyTransaction();
|
||||
pgstat_report_subscription_error(MySubscription->oid,
|
||||
WORKERTYPE_SEQUENCESYNC);
|
||||
pgstat_report_subscription_error(MySubscription->oid);
|
||||
|
||||
PG_RE_THROW();
|
||||
}
|
||||
|
||||
@ -1527,8 +1527,7 @@ start_table_sync(XLogRecPtr *origin_startpos, char **slotname)
|
||||
* idle state.
|
||||
*/
|
||||
AbortOutOfAnyTransaction();
|
||||
pgstat_report_subscription_error(MySubscription->oid,
|
||||
WORKERTYPE_TABLESYNC);
|
||||
pgstat_report_subscription_error(MySubscription->oid);
|
||||
|
||||
PG_RE_THROW();
|
||||
}
|
||||
|
||||
@ -5644,8 +5644,7 @@ start_apply(XLogRecPtr origin_startpos)
|
||||
* idle state.
|
||||
*/
|
||||
AbortOutOfAnyTransaction();
|
||||
pgstat_report_subscription_error(MySubscription->oid,
|
||||
MyLogicalRepWorker->type);
|
||||
pgstat_report_subscription_error(MySubscription->oid);
|
||||
|
||||
PG_RE_THROW();
|
||||
}
|
||||
@ -6000,8 +5999,7 @@ DisableSubscriptionAndExit(void)
|
||||
* Report the worker failed during sequence synchronization, table
|
||||
* synchronization, or apply.
|
||||
*/
|
||||
pgstat_report_subscription_error(MyLogicalRepWorker->subid,
|
||||
MyLogicalRepWorker->type);
|
||||
pgstat_report_subscription_error(MyLogicalRepWorker->subid);
|
||||
|
||||
/* Disable the subscription */
|
||||
StartTransactionCommand();
|
||||
|
||||
@ -22,6 +22,7 @@
|
||||
#include "miscadmin.h"
|
||||
#include "pgstat.h"
|
||||
#include "port/pg_bitutils.h"
|
||||
#include "replication/logicalctl.h"
|
||||
#include "replication/logicalworker.h"
|
||||
#include "replication/walsender.h"
|
||||
#include "storage/condition_variable.h"
|
||||
|
||||
@ -25,10 +25,11 @@
|
||||
* Report a subscription error.
|
||||
*/
|
||||
void
|
||||
pgstat_report_subscription_error(Oid subid, LogicalRepWorkerType wtype)
|
||||
pgstat_report_subscription_error(Oid subid)
|
||||
{
|
||||
PgStat_EntryRef *entry_ref;
|
||||
PgStat_BackendSubEntry *pending;
|
||||
LogicalRepWorkerType wtype = get_logical_worker_type();
|
||||
|
||||
entry_ref = pgstat_prep_pending_entry(PGSTAT_KIND_SUBSCRIPTION,
|
||||
InvalidOid, subid, NULL);
|
||||
|
||||
@ -16,7 +16,6 @@
|
||||
#include "portability/instr_time.h"
|
||||
#include "postmaster/pgarch.h" /* for MAX_XFN_CHARS */
|
||||
#include "replication/conflict.h"
|
||||
#include "replication/worker_internal.h"
|
||||
#include "utils/backend_progress.h" /* for backward compatibility */ /* IWYU pragma: export */
|
||||
#include "utils/backend_status.h" /* for backward compatibility */ /* IWYU pragma: export */
|
||||
#include "utils/pgstat_kind.h"
|
||||
@ -775,8 +774,7 @@ extern PgStat_SLRUStats *pgstat_fetch_slru(void);
|
||||
* Functions in pgstat_subscription.c
|
||||
*/
|
||||
|
||||
extern void pgstat_report_subscription_error(Oid subid,
|
||||
LogicalRepWorkerType wtype);
|
||||
extern void pgstat_report_subscription_error(Oid subid);
|
||||
extern void pgstat_report_subscription_conflict(Oid subid, ConflictType type);
|
||||
extern void pgstat_create_subscription(Oid subid);
|
||||
extern void pgstat_drop_subscription(Oid subid);
|
||||
|
||||
@ -393,4 +393,11 @@ am_parallel_apply_worker(void)
|
||||
return isParallelApplyWorker(MyLogicalRepWorker);
|
||||
}
|
||||
|
||||
static inline LogicalRepWorkerType
|
||||
get_logical_worker_type(void)
|
||||
{
|
||||
Assert(MyLogicalRepWorker->in_use);
|
||||
return MyLogicalRepWorker->type;
|
||||
}
|
||||
|
||||
#endif /* WORKER_INTERNAL_H */
|
||||
|
||||
@ -12,6 +12,7 @@
|
||||
*/
|
||||
#include "postgres.h"
|
||||
|
||||
#include "access/htup_details.h"
|
||||
#include "common/hashfn.h"
|
||||
#include "funcapi.h"
|
||||
#include "storage/dsm_registry.h"
|
||||
|
||||
Reference in New Issue
Block a user