Forget close an open relation in ReorderBufferProcessTXN() - Mailing list pgsql-hackers

From Japin Li
Subject Forget close an open relation in ReorderBufferProcessTXN()
Date
Msg-id MEYP282MB166933B1AB02B4FE56E82453B64D9@MEYP282MB1669.AUSP282.PROD.OUTLOOK.COM
Whole thread Raw
Responses Re: Forget close an open relation in ReorderBufferProcessTXN()
List pgsql-hackers
The RelationIdGetRelation() comment says:

> Caller should eventually decrement count. (Usually,
> that happens by calling RelationClose().)

However, it doesn't do it in ReorderBufferProcessTXN().
I think we should close it, here is a patch that fixes it. Thoughts?

-- 
Regrads,
Japin Li.
ChengDu WenWu Information Technology Co.,Ltd.


diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c
index 52d06285a2..aac6ffc602 100644
--- a/src/backend/replication/logical/reorderbuffer.c
+++ b/src/backend/replication/logical/reorderbuffer.c
@@ -2261,7 +2261,10 @@ ReorderBufferProcessTXN(ReorderBuffer *rb, ReorderBufferTXN *txn,
                                                                elog(ERROR, "could not open relation with OID %u",
relid);

                                                        if (!RelationIsLogicallyLogged(relation))
+                                                       {
+                                                               RelationClose(relation);
                                                                continue;
+                                                       }

                                                        relations[nrelations++] = relation;
                                                }



pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: Truncate in synchronous logical replication failed
Next
From: Julien Rouhaud
Date:
Subject: Re: Bogus collation version recording in recordMultipleDependencies