aboutsummaryrefslogtreecommitdiff
path: root/src/include/commands/waitlsn.h
blob: 10ef63f0c096c7298f1d5241301beb792e173078 (plain)
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
/*-------------------------------------------------------------------------
 *
 * waitlsn.h
 *	  Declarations for LSN waiting routines.
 *
 * Copyright (c) 2024, PostgreSQL Global Development Group
 *
 * src/include/commands/waitlsn.h
 *
 *-------------------------------------------------------------------------
 */
#ifndef WAIT_LSN_H
#define WAIT_LSN_H

#include "postgres.h"
#include "port/atomics.h"
#include "storage/spin.h"
#include "tcop/dest.h"

/* Shared memory structures */
typedef struct WaitLSNProcInfo
{
	int			procnum;
	XLogRecPtr	waitLSN;
} WaitLSNProcInfo;

typedef struct WaitLSNState
{
	pg_atomic_uint64 minLSN;
	slock_t		mutex;
	int			numWaitedProcs;
	WaitLSNProcInfo procInfos[FLEXIBLE_ARRAY_MEMBER];
} WaitLSNState;

extern PGDLLIMPORT struct WaitLSNState *waitLSN;

extern void WaitForLSN(XLogRecPtr targetLSN, int64 timeout);
extern Size WaitLSNShmemSize(void);
extern void WaitLSNShmemInit(void);
extern void WaitLSNSetLatches(XLogRecPtr currentLSN);
extern void WaitLSNCleanup(void);

#endif							/* WAIT_LSN_H */