Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6d66058

Browse files
committed
Revise bgwriter fsync-request mechanism to improve robustness when a table
is deleted. A backend about to unlink a file now sends a "revoke fsync"request to the bgwriter to make it clean out pending fsync requests. Thereis still a race condition where the bgwriter may try to fsync after the unlinkhas happened, but we can resolve that by rechecking the fsync request queueto see if a revoke request arrived meanwhile. This eliminates the formerkluge of "just assuming" that an ENOENT failure is okay, and lets us handlethe fact that on Windows it might be EACCES too without introducing anyquestionable assumptions. After an idea of mine improved by Magnus.The HEAD patch doesn't apply cleanly to 8.2, but I'll see about a back-portlater. In the meantime this could do with some testing on Windows; I've beenable to force it through the code path via ENOENT, but that doesn't prove thatit actually fixes the Windows problem ...
1 parent7f58ed1 commit6d66058

File tree

2 files changed

+213
-98
lines changed

2 files changed

+213
-98
lines changed

‎src/backend/postmaster/bgwriter.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
*
33
* bgwriter.c
44
*
5-
* The background writer (bgwriter) is newin Postgres 8.0. It attempts
5+
* The background writer (bgwriter) is newas of Postgres 8.0. It attempts
66
* to keep regular backends from having to write out dirty shared buffers
77
* (which they would only do when needing to free a shared buffer to read in
88
* another page). In the best scenario all writes from shared buffers will
@@ -37,7 +37,7 @@
3737
*
3838
*
3939
* IDENTIFICATION
40-
* $PostgreSQL: pgsql/src/backend/postmaster/bgwriter.c,v 1.34 2007/01/05 22:19:36 momjian Exp $
40+
* $PostgreSQL: pgsql/src/backend/postmaster/bgwriter.c,v 1.35 2007/01/17 00:17:20 tgl Exp $
4141
*
4242
*-------------------------------------------------------------------------
4343
*/
@@ -103,8 +103,8 @@
103103
typedefstruct
104104
{
105105
RelFileNodernode;
106-
BlockNumbersegno;
107-
/* might add a request-type field later */
106+
BlockNumbersegno;/* InvalidBlockNumber means "revoke" */
107+
/* might add arealrequest-type field later; not needed yet */
108108
}BgWriterRequest;
109109

110110
typedefstruct
@@ -695,6 +695,11 @@ RequestCheckpoint(bool waitforit, bool warnontime)
695695
* ForwardFsyncRequest
696696
*Forward a file-fsync request from a backend to the bgwriter
697697
*
698+
* segno specifies which segment (not block!) of the relation needs to be
699+
* fsync'd. If segno == InvalidBlockNumber, the meaning is to revoke any
700+
* pending fsync requests for the entire relation (this message is sent
701+
* when the relation is about to be deleted).
702+
*
698703
* Whenever a backend is compelled to write directly to a relation
699704
* (which should be seldom, if the bgwriter is getting its job done),
700705
* the backend calls this routine to pass over knowledge that the relation

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp