PostgreSQL Source Code: src/backend/postmaster/bgwriter.c Source File (original) (raw)
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
33
54
55
56
57
59
60
61
62
63
64#define HIBERNATE_FACTOR 50
65
66
67
68
69
70#define LOG_SNAPSHOT_INTERVAL_MS 15000
71
72
73
74
75
76
79
80
81
82
83
84
85
86
87void
89{
90 sigjmp_buf local_sigjmp_buf;
92 bool prev_hibernate;
94
95 Assert(startup_data_len == 0);
96
99
100
101
102
106
111
112
113
114
116
117
118
119
120
122
123
124
125
126
127
128
130 "Background Writer",
133
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154 if (sigsetjmp(local_sigjmp_buf, 1) != 0)
155 {
156
158
159
161
162
164
165
166
167
168
169
179
180
181
182
183
186
187
189
190
192
193
195
196
197
198
199
200
202
203
205 }
206
207
209
210
211
212
213 sigprocmask(SIG_SETMASK, &UnBlockSig, NULL);
214
215
216
217
218 prev_hibernate = false;
219
220
221
222
223 for (;;)
224 {
225 bool can_hibernate;
226 int rc;
227
228
230
232
233
234
235
237
238
241
243 {
244
245
246
247
248
249
251 }
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
275 {
278
281
282
283
284
285
286
287
288
289 if (now >= timeout &&
291 {
294 }
295 }
296
297
298
299
300
301
302
303
304
305
306
309 BgWriterDelay , WAIT_EVENT_BGWRITER_MAIN);
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329 if (rc == WL_TIMEOUT && can_hibernate && prev_hibernate)
330 {
331
333
337 WAIT_EVENT_BGWRITER_HIBERNATE);
338
340 }
341
342 prev_hibernate = can_hibernate;
343 }
344}
void pgaio_error_cleanup(void)
void AuxiliaryProcessMainCommon(void)
TimestampTz GetCurrentTimestamp(void)
Datum now(PG_FUNCTION_ARGS)
static XLogRecPtr last_snapshot_lsn
static TimestampTz last_snapshot_ts
void BackgroundWriterMain(const void *startup_data, size_t startup_data_len)
#define LOG_SNAPSHOT_INTERVAL_MS
void AtEOXact_Buffers(bool isCommit)
bool BgBufferSync(WritebackContext *wb_context)
void WritebackContextInit(WritebackContext *context, int *max_pending)
bool FirstCallSinceLastCheckpoint(void)
bool ConditionVariableCancelSleep(void)
void AtEOXact_HashTables(bool isCommit)
void EmitErrorReport(void)
ErrorContextCallback * error_context_stack
void FlushErrorState(void)
sigjmp_buf * PG_exception_stack
void AtEOXact_Files(bool isCommit)
void StrategyNotifyBgWriter(int bgwprocno)
Assert(PointerIsAligned(start, uint64))
void SignalHandlerForShutdownRequest(SIGNAL_ARGS)
void ProcessMainLoopInterrupts(void)
void SignalHandlerForConfigReload(SIGNAL_ARGS)
void ResetLatch(Latch *latch)
int WaitLatch(Latch *latch, int wakeEvents, long timeout, uint32 wait_event_info)
void LWLockReleaseAll(void)
void MemoryContextReset(MemoryContext context)
MemoryContext TopMemoryContext
#define AllocSetContextCreate
#define ALLOCSET_DEFAULT_SIZES
#define RESUME_INTERRUPTS()
#define HOLD_INTERRUPTS()
BackendType MyBackendType
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
void pgstat_report_bgwriter(void)
void pgstat_report_wal(bool force)
void procsignal_sigusr1_handler(SIGNAL_ARGS)
void ReleaseAuxProcessResources(bool isCommit)
void pg_usleep(long microsec)
void smgrdestroyall(void)
XLogRecPtr LogStandbySnapshot(void)
#define TimestampTzPlusMilliseconds(tz, ms)
static void pgstat_report_wait_end(void)
#define WL_EXIT_ON_PM_DEATH
bool RecoveryInProgress(void)
XLogRecPtr GetLastImportantRecPtr(void)
#define XLogStandbyInfoActive()
#define InvalidXLogRecPtr