<div dir="ltr">Hi Tatsuo<div><br><div>I have rebased the EXCEPTION_MGR branch to current master, please find the updated patch generated after rebasing.</div><div><br></div><div>Thanks</div><div>Muhammad Usama<br><div class="gmail_extra">
<br><br><div class="gmail_quote">On Tue, Feb 11, 2014 at 11:17 AM, Tatsuo Ishii <span dir="ltr">&lt;<a href="mailto:ishii@postgresql.org" target="_blank">ishii@postgresql.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Usama,<br>
<br>
I have checked EXCEPTION_MGR branch and it seems it is far behind main<br>
branch. The last patch brought to the EXCEPTION_MGR was dated<br>
2013/12/19. Can you please rebase the branch?<br>
<br>
Best regards,<br>
--<br>
Tatsuo Ishii<br>
SRA OSS, Inc. Japan<br>
English: <a href="http://www.sraoss.co.jp/index_en.php" target="_blank">http://www.sraoss.co.jp/index_en.php</a><br>
Japanese: <a href="http://www.sraoss.co.jp" target="_blank">http://www.sraoss.co.jp</a><br>
<br>
From: Muhammad Usama &lt;<a href="mailto:m.usama@gmail.com">m.usama@gmail.com</a>&gt;<br>
Subject: penultimate patch for exception and memory manager ( EXCEPTION_MGR branch)<br>
Date: Mon, 10 Feb 2014 19:53:41 +0500<br>
Message-ID: &lt;CAEJvTzUZHKKHjz-ZvYaAsviwVVBKSoX-ByNq9rhANO1zPJYR=<a href="mailto:w@mail.gmail.com">w@mail.gmail.com</a>&gt;<br>
<div class=""><div class="h5"><br>
&gt; Please find the penultimate patch for integration of memory and exception<br>
&gt; manager APIs into pgpool.<br>
&gt; The patch is generated on the EXCEPTION_MGR development branch and<br>
&gt; integrates the said APIs in query processing portion of pgpool-II code.<br>
&gt;<br>
&gt; Patch summary for review<br>
&gt; ======================<br>
&gt; The patch is very large mainly because of replacing of pool_error(),<br>
&gt; pool_debug() and pool_log() function calls to ereport(ERROR,..)<br>
&gt; ereport(DEBUG,..) and ereport(LOG,..) and it would be little time consuming<br>
&gt; to review the patch. Although all the above also needs the thorough review,<br>
&gt; as replacing pool_error() with ereport(ERROR) or ereport(FATAL) is just not<br>
&gt; a cosmetic but changes the flow of code, but there are few things, that<br>
&gt; requires the more attention than others.<br>
&gt;<br>
&gt; Lifecycle of objects.<br>
&gt; ================<br>
&gt; Since with integration of memory manager, it is very important to manage<br>
&gt; the life cycle of each object and making sure the object is created in the<br>
&gt; proper MemoryContext. Here is the summary of some important objects and<br>
&gt; their residences.<br>
&gt;<br>
&gt; Some Important Memory Contexts<br>
&gt; ============================<br>
&gt;<br>
&gt; ProcessLoopContext:<br>
&gt; This context resets at every main loop iteration of a process<br>
&gt;<br>
&gt; TopMemoryContext:<br>
&gt; This context is same as PostgreSQL&#39;s TopMemoryContext and lives for a life<br>
&gt; time of process.<br>
&gt;<br>
&gt; ErrorContext:<br>
&gt; Same as PostgreSQL&#39;s ErrorContext and used for error processing.<br>
&gt;<br>
&gt; QueryContext:<br>
&gt; Used by pgpool child process and it lives for single query cycle.<br>
&gt;<br>
&gt;<br>
&gt; Lifecycle of Important Objects<br>
&gt; ========================<br>
&gt;<br>
&gt; SessionContext:<br>
&gt; The session context consists of a backend and frontend connection and it<br>
&gt; lives for a single iteration of main child process loop.<br>
&gt; So the session context object is created in ProcessLoopContext.<br>
&gt;<br>
&gt; ProcessContext:<br>
&gt; ConnectionPool:<br>
&gt; BackendConnection:<br>
&gt; The above objects are required for the life of process hence are created in<br>
&gt; TopMemoryContext which lives throughout the process life time.<br>
&gt;<br>
&gt; Child Frontend connection:<br>
&gt; Frontend connection object is placed in the ProcessLoopContext since new<br>
&gt; frontend connection is created at every main loop iteration of pgpool child<br>
&gt; process.<br>
&gt;<br>
&gt; PCP Frontend connection:<br>
&gt; This object can live till the pcp process so the object for pcp frontend is<br>
&gt; created in TopMemoryContext.<br>
&gt;<br>
&gt; new configuration parameters<br>
&gt; ========================<br>
&gt;<br>
&gt; The patch also adds three new configuration parameters to control the error<br>
&gt; reporting style and details.<br>
&gt; Parameters names and their behaviours are borrowed from PostgreSQL.<br>
&gt;<br>
&gt; int log_error_verbosity;    /* controls how much detail about error should<br>
&gt; be emitted */<br>
&gt;<br>
&gt; int client_min_messages;    /*controls which message should be sent to<br>
&gt; client */<br>
&gt;<br>
&gt; int log_min_messages;       /*controls which message should be emitted to<br>
&gt; server log */<br>
&gt;<br>
&gt;<br>
&gt; Some other notable changes introduced by the patch.<br>
&gt; ==========================================<br>
&gt;<br>
&gt; The patch changes the error reporting behaviour and now pgpool-II tries to<br>
&gt; send all the error and log messages to the connected frontend clients<br>
&gt; (controllable by &quot;client_min_messages&quot; configuration parameter ).<br>
&gt;<br>
&gt; The patch added an extra call back &quot;on_system_exit&quot; to the elog API, which<br>
&gt; is not present in the PostgreSQL.<br>
&gt; The call back is called at system exit by elog API just before calling the<br>
&gt; &quot;on_shmem_exit&quot; call backs.<br>
&gt; &quot;on_system_exit&quot; is a single call back and can be used to clean up things<br>
&gt; which are dependent on shared memory.<br>
&gt;<br>
&gt; &quot;repalloc()&quot; behaviour in PostgreSQL palloc API is little different from<br>
&gt; C-API counterpart &quot;realloc()&quot;.<br>
&gt; (&quot;realloc()&quot; behaves as &quot;malloc()&quot; if ptr argument is NULL. While<br>
&gt; &quot;repalloc()&quot; does not works on NULL pointers)<br>
&gt; So I have changed the behaviour of &quot;repalloc()&quot; to make it more consistent<br>
&gt; with C-API.<br>
&gt;<br>
&gt; The patch makes the libpcp exclusive for the tool binaries only (compile<br>
&gt; with POOL_PRIVATE flag ). pgpool binary no longer has the dependancy on the<br>
&gt; lib, and uses the pcp_stream.c function directly.<br>
&gt; For this new arrangement the patch also rearranges the source code<br>
&gt; organisation and moves the pcp_stream.c and pcp_error.c files to<br>
&gt; src/utils/pcp directory from src/lib/pcp directory.<br>
&gt;<br>
&gt; What is still remaining.<br>
&gt; ==================<br>
&gt; 1- Need to decide the MemoryContext for memcache objects.<br>
&gt; 2- Watchdog and few rewrite function are still without the managers.<br>
&gt; 3- Replace all remaining occurrences of  pool_error, pool_debug, and<br>
&gt; pool_log with appropriate ereport() calls<br>
&gt; 4 -Code cleanup<br>
&gt;<br>
&gt; Reviews comments and suggestions are most welcome<br>
&gt;<br>
&gt; Thanks<br>
&gt; Usama<br>
</div></div></blockquote></div><br></div></div></div></div>