Hi, This is a follow-up to the issue described in thread https://www.postgresql.org/message-id/CAMbWs4-Mys%3DhBQSevTA8Zpd-TYFnb%3DXuHhN2TnktXMsfMUbjiQ%40mail.gmail.com
In short, during the first transaction starting phase within a backend, if there is an 'ereport' after setting transaction state but before saving CurrentUserId into 'prevUser' in TransactionStateData, 'prevUser' will remain as InvalidOid. Then in AbortTransaction(), CurrentUserId is restored with 'prevUser'. As a result, CurrentUserId will be InvalidOid in the rest of the session. Attached is a patch that fixes this issue. Thanks Richard
0001-Restore-CurrentUserId-only-if-prevUser-is-valid.patch
Description: Binary data