(unnamed)

text/html

Filename: (unnamed)
Type: text/html
Part: 0
Message: Hooks or another better way to track session objects
<div><div style="background-color:#ffffff;color:#000000;font-family:'menlo' , 'monaco' , 'courier new' , monospace;font-size:16px;font-weight:normal;line-height:24px;white-space:pre"><div><div style="background-color:#ffffff;color:#000000;font-family:'menlo' , 'monaco' , 'courier new' , monospace;font-size:16px;font-weight:normal;line-height:24px;white-space:pre"><div><span style="color:#000000">Hi all!</span></div> <div><span style="color:#000000">I am working on a new type of pooling mechanism for Postgres</span></div><div><span style="color:#000000">connection managers. In this mode, the client connection is</span></div><div><span style="color:#000000">detached from server between transactions only if no temporary</span></div><div><span style="color:#000000">objects were created in that session</span></div><div><span style="color:#000000">(temporary tables, prepared statements, and advisory locks).</span></div> <div><span style="color:#000000">Currently, I am exploring ways to notify the connection manager</span></div><div><span style="color:#000000">when any of these session-level objects are created or existing.</span></div><div><span style="color:#000000">I got next ideas:</span></div><div><span style="color:#0451a5">-</span><span style="color:#000000"> send a status info byte in RFQ package, but that requires a</span></div><div><span style="color:#000000"> protocol changes, so this option should be discarded, I suppose</span></div><div><span style="color:#0451a5">-</span><span style="color:#000000"> create an extension, that executes elog(NOTIFY, "some message") or</span></div><div><span style="color:#000000"> sends dedicated package with smth like pq_putemptymessage('O') in new</span></div><div><span style="color:#000000"> hook, that is called before RFQ sending (see POC patch in attachments)</span></div><div><span style="color:#0451a5">-</span><span style="color:#000000"> create an extension, that executes the same things as in option above,</span></div><div><span style="color:#000000"> but uses more specialized hooks. For temporary tables I can use</span></div><div><span style="color:#000000"> ProcessUtility_hook that already exists. For prepared statements and</span></div><div><span style="color:#000000"> advisory locks I wasn't able to find a suitable hooks, so I add a hook</span></div><div><span style="color:#000000"> before sending ParseComplete message and in LockAcquire end</span></div><div><span style="color:#000000"> (see another POC patch in attachments)</span></div> <div><span style="color:#000000">I would appreciate any feedback on the general idea, advices on a clean way</span></div><div><span style="color:#000000">to implement such notifications, and comments on the attached POC patches.</span></div><div><span style="color:#000000">If you have ideas, experience with similar tasks, or suggestions for a</span></div><div><span style="color:#000000">better (or more canonical) Postgres way to approach this, please let me know.</span></div> <div><span style="color:#000000">Thanks!</span></div></div></div></div></div><div> </div><div>----</div><div>Best regards,</div><div>Roman Khapov.</div><div> </div>