From: | Andy Fan <zhihui(dot)fan1213(at)gmail(dot)com> |
---|---|
To: | Robert Haas <robertmhaas(at)gmail(dot)com> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Dilip Kumar <dilipbalaut(at)gmail(dot)com> |
Subject: | Re: Can I assume relation would not be invalid during from ExecutorRun to ExecutorEnd |
Date: | 2021-12-02 03:58:41 |
Message-ID: | CAKU4AWqo0nvtV7E99sS3hbufEJA7Wn1+Rz=oDgPrsxTYsipJoA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
> If the relation is open,
> the relcache entry can't be destroyed altogether, but it can be
> rebuilt: see RelationClearRelation().
Thanks! This is a new amazing knowledge for me!
> They are in fact stable in a certain sense - if we have the relation open
we hold a reference count on it, and so the Relation pointer itself will
remain valid.
This sounds amazing as well.
> But
> the data it points to can change in various ways, and different
> members of the RelationData struct are handled differently. Separately
> from the reference count, the heavyweight lock that we also hold on
> the relation as a condition of opening it prevents certain kinds of
> changes, so that even if the relation cache entry is rebuilt, certain
> particular fields will be unaffected. Which fields are protected in
> this way will depend on what kind of lock is held. It's hard to speak
> in general terms.
Amazing++;
> The best advice I can give you is (1) look exactly
> what RelationClearRelation() is going to do to the fields you care
> about if a rebuild happens, (2) err on the side of assuming that
> things can change under you, and (3) try running your code under
> debug_discard_caches = 1. It will be slow that way, but it's pretty
> effective in finding places where you've made unsafe assumptions.
>
>
Thanks! I clearly understand what's wrong in my previous knowledge.
That is, after a relation is open with some lock, then the content of the
relation
will never change until the RelationClose. It would take time to fill the
gap, but I'd like to say "thank you!" first.
--
Best Regards
Andy Fan
From | Date | Subject | |
---|---|---|---|
Next Message | houzj.fnst@fujitsu.com | 2021-12-02 03:59:07 | RE: row filtering for logical replication |
Previous Message | Justin Pryzby | 2021-12-02 03:34:39 | Re: GUC flags |