Skip to Content.
Sympa Menu

devel - Re: [sympa-developpers] database connection pooling

Subject: Developers of Sympa

List archive

Chronological Thread  
  • From: Guillaume Rousse <address@concealed>
  • To: address@concealed
  • Subject: Re: [sympa-developpers] database connection pooling
  • Date: Tue, 11 Mar 2014 12:38:10 +0100

Le 11/03/2014 05:30, IKEDA Soji a écrit :
The only current benefit of this 'pooling' feature is to cache the
database connection (the DBI::DBH instance), because it is lazily
created as a side effect of any kind of database operation. Any call to
any function in Sympa::DatabaseManager function, such as do_query(),
will silently intialize this connection, relying on this caching
mechanism to avoid creating duplicate DBI::DBH instances... I could
summarize its purpose as "no need to worry where I should store my
database handle, as I can throw it away in a loose bag after every
usage, and dig this bag again next time I need it". Dubious feature...

I have once explained that using db handle directly will make Sympa
unstable and make code complex. Please read past posts.
I never suggested such thing, no need to invoke past discussions.

A far simpler, readable and efficient solution would be to have each
binary (sympa.pl, bulk.pl, wwwsympa.fcgi) explicitely create this
database connection on startup, check if it is uptodate (otherwise, exit
immediately), and keep a permanent reference on it, for later usage. Ie,
something as:

# read configuration

our $database = Sympa::Database->new(%params);
croak 'unable to connect to the database, check your configuration'
if !$database->connect();
croak 'database need to be updated first, use sympa_wizard'
if !$database->up_to_date();

# let's assume than the database is now available and fonctional
# from this point everywhere in the code as $main::database


90% of code in Sympa::DatabaseManager would become immediatly useless, a
they just forward function call to the underlying $db_source object.

I agree to you on style, and on the fact SDM and Datasource are
redundant. However, I suppose it would be better rather to unify
the feature above into Datasource than to strip it (I'll write on
this issue later again, about use of singleton).
I'd rather use a single 'Database' concept rather than the current mix of 'DatabaseManager', 'Datasource' and 'DBEngine' concepts.

BTW: The naming "Sympa::DatabaseManager" feels too long for me.
March of such as many "Sympa::DatabaseManager::quote(...)" can be
hard to read. I prefer to "Sympa::DBM", at least "Sympa::DBManager".
Don't use cryptic abbreviation you're the only one to understand just for cosmetic reasons.

A better solution is to simplify and rationalise the names currently used. It seems silly to have a 'DatabaseManager' concept, when you don't have a 'Database' one...

And even better, use instance methods instead of functions:
my $manager = Sympa::DatabaseManager::WhateverNameYouWant->new();
$manager->quote();
--
Guillaume Rousse
INRIA, Direction des systèmes d'information
Domaine de Voluceau
Rocquencourt - BP 105
78153 Le Chesnay
Tel: 01 39 63 58 31

Attachment: smime.p7s
Description: Signature cryptographique S/MIME




Archive powered by MHonArc 2.6.19+.

Top of Page