From: | Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-hackers(at)postgreSQL(dot)org |
Subject: | Re: CreateFakeRelcacheEntry versus Hot Standby |
Date: | 2010-02-09 20:03:41 |
Message-ID: | 4B71BF9D.3020109@enterprisedb.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Tom Lane wrote:
> I was rather surprised to find this code still present:
>
> /*
> * We set up the lockRelId in case anything tries to lock the dummy
> * relation. Note that this is fairly bogus since relNode may be
> * different from the relation's OID. It shouldn't really matter though,
> * since we are presumably running by ourselves and can't have any lock
> * conflicts ...
> */
> rel->rd_lockInfo.lockRelId.dbId = rnode.dbNode;
> rel->rd_lockInfo.lockRelId.relId = rnode.relNode;
>
> Seems quite unsafe in HS.
Good catch.
I started looking at the callers of CreateFakeRelcacheEntry to see if
any of them actually take a lock on the Relation. It seems not, so maybe
we should just set those to InvalidOid, and add an
Assert(OidIsValid(dbId) && OidIsValid(relId)) to LockAcquire() to ensure
that a fake relcache entry is not used to grab locks in the future either.
However, I spotted another bug. In ginContinueSplit(), we call
CreateFakeRelcacheEntry(), and pass the fake relcache entry to
prepareEntryScan() or prepareDataScan(). Those functions store the
passed-in Relation ptr in the passed in GinBtreeData struct. After the
call, we free the fake relcache entry, but the pointer is still present
in the GinBtreeData. The findParents() call later in the function uses
it, and will thus access free'd memory.
A trivial fix is to delay freeing the fake relcache entry in
ginContinueSplit(). But this once again shows that our WAL redo
functions are not as well tested as they should be, and the WAL redo
cleanup functions in particularly.
--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com
From | Date | Subject | |
---|---|---|---|
Next Message | Marko Tiikkaja | 2010-02-09 20:13:17 | Re: Writeable CTEs patch |
Previous Message | Greg Stark | 2010-02-09 19:50:19 | Some belated patch review for "Buffers" explain analyze patch |