Skip to content

Commit 203b0d1

Browse files
committed
Improve error messages in reorderbuffer.c.
Be more clear about failure cases in relfilenode->relation lookup, and fix some other places that were inconsistent or not per our message style guidelines. Andres Freund and Tom Lane
1 parent 5ec45bb commit 203b0d1

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

src/backend/replication/logical/reorderbuffer.c

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1355,14 +1355,17 @@ ReorderBufferCommit(ReorderBuffer *rb, TransactionId xid,
13551355
change->data.tp.oldtuple == NULL)
13561356
continue;
13571357
else if (reloid == InvalidOid)
1358-
elog(ERROR, "could not lookup relation %s",
1359-
relpathperm(change->data.tp.relnode, MAIN_FORKNUM));
1358+
elog(ERROR, "could not map filenode \"%s\" to relation OID",
1359+
relpathperm(change->data.tp.relnode,
1360+
MAIN_FORKNUM));
13601361

13611362
relation = RelationIdGetRelation(reloid);
13621363

13631364
if (relation == NULL)
1364-
elog(ERROR, "could open relation descriptor %s",
1365-
relpathperm(change->data.tp.relnode, MAIN_FORKNUM));
1365+
elog(ERROR, "could not open relation with OID %u (for filenode \"%s\")",
1366+
reloid,
1367+
relpathperm(change->data.tp.relnode,
1368+
MAIN_FORKNUM));
13661369

13671370
if (RelationIsLogicallyLogged(relation))
13681371
{
@@ -1475,7 +1478,7 @@ ReorderBufferCommit(ReorderBuffer *rb, TransactionId xid,
14751478

14761479
/* this is just a sanity check against bad output plugin behaviour */
14771480
if (GetCurrentTransactionIdIfAny() != InvalidTransactionId)
1478-
elog(ERROR, "output plugin used xid %u",
1481+
elog(ERROR, "output plugin used XID %u",
14791482
GetCurrentTransactionId());
14801483

14811484
/* make sure there's no cache pollution */
@@ -1903,7 +1906,7 @@ ReorderBufferSerializeTXN(ReorderBuffer *rb, ReorderBufferTXN *txn)
19031906
Size spilled = 0;
19041907
char path[MAXPGPATH];
19051908

1906-
elog(DEBUG2, "spill %u changes in tx %u to disk",
1909+
elog(DEBUG2, "spill %u changes in XID %u to disk",
19071910
(uint32) txn->nentries_mem, txn->xid);
19081911

19091912
/* do the same to all child TXs */
@@ -2086,7 +2089,7 @@ ReorderBufferSerializeChange(ReorderBuffer *rb, ReorderBufferTXN *txn,
20862089
CloseTransientFile(fd);
20872090
ereport(ERROR,
20882091
(errcode_for_file_access(),
2089-
errmsg("could not write to xid %u's data file: %m",
2092+
errmsg("could not write to data file for XID %u: %m",
20902093
txn->xid)));
20912094
}
20922095

@@ -2189,7 +2192,7 @@ ReorderBufferRestoreChanges(ReorderBuffer *rb, ReorderBufferTXN *txn,
21892192
else if (readBytes != sizeof(ReorderBufferDiskChange))
21902193
ereport(ERROR,
21912194
(errcode_for_file_access(),
2192-
errmsg("incomplete read from reorderbuffer spill file: read %d instead of %u",
2195+
errmsg("incomplete read from reorderbuffer spill file: read %d instead of %u bytes",
21932196
readBytes,
21942197
(uint32) sizeof(ReorderBufferDiskChange))));
21952198

@@ -2209,7 +2212,7 @@ ReorderBufferRestoreChanges(ReorderBuffer *rb, ReorderBufferTXN *txn,
22092212
else if (readBytes != ondisk->size - sizeof(ReorderBufferDiskChange))
22102213
ereport(ERROR,
22112214
(errcode_for_file_access(),
2212-
errmsg("could not read from reorderbuffer spill file: read %d instead of %u",
2215+
errmsg("could not read from reorderbuffer spill file: read %d instead of %u bytes",
22132216
readBytes,
22142217
(uint32) (ondisk->size - sizeof(ReorderBufferDiskChange)))));
22152218

@@ -2815,7 +2818,7 @@ ApplyLogicalMappingFile(HTAB *tuplecid_data, Oid relid, const char *fname)
28152818
else if (readBytes != sizeof(LogicalRewriteMappingData))
28162819
ereport(ERROR,
28172820
(errcode_for_file_access(),
2818-
errmsg("could not read file \"%s\", read %d instead of %d",
2821+
errmsg("could not read from file \"%s\": read %d instead of %d bytes",
28192822
path, readBytes,
28202823
(int32) sizeof(LogicalRewriteMappingData))));
28212824

@@ -2928,7 +2931,7 @@ UpdateLogicalMappings(HTAB *tuplecid_data, Oid relid, Snapshot snapshot)
29282931
if (sscanf(mapping_de->d_name, LOGICAL_REWRITE_FORMAT,
29292932
&f_dboid, &f_relid, &f_hi, &f_lo,
29302933
&f_mapped_xid, &f_create_xid) != 6)
2931-
elog(ERROR, "could not parse fname %s", mapping_de->d_name);
2934+
elog(ERROR, "could not parse filename \"%s\"", mapping_de->d_name);
29322935

29332936
f_lsn = ((uint64) f_hi) << 32 | f_lo;
29342937

@@ -2971,7 +2974,7 @@ UpdateLogicalMappings(HTAB *tuplecid_data, Oid relid, Snapshot snapshot)
29712974
for(off = 0; off < list_length(files); off++)
29722975
{
29732976
RewriteMappingFile *f = files_a[off];
2974-
elog(DEBUG1, "applying mapping: %s in %u", f->fname,
2977+
elog(DEBUG1, "applying mapping: \"%s\" in %u", f->fname,
29752978
snapshot->subxip[0]);
29762979
ApplyLogicalMappingFile(tuplecid_data, relid, f->fname);
29772980
pfree(f);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy