summaryrefslogtreecommitdiff
path: root/src/backend/commands
diff options
context:
space:
mode:
authorAlvaro Herrera2022-03-29 13:36:21 +0000
committerAlvaro Herrera2022-03-29 13:36:21 +0000
commitbf902c13930c268388644100663f2998868b6e85 (patch)
tree92715e94f33cb0d1fd9dc4f5acb2bf3daaf031a5 /src/backend/commands
parentedea649afbcedd431802a5255cd153538e43ee1d (diff)
Revert "Fix replay of create database records on standby"
This reverts commit 49d9cfc68bf4. The approach taken by this patch has problems, so we'll come up with a radically different fix. Discussion: https://postgr.es/m/CA+TgmoYcUPL+WOJL2ZzhH=zmrhj0iOQ=iCFM0SuYqBbqZEamEg@mail.gmail.com
Diffstat (limited to 'src/backend/commands')
-rw-r--r--src/backend/commands/dbcommands.c57
-rw-r--r--src/backend/commands/tablespace.c17
2 files changed, 0 insertions, 74 deletions
diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c
index 95771b06a2e..623e5ec7789 100644
--- a/src/backend/commands/dbcommands.c
+++ b/src/backend/commands/dbcommands.c
@@ -30,7 +30,6 @@
#include "access/tableam.h"
#include "access/xact.h"
#include "access/xloginsert.h"
-#include "access/xlogrecovery.h"
#include "access/xlogutils.h"
#include "catalog/catalog.h"
#include "catalog/dependency.h"
@@ -2484,9 +2483,7 @@ dbase_redo(XLogReaderState *record)
xl_dbase_create_rec *xlrec = (xl_dbase_create_rec *) XLogRecGetData(record);
char *src_path;
char *dst_path;
- char *parent_path;
struct stat st;
- bool skip = false;
src_path = GetDatabasePath(xlrec->src_db_id, xlrec->src_tablespace_id);
dst_path = GetDatabasePath(xlrec->db_id, xlrec->tablespace_id);
@@ -2504,56 +2501,6 @@ dbase_redo(XLogReaderState *record)
(errmsg("some useless files may be left behind in old database directory \"%s\"",
dst_path)));
}
- else if (!reachedConsistency)
- {
- /*
- * It is possible that a drop tablespace record appearing later in
- * WAL has already been replayed -- in other words, that we are
- * replaying the database creation record a second time with no
- * intervening checkpoint. In that case, the tablespace directory
- * has already been removed and the create database operation
- * cannot be replayed. Skip the replay itself, but remember the
- * fact that the tablespace directory is missing, to be matched
- * with the expected tablespace drop record later.
- */
- parent_path = pstrdup(dst_path);
- get_parent_directory(parent_path);
- if (!(stat(parent_path, &st) == 0 && S_ISDIR(st.st_mode)))
- {
- XLogRememberMissingDir(xlrec->tablespace_id, InvalidOid, parent_path);
- skip = true;
- ereport(WARNING,
- (errmsg("skipping replay of database creation WAL record"),
- errdetail("The target tablespace \"%s\" directory was not found.",
- parent_path),
- errhint("A future WAL record that removes the directory before reaching consistent mode is expected.")));
- }
- pfree(parent_path);
- }
-
- /*
- * If the source directory is missing, skip the copy and make a note of
- * it for later.
- *
- * One possible reason for this is that the template database used for
- * creating this database may have been dropped, as noted above.
- * Moving a database from one tablespace may also be a partner in the
- * crime.
- */
- if (!(stat(src_path, &st) == 0 && S_ISDIR(st.st_mode)) &&
- !reachedConsistency)
- {
- XLogRememberMissingDir(xlrec->src_tablespace_id, xlrec->src_db_id, src_path);
- skip = true;
- ereport(WARNING,
- (errmsg("skipping replay of database creation WAL record"),
- errdetail("The source database directory \"%s\" was not found.",
- src_path),
- errhint("A future WAL record that removes the directory before reaching consistent mode is expected.")));
- }
-
- if (skip)
- return;
/*
* Force dirty buffers out to disk, to ensure source database is
@@ -2616,10 +2563,6 @@ dbase_redo(XLogReaderState *record)
ereport(WARNING,
(errmsg("some useless files may be left behind in old database directory \"%s\"",
dst_path)));
-
- if (!reachedConsistency)
- XLogForgetMissingDir(xlrec->tablespace_ids[i], xlrec->db_id);
-
pfree(dst_path);
}
diff --git a/src/backend/commands/tablespace.c b/src/backend/commands/tablespace.c
index 55f40831da9..40514ab550f 100644
--- a/src/backend/commands/tablespace.c
+++ b/src/backend/commands/tablespace.c
@@ -57,7 +57,6 @@
#include "access/tableam.h"
#include "access/xact.h"
#include "access/xloginsert.h"
-#include "access/xlogrecovery.h"
#include "access/xlogutils.h"
#include "catalog/catalog.h"
#include "catalog/dependency.h"
@@ -1575,22 +1574,6 @@ tblspc_redo(XLogReaderState *record)
{
xl_tblspc_drop_rec *xlrec = (xl_tblspc_drop_rec *) XLogRecGetData(record);
- if (!reachedConsistency)
- XLogForgetMissingDir(xlrec->ts_id, InvalidOid);
-
- /*
- * Before we remove the tablespace directory, update minimum recovery
- * point to cover this WAL record. Once the tablespace is removed,
- * there's no going back. This manually enforces the WAL-first rule.
- * Doing this before the removal means that if the removal fails for
- * some reason, the directory is left alone and needs to be manually
- * removed. Alternatively we could update the minimum recovery point
- * after removal, but that would leave a small window where the
- * WAL-first rule could be violated.
- */
- if (!reachedConsistency)
- XLogFlush(record->EndRecPtr);
-
/*
* If we issued a WAL record for a drop tablespace it implies that
* there were no files in it at all when the DROP was done. That means