Hi Michael,
> In terms of implementation simplicity, I see more merit with the existing
> logic where we don't add a PID tracking because it's well, simpler!
OK, v10 drops the PID from the stats entry. v10-0001 is the permission
patch, and the entry stores only the role of the backend. That is enough
for the snapshot case upthread. The old entry keeps the role of the old
backend, so u1 gets nothing from it. I checked it with the same script.
> The role ID case is different: we want consistency to check for the
> permissions.
v10-0002 is optional and follows that idea for Bertrand's point on
pg_stat_get_backend_subxact(). The role is checked from the copied status
entry, but the subxact counters are read from PGPROC in a second step.
The PID check makes sure both come from the same backend. Your call.
Thanks,
Shihao