• Tom Lane's avatar
    Fix the logic for putting relations into the relcache init file. · 5d1ff6bd
    Tom Lane authored
    Commit f3b5565d was a couple of bricks shy
    of a load; specifically, it missed putting pg_trigger_tgrelid_tgname_index
    into the relcache init file, because that index is not used by any
    syscache.  However, we have historically nailed that index into cache for
    performance reasons.  The upshot was that load_relcache_init_file always
    decided that the init file was busted and silently ignored it, resulting
    in a significant hit to backend startup speed.
    
    To fix, reinstantiate RelationIdIsInInitFile() as a wrapper around
    RelationSupportsSysCache(), which can know about additional relations
    that should be in the init file despite being unknown to syscache.c.
    
    Also install some guards against future mistakes of this type: make
    write_relcache_init_file Assert that all nailed relations get written to
    the init file, and make load_relcache_init_file emit a WARNING if it takes
    the "wrong number of nailed relations" exit path.  Now that we remove the
    init files during postmaster startup, that case should never occur in the
    field, even if we are starting a minor-version update that added or removed
    rels from the nailed set.  So the warning shouldn't ever be seen by end
    users, but it will show up in the regression tests if somebody breaks this
    logic.
    
    Back-patch to all supported branches, like the previous commit.
    5d1ff6bd
relcache.c 164 KB