Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 136370 - Requesting a database connection Factory [was: Database connections do not fail gracefully]
Summary: Requesting a database connection Factory [was: Database connections do not fa...
Status: RESOLVED DUPLICATE of bug 203636
Alias: None
Product: Community
Classification: Eclipse Foundation
Component: Website (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: phoenix.contentmgt-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 137437
  Show dependency tree
 
Reported: 2006-04-12 12:16 EDT by Eclipse Webmaster CLA
Modified: 2008-08-26 13:43 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eclipse Webmaster CLA 2006-04-12 12:16:50 EDT
Some pages connect to MySQL databases using PHP connection objects.  These objects halt the page execution if the database connection fails.

These connection failures should be returned to the caller so that the page can handle them gracefully.

D.
Comment 1 Diego Figueroa CLA 2006-04-19 15:49:16 EDT
We currently use the MySQL objects provided by the Eclipse webmasters (e.g., dbconnection_*.class.php).

Do these objects return anything specific upon failure to connect? or are they still using exit()?
Comment 2 Eclipse Webmaster CLA 2006-05-10 08:40:08 EDT
(In reply to comment #1)
They currently exit(), which is the problem.
Comment 3 Eclipse Webmaster CLA 2006-05-10 09:14:41 EDT
Expanding this bug into a feature request. The purpose of this FR is to extend the functionality of the databases, while improving our site security, improving our site's 'robustness' where database connections are required, and removing some development burden from the developers.

The current database connection mechanisms have the following drawbacks:
- they are difficult to maintain by the webmaster, as the number of classes increases
- they require the developer to manage DB connects, disconnects, SQL sanitizing
- do not fail gracefully if the database is not there
- require the programmer to select between the master and slave
- don't allow code to run locally, where no database is present
- prevent the actual dbconnection PHP code from being in CVS, because of passwords and trusted path information


I'm proposing we deprecate the many dbconnection_*.class.php and create a database connection handler for *all* the eclipse.org databases, where the handler:
- will connect to the appropriate database server (master always for writes, or slave(s) for selects)
- will handle trusted paths for all the databases
- will handle disconnecting
- will handle SQL sanitizing, to prevent SQL injection attacks
- will gracefully fail if the database server is unavailable
- will gracefully route SELECT queries to the MASTER if the SLAVE is unavailable
- will use username/password and trusted path information from root-accessible files, allowing the actual code to be stored in CVS

This proposed suggestion will make it easy to add the following functionality later on:
- handle intelligent load balancing for SELECTs among slaves, depending on load and locks


Proposed client-side implementation would look like this:

$eclipse_db = new DatabaseHandler();
$resultset  = $eclipse_db->query("database1", "SELECT blabla");
$some_xml   = $eclipse_db->query("database2", "SELECT something else", "xml");
$resultset3 = $eclipse_db->query("database1", "INSERT INTO something");

The return value for the resultset would either be the actual PHP/mysql resultset for SELECTS (or xml if specified), the number of matched rows for all other queries, or some special indicator that the database is unavailable.

Obviously, this will only apply to Phoenix-related code that accesses a database, i.e. Bugzilla, Wiki and Search won't be affected by this. I'm tossing this up in the air for comment.  Any specific implementation suggestions or ideas are welcome.

D.
Comment 4 Bjorn Freeman-Benson CLA 2006-05-10 10:31:29 EDT
Sounds good. My question is "what is gracefully fail?" Will they return an error code? An empty select? Call a handler? I don't think it really matters, I just want to know the spec/API so that we can use it.
Comment 5 Eclipse Webmaster CLA 2006-05-10 10:37:26 EDT
"The return value for the resultset would either be the actual PHP/mysql
resultset for SELECTS (or xml if specified), the number of matched rows for all
other queries, or some special indicator that the database is unavailable."

I'm not sure yet what the actual value would be, but it would be something.  Any suggestions?
Comment 6 Bjorn Freeman-Benson CLA 2006-05-10 10:42:50 EDT
Nothing comes to mind. Perhaps some string that is not numeric, thus I can distinguish between success (an object) or success (an integer) or failure (a string). But I'm sure you've already thought that far along and so my comment here is seriously redundant.
Comment 7 Denis Roy CLA 2007-10-10 11:42:01 EDT
Moving to Community/Website
Comment 8 Denis Roy CLA 2008-08-26 13:43:17 EDT

*** This bug has been marked as a duplicate of bug 203636 ***