Probable bug with CreateFakeRelcacheEntry - Mailing list pgsql-bugs

From Jeff Davis
Subject Probable bug with CreateFakeRelcacheEntry
Date
Msg-id 1347327239.4161.20.camel@sussancws0025
Whole thread Raw
Responses Re: Probable bug with CreateFakeRelcacheEntry (now with reproducible test case)  (Jeff Davis <pgsql@j-davis.com>)
List 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

pgsql-bugs by date:

Previous
From: Mike Toews
Date:
Subject: Re: initdb.exe changes --locale option
Next
From: Dave Page
Date:
Subject: Re: initdb.exe changes --locale option