Commit d6e98ebe authored by Michael Paquier's avatar Michael Paquier

Improve some error message strings and errcodes

This makes a bit less work for translators, by unifying error strings a
bit more with what the rest of the code does, this time for three error
strings in autoprewarm and one in base backup code.

After some code review of slot.c, some file-access errcodes are reported
but lead to an incorrect internal error, while corrupted data makes the
most sense, similarly to the previous work done in e41d0a10.  Also,
after calling rmtree(), a WARNING gets reported, which is a duplicate of
what the internal call report, so make the code more consistent with all
other code paths calling this function.

Author: Michael Paquier
Discussion: https://postgr.es/m/20180902200747.GC1343@paquier.xyz
parent 17b7c302
...@@ -641,7 +641,7 @@ apw_dump_now(bool is_bgworker, bool dump_unlogged) ...@@ -641,7 +641,7 @@ apw_dump_now(bool is_bgworker, bool dump_unlogged)
errno = save_errno; errno = save_errno;
ereport(ERROR, ereport(ERROR,
(errcode_for_file_access(), (errcode_for_file_access(),
errmsg("could not write to file \"%s\" : %m", errmsg("could not write to file \"%s\": %m",
transient_dump_file_path))); transient_dump_file_path)));
} }
...@@ -664,7 +664,7 @@ apw_dump_now(bool is_bgworker, bool dump_unlogged) ...@@ -664,7 +664,7 @@ apw_dump_now(bool is_bgworker, bool dump_unlogged)
errno = save_errno; errno = save_errno;
ereport(ERROR, ereport(ERROR,
(errcode_for_file_access(), (errcode_for_file_access(),
errmsg("could not write to file \"%s\" : %m", errmsg("could not write to file \"%s\": %m",
transient_dump_file_path))); transient_dump_file_path)));
} }
} }
...@@ -684,7 +684,7 @@ apw_dump_now(bool is_bgworker, bool dump_unlogged) ...@@ -684,7 +684,7 @@ apw_dump_now(bool is_bgworker, bool dump_unlogged)
errno = save_errno; errno = save_errno;
ereport(ERROR, ereport(ERROR,
(errcode_for_file_access(), (errcode_for_file_access(),
errmsg("could not close file \"%s\" : %m", errmsg("could not close file \"%s\": %m",
transient_dump_file_path))); transient_dump_file_path)));
} }
......
...@@ -333,7 +333,7 @@ perform_base_backup(basebackup_options *opt) ...@@ -333,7 +333,7 @@ perform_base_backup(basebackup_options *opt)
if (lstat(XLOG_CONTROL_FILE, &statbuf) != 0) if (lstat(XLOG_CONTROL_FILE, &statbuf) != 0)
ereport(ERROR, ereport(ERROR,
(errcode_for_file_access(), (errcode_for_file_access(),
errmsg("could not stat control file \"%s\": %m", errmsg("could not stat file \"%s\": %m",
XLOG_CONTROL_FILE))); XLOG_CONTROL_FILE)));
sendFile(XLOG_CONTROL_FILE, XLOG_CONTROL_FILE, &statbuf, false); sendFile(XLOG_CONTROL_FILE, XLOG_CONTROL_FILE, &statbuf, false);
} }
......
...@@ -628,8 +628,7 @@ ReplicationSlotDropPtr(ReplicationSlot *slot) ...@@ -628,8 +628,7 @@ ReplicationSlotDropPtr(ReplicationSlot *slot)
*/ */
if (!rmtree(tmppath, true)) if (!rmtree(tmppath, true))
ereport(WARNING, ereport(WARNING,
(errcode_for_file_access(), (errmsg("could not remove directory \"%s\"", tmppath)));
errmsg("could not remove directory \"%s\"", tmppath)));
/* /*
* We release this at the very end, so that nobody starts trying to create * We release this at the very end, so that nobody starts trying to create
...@@ -1132,8 +1131,8 @@ StartupReplicationSlots(void) ...@@ -1132,8 +1131,8 @@ StartupReplicationSlots(void)
if (!rmtree(path, true)) if (!rmtree(path, true))
{ {
ereport(WARNING, ereport(WARNING,
(errcode_for_file_access(), (errmsg("could not remove directory \"%s\"",
errmsg("could not remove directory \"%s\"", path))); path)));
continue; continue;
} }
fsync_fname("pg_replslot", true); fsync_fname("pg_replslot", true);
...@@ -1432,21 +1431,21 @@ RestoreSlotFromDisk(const char *name) ...@@ -1432,21 +1431,21 @@ RestoreSlotFromDisk(const char *name)
/* verify magic */ /* verify magic */
if (cp.magic != SLOT_MAGIC) if (cp.magic != SLOT_MAGIC)
ereport(PANIC, ereport(PANIC,
(errcode_for_file_access(), (errcode(ERRCODE_DATA_CORRUPTED),
errmsg("replication slot file \"%s\" has wrong magic number: %u instead of %u", errmsg("replication slot file \"%s\" has wrong magic number: %u instead of %u",
path, cp.magic, SLOT_MAGIC))); path, cp.magic, SLOT_MAGIC)));
/* verify version */ /* verify version */
if (cp.version != SLOT_VERSION) if (cp.version != SLOT_VERSION)
ereport(PANIC, ereport(PANIC,
(errcode_for_file_access(), (errcode(ERRCODE_DATA_CORRUPTED),
errmsg("replication slot file \"%s\" has unsupported version %u", errmsg("replication slot file \"%s\" has unsupported version %u",
path, cp.version))); path, cp.version)));
/* boundary check on length */ /* boundary check on length */
if (cp.length != ReplicationSlotOnDiskV2Size) if (cp.length != ReplicationSlotOnDiskV2Size)
ereport(PANIC, ereport(PANIC,
(errcode_for_file_access(), (errcode(ERRCODE_DATA_CORRUPTED),
errmsg("replication slot file \"%s\" has corrupted length %u", errmsg("replication slot file \"%s\" has corrupted length %u",
path, cp.length))); path, cp.length)));
...@@ -1496,8 +1495,8 @@ RestoreSlotFromDisk(const char *name) ...@@ -1496,8 +1495,8 @@ RestoreSlotFromDisk(const char *name)
if (!rmtree(slotdir, true)) if (!rmtree(slotdir, true))
{ {
ereport(WARNING, ereport(WARNING,
(errcode_for_file_access(), (errmsg("could not remove directory \"%s\"",
errmsg("could not remove directory \"%s\"", slotdir))); slotdir)));
} }
fsync_fname("pg_replslot", true); fsync_fname("pg_replslot", true);
return; return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment