Исходный код СУБД RuDB — свободной СУБД с открытым исходным кодом на базе PostgreSQL
rudb
2 days ago bd039d1e92813358c5c5a1e346b49074baf513f2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*-------------------------------------------------------------------------
 * 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 */