You are here:  » Error when Database is down


Error when Database is down

Submitted by erv on Tue, 2013-06-18 12:22 in

Hi!

last night my Database crashed, while the webserver was still running.

My web-monitoring didnt find out about it, since the website was up and sending status 200 - only the pages were empty.

If I understand correctly, what PT does in case of database outages is behave as if the database was empty, basically generating empty category/brand-pages and 404 errors.

This of course tells search engines to drop the contents of all pages, until a PT-admin finds out about the problem, and restarts the database.

Shouldn't it be relatively easy to send an error-code while the database is down, so that searchengines ignore missing content?

Submitted by support on Tue, 2013-06-18 12:36

Hi erv,

Following user feedback I actually removed the code that sent a 404 (Not Found) response for expired products from the latest distribution (13/03A) since those pages turned out to be a valuable source of traffic; with the Related Products feature often directing users to, for example, a new version of a particular product.

It can be removed easily from 12/10B, simply delete or comment out the following code from line 72 of products.php:

  header("HTTP/1.0 404 Not Found");

However, if you wanted to check at this point whether the product was genuinely not found, or if instead there appears to be a database problem you could do this as follows by replacing the above code with:

  $sql = "SELECT MAX(id) FROM `".$config_databaseTablePrefix."products`";
  if (!database_querySelect($sql,$result))
  {
    header("HTTP/1.1 503 Service Unavailable");
    exit();
  }
  else
  {
     header("HTTP/1.0 404 Not Found");
  }

If you wanted, as per the latest distribution, not to send 404, just leave out the else {..} section of the above modification.

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by erv on Tue, 2013-06-18 13:05

thanks david, exactly what i was looking for.