Probable bug with CreateFakeRelcacheEntry

From: Jeff Davis <pgsql(at)j-davis(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: Probable bug with CreateFakeRelcacheEntry
Date: 2012-09-11 01:33:59
Message-ID: 1347327239.4161.20.camel@sussancws0025
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

I haven't produced a real problem in a small test case (yet), but I
convinced myself that it's wrong enough to be called a bug.

If you add the following assertion to BufferAlloc:

Assert(relpersistence == RELPERSISTENCE_PERMANENT ||
relpersistence == RELPERSISTENCE_UNLOGGED ||
relpersistence == RELPERSISTENCE_TEMP);

(which seems like a reasonable assertion to me), then do:

create table foo(i int);
insert into foo values(1);
vacuum foo;
vacuum foo;
insert into foo values(2);

Then do an immediate shutdown, then restart, you hit the assertion.

The problem is using CreateFakeRelcacheEntry, which has the following
comment:

Only the fields related to physical storage, like rd_rel, are
initialized, so the fake entry is only usable in low-level
operations like ReadBuffer().

That doesn't seem right, because ReadBuffer needs relpersistence set.

One of the consequences is that you can get buffers with the wrong flags
set; in particular, missing BM_PERMANENT, which seems like it could be a
serious problem.

Are there other areas where we might have similar problems?

Regards,
Jeff Davis

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Dave Page 2012-09-11 02:54:02 Re: initdb.exe changes --locale option
Previous Message Mike Toews 2012-09-10 22:36:17 Re: initdb.exe changes --locale option