Skip to content

Commit 9cde0f9

Browse files
committed
Modify tablespace preflight checks (as per comment by Roman Zharkov)
1 parent 8a9c6ce commit 9cde0f9

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/catchup.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,8 @@ catchup_preflight_checks(PGNodeInfo *source_node_info, PGconn *source_conn,
219219
if (current.from_replica && exclusive_backup)
220220
elog(ERROR, "Catchup from standby is only available for PostgreSQL >= 9.6");
221221

222-
/* if local catchup, check that we don't overwrite tablespace in source pgdata */
223-
if (!fio_is_remote(FIO_DB_HOST))
224-
catchup_check_tablespaces_existance_in_tbsmapping(source_conn);
222+
/* check that we don't overwrite tablespace in source pgdata */
223+
catchup_check_tablespaces_existance_in_tbsmapping(source_conn);
225224

226225
/* check timelines */
227226
if (current.backup_mode != BACKUP_MODE_FULL)
@@ -246,7 +245,7 @@ catchup_preflight_checks(PGNodeInfo *source_node_info, PGconn *source_conn,
246245

247246
/*
248247
* Check that all tablespaces exists in tablespace mapping (--tablespace-mapping option)
249-
* Check that all local mapped directories is empty if it is local catchup
248+
* Check that all local mapped directories is empty if it is local FULL catchup
250249
* Emit fatal error if that (not existent in map or not empty) tablespace found
251250
*/
252251
static void
@@ -274,17 +273,23 @@ catchup_check_tablespaces_existance_in_tbsmapping(PGconn *conn)
274273
linked_path = get_tablespace_mapping(tablespace_path);
275274

276275
if (strcmp(tablespace_path, linked_path) == 0)
277-
/* same result -> not found in mapping */
278-
elog(ERROR, "Local catchup executed, but source database contains "
279-
"tablespace (\"%s\"), that is not listed in the map", tablespace_path);
276+
/* same result -> not found in mapping */
277+
{
278+
if (!fio_is_remote(FIO_DB_HOST))
279+
elog(ERROR, "Local catchup executed, but source database contains "
280+
"tablespace (\"%s\"), that is not listed in the map", tablespace_path);
281+
else
282+
elog(WARNING, "Remote catchup executed and source database contains "
283+
"tablespace (\"%s\"), that is not listed in the map", tablespace_path);
284+
}
280285

281286
if (!is_absolute_path(linked_path))
282287
elog(ERROR, "Tablespace directory path must be an absolute path: \"%s\"",
283288
linked_path);
284289

285290
if (current.backup_mode == BACKUP_MODE_FULL
286291
&& !dir_is_empty(linked_path, FIO_LOCAL_HOST))
287-
elog(ERROR, "Target mapped tablespace directory (\"%s\") is not empty in local catchup",
292+
elog(ERROR, "Target mapped tablespace directory (\"%s\") is not empty in FULL catchup",
288293
linked_path);
289294
}
290295
PQclear(res);

0 commit comments

Comments
 (0)