Commit da3751c8 authored by Tom Lane's avatar Tom Lane

Be more noisy about "wrong number of nailed relations" initfile problems.

In commit 5d1ff6bd I added some logic to
relcache.c to try to ensure that the regression tests would fail if we
made a mistake about which relations belong in the relcache init files.
I'm quite sure I tested that, but I must have done so only for the
non-shared-catalog case, because a report from Adam Brightwell showed that
the regression tests still pass just fine if we bollix the shared-catalog
init file in the way this code was supposed to catch.  The reason is that
that file gets loaded before we do client authentication, so the WARNING
is not sent to the client, only to the postmaster log, where it's far too
easily missed.

The least Rube Goldbergian answer to this is to put an Assert(false)
after the elog(WARNING).  That will certainly get developers' attention,
while not breaking production builds' ability to recover from corner
cases with similar symptoms.

Since this is only of interest to developers, there seems no need for
a back-patch, even though the previous commit went into all branches.
parent 80558c1f
...@@ -4910,6 +4910,12 @@ load_relcache_init_file(bool shared) ...@@ -4910,6 +4910,12 @@ load_relcache_init_file(bool shared)
* get the right number of nailed items? This is a useful crosscheck in * get the right number of nailed items? This is a useful crosscheck in
* case the set of critical rels or indexes changes. However, that should * case the set of critical rels or indexes changes. However, that should
* not happen in a normally-running system, so let's bleat if it does. * not happen in a normally-running system, so let's bleat if it does.
*
* For the shared init file, we're called before client authentication is
* done, which means that elog(WARNING) will go only to the postmaster
* log, where it's easily missed. To ensure that developers notice bad
* values of NUM_CRITICAL_SHARED_RELS/NUM_CRITICAL_SHARED_INDEXES, we put
* an Assert(false) there.
*/ */
if (shared) if (shared)
{ {
...@@ -4919,6 +4925,9 @@ load_relcache_init_file(bool shared) ...@@ -4919,6 +4925,9 @@ load_relcache_init_file(bool shared)
elog(WARNING, "found %d nailed shared rels and %d nailed shared indexes in init file, but expected %d and %d respectively", elog(WARNING, "found %d nailed shared rels and %d nailed shared indexes in init file, but expected %d and %d respectively",
nailed_rels, nailed_indexes, nailed_rels, nailed_indexes,
NUM_CRITICAL_SHARED_RELS, NUM_CRITICAL_SHARED_INDEXES); NUM_CRITICAL_SHARED_RELS, NUM_CRITICAL_SHARED_INDEXES);
/* Make sure we get developers' attention about this */
Assert(false);
/* In production builds, recover by bootstrapping the relcache */
goto read_failed; goto read_failed;
} }
} }
...@@ -4930,6 +4939,7 @@ load_relcache_init_file(bool shared) ...@@ -4930,6 +4939,7 @@ load_relcache_init_file(bool shared)
elog(WARNING, "found %d nailed rels and %d nailed indexes in init file, but expected %d and %d respectively", elog(WARNING, "found %d nailed rels and %d nailed indexes in init file, but expected %d and %d respectively",
nailed_rels, nailed_indexes, nailed_rels, nailed_indexes,
NUM_CRITICAL_LOCAL_RELS, NUM_CRITICAL_LOCAL_INDEXES); NUM_CRITICAL_LOCAL_RELS, NUM_CRITICAL_LOCAL_INDEXES);
/* We don't need an Assert() in this case */
goto read_failed; goto read_failed;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment