/*-------------------------------------------------------------------------
|
* cfs_bgworker.h
|
* Compressed File Store (CFS) — background compaction worker.
|
*
|
* CfsBgWorker is a database-less launcher that periodically enumerates the
|
* databases of the cluster and, one at a time, starts a short-lived
|
* per-database worker; that worker scans the catalog of its database for
|
* CFS relations with a high dead-space ratio and compacts their sidecar
|
* files (.cfp / .cfsmap) under an AccessExclusiveLock. The same
|
* compaction algorithm is available synchronously via the SQL function
|
* pg_cfs_compact(regclass).
|
*
|
* Copyright (c) 2026, Kirillov Vyacheslav by AI, QDB Development Group
|
*
|
* IDENTIFICATION
|
* src/include/postmaster/cfs_bgworker.h
|
*
|
*-------------------------------------------------------------------------
|
*/
|
#ifndef CFS_BGWORKER_H
|
#define CFS_BGWORKER_H
|
|
#include "postgres.h"
|
|
#ifdef USE_CFS
|
|
#include "storage/cfs/cfs_compact.h"
|
|
/* Register the CfsBgWorker launcher with the postmaster (called from postmaster main). */
|
extern void CfsBgWorkerRegister(void);
|
|
/* Launcher main loop: database-less, cycles through every database. */
|
extern void CfsBgWorkerMain(Datum main_arg);
|
|
/*
|
* Per-database worker: connects to the database given in main_arg, runs a
|
* single compaction pass there and exits. Started dynamically by the
|
* launcher, one database at a time.
|
*/
|
extern void CfsBgWorkerDbMain(Datum main_arg);
|
|
/*
|
* CfsCompactRelationByOid — compact one CFS relation by its OID. This is the
|
* shared backend used by both the SQL function pg_cfs_compact(regclass) and
|
* the automatic background worker. Returns true on success.
|
* When out_result is non-NULL it is filled with compaction statistics.
|
*/
|
extern bool CfsCompactRelationByOid(Oid reloid, bool is_automatic,
|
CfsCompactResult *out_result);
|
|
#endif /* USE_CFS */
|
|
#endif /* CFS_BGWORKER_H */
|