Wrong usage of RelationNeedsWAL
Kyotaro Horiguchi <horikyota.ntt@gmail.com>
From: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
To: pgsql-hackers@postgresql.org
Date: 2021-01-13T07:07:05Z
Lists: pgsql-hackers
Attachments
- 0001-Fix-misuses-of-RelationNeedsWAL.patch (text/x-patch)
Hello.
Commit c6b92041d3 changed the definition of RelationNeedsWAL().
-#define RelationNeedsWAL(relation) \
- ((relation)->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+#define RelationNeedsWAL(relation) \
+ ((relation)->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT && \
+ (XLogIsNeeded() || \
+ (relation->rd_createSubid == InvalidSubTransactionId && \
+ relation->rd_firstRelfilenodeSubid == InvalidSubTransactionId)))
On the other hand I found this usage.
plancat.c:128 get_relation_info()
> /* Temporary and unlogged relations are inaccessible during recovery. */
> if (!RelationNeedsWAL(relation) && RecoveryInProgress())
> ereport(ERROR,
> (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
> errmsg("cannot access temporary or unlogged relations during recovery")));
It works as expected accidentally, but the meaning is off.
WAL-skipping optmization is irrelevant to the condition for the error.
I found five misues in the tree. Please find the attached.
regards.
--
Kyotaro Horiguchi
NTT Open Source Software Center
Commits
-
Revive "snapshot too old" with wal_level=minimal and SET TABLESPACE.
- d798ea750d22 13.2 landed
- 7da83415e5bc 14.0 landed
-
Fix error with CREATE PUBLICATION, wal_level=minimal, and new tables.
- e8e3e67490f5 13.2 landed
- 360bd2321b1a 14.0 landed
-
Skip WAL for new relfilenodes, under wal_level=minimal.
- c6b92041d385 13.0 cited