Fix for segfault in logical replication on master
Mark Dilger <mark.dilger@enterprisedb.com>
From: Mark Dilger <mark.dilger@enterprisedb.com>
To: akapila@postgresql.org,
"osumi.takamichi@fujitsu.com" <osumi.takamichi@fujitsu.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2021-06-17T04:31:22Z
Lists: pgsql-hackers
Attachments
- v1-0001-Fixing-bug-in-logical-replication.patch (application/octet-stream) patch v1-0001
- (unnamed) (text/plain)
Hi Amit,
In commit e7eea52b2d, you introduced a new function, RelationGetIdentityKeyBitmap(), which uses some odd logic for determining if a relation has a replica identity index. That code segfaults under certain conditions. A test case to demonstrate that is attached. Prior to patching the code, this new test gets stuck waiting for replication to finish, which never happens. You have to break out of the test and check tmp_check/log/021_no_replica_identity_publisher.log.
I believe this bit of logic in src/backend/utils/cache/relcache.c:
indexDesc = RelationIdGetRelation(relation->rd_replidindex);
for (i = 0; i < indexDesc->rd_index->indnatts; i++)
is unsafe without further checks, also attached.
Would you mind taking a look?
Commits
-
Improve RelationGetIdentityKeyBitmap().
- ee3fdb8f3465 14.0 landed
-
Handle no replica identity index case in RelationGetIdentityKeyBitmap.
- 2731ce1bd550 14.0 landed
-
Fix Logical Replication of Truncate in synchronous commit mode.
- e7eea52b2d61 14.0 cited