On 04/08/2018 02:01 AM, Andrew Gierth wrote: > Chapman> (d) some other reason I haven't thought of ? > > It has to be pushed as the active snapshot so that it's the snapshot > that the executor uses to run the query to populate the tuplestore which > becomes the "held" portal content.
That seems closest to my (b) guess. > I think you're confusing the stack of active snapshots with the registry > of snapshots. The snapshot of a portal that's not currently running in > the executor won't be on the stack, but it will be registered (which is > enough to maintain the session's reported xmin, which is what prevents > visible data from being vacuumed away). That's why I was asking. The first paragraph in snapmgr.c seems to say that the registry and the active stack both exist as ways to keep the snapshot alive, with reachability from either one being sufficient: * We keep track of snapshots in two ways: those "registered" by * resowner.c, and the "active snapshot" stack. All snapshots in * either of them live in persistent memory. When a snapshot is * no longer in any of these lists (tracked by separate refcounts * on each snapshot), its memory can be freed. AFAICS, that is *all* that comment block has to say about why there's an active snapshot stack. I believe you are saying it has another important function, namely that its top element is what tells the executor what can be seen. That makes sense, and to clarify that was why I was asking. I suppose the reason that's not mentioned in the comments is that it was so obviously the ultimate purpose of the whole scheme that nobody writing or reviewing the comments could imagine not knowing it. :) -Chap