[pgpool-hackers: 371] Exception Manager for pgpool

Muhammad Usama m.usama at gmail.com
Mon Oct 7 17:59:38 JST 2013


I am working on adding the exception manager in pgpool and my plan of
action for this is to use the Postgres exception manager API (elog and
friends). Since the exception manager in Postgres uses the long jump, so
importing this API in pgpool will effect all existing pgpool code flows
especially in case of an error. and lot of care will be required for this
integration, and secondly the elog API along with its friends will touch
almost all parts of pgpool source code which will add up to a very huge
So instead throwing a very huge patch to the community my plan is to divide
this task into multiple smaller sub tasks so that it would be easier
maintain and review the patch.

Cut to the chase, attached is the  first of the series of related patches
to come.This is the first cut patch for implementing the exception manager
in pgpool. As described above the exception manager and related code is
borrowed from PostgreSQL source code.
and the exception manager (elog API) is very closely tied with memory
manager in PostgreSQL (palloc API) so the patch also borrows the PG's
memory manager.

Below is the little description of things part of this patch.

-- Exception manager API of Postgres is added to pgpool, The API consists
of elog.c and elog.h files. Since this API is very extensive and is
designed for PostgreSQL so to fit it properly into pgpool I have modified
it a little bit, and most of the modifications are related to removal of
code which is not required for pgpool.

-- Added on_proc_exit callback mechanism of Postgres. To facilitate the
cleanup at exit time.

-- Added PostgreSQL's memory manager (palloc API). This includes the client
side palloc functions placed in 'src/tools' directory (fe_memutils)

-- Removed the existing memory manager which was very minimalistic and was
not integrated in all parts of the code.

-- I have also tried to reflector some portions of code to make the code
more readable at first glance. This includes

- dividing the main.c file into two files main.c and pgpool_main.c, Now the
main.c file only contains the code related to early initialisations of
pgpool and parsing the command line options and related code. The actual
logic of the pgpool main process is moved to new pgpool_main.c file.
- breaking up some large functions in child.c into smaller functions.
- rewrite the pgpool's main loop logic to make the code more readable.

Remaining TODOs on this front.

-- The current patch only integrates the memory and exception manager in
main process and connection creation segment of pgpool child process.
integration of newly added APIs in pcp and worker child process codes will
be done be next patch.

-- Integration of newly added API into query processor logic in child
process. ( this will be the toughest part)

-- elog.c and elog.h files needs some cleanups and changes ( to remove
unwanted functions and data members of ErrorData structure) but this will
be done at the end when we will have 100% surety if something in there is
required or not.

Muhammad Usama
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.sraoss.jp/pipermail/pgpool-hackers/attachments/20131007/dfaaf10e/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: exmgr_1stCut.patch
Type: application/octet-stream
Size: 472538 bytes
Desc: not available
URL: <http://www.sraoss.jp/pipermail/pgpool-hackers/attachments/20131007/dfaaf10e/attachment-0001.obj>

More information about the pgpool-hackers mailing list