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

Commit33f80f8

Browse files
committed
Drop no-longer-needed buffers during ALTER DATABASE SET TABLESPACE.
The previous coding assumed that we could just let buffers for thedatabase's old tablespace age out of the buffer arena naturally.The folly of that is exposed by bug #11867 from Marc Munro: the user couldlater move the database back to its original tablespace, after which anystill-surviving buffers would match lookups again and appear to containvalid data. But they'd be missing any changes applied while the databasewas in the new tablespace.This has been broken since ALTER SET TABLESPACE was introduced, soback-patch to all supported branches.
1 parent5028f22 commit33f80f8

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

‎src/backend/commands/dbcommands.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,6 +1153,23 @@ movedb(const char *dbname, const char *tblspcname)
11531153
RequestCheckpoint(CHECKPOINT_IMMEDIATE |CHECKPOINT_FORCE |CHECKPOINT_WAIT
11541154
|CHECKPOINT_FLUSH_ALL);
11551155

1156+
/*
1157+
* Now drop all buffers holding data of the target database; they should
1158+
* no longer be dirty so DropDatabaseBuffers is safe.
1159+
*
1160+
* It might seem that we could just let these buffers age out of shared
1161+
* buffers naturally, since they should not get referenced anymore. The
1162+
* problem with that is that if the user later moves the database back to
1163+
* its original tablespace, any still-surviving buffers would appear to
1164+
* contain valid data again --- but they'd be missing any changes made in
1165+
* the database while it was in the new tablespace. In any case, freeing
1166+
* buffers that should never be used again seems worth the cycles.
1167+
*
1168+
* Note: it'd be sufficient to get rid of buffers matching db_id and
1169+
* src_tblspcoid, but bufmgr.c presently provides no API for that.
1170+
*/
1171+
DropDatabaseBuffers(db_id);
1172+
11561173
/*
11571174
* Check for existence of files in the target directory, i.e., objects of
11581175
* this database that are already in the target tablespace. We can't

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp