Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2022-05-31 00:51:13

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 3,225
Website

Database is down message

The database server for some of my Textpattern sites went down – “MariaDB InnoDB data files and logs have becoming corrupt”. OK – s**t happens.

But I wonder, is it possible for Textpattern to show the world (the public side at least) a friendlier message in such case? Right now it only shows raw error messages (below). I know, given de dependency on the DB, it is might not be possible. Something that would sent a 503 error probably.

Below is the sequence of messages displayed (slightly sanitised… and vaguely prettified).

First message – the DB server went down:

Fatal error: Uncaught mysqli_sql_exception: Connection refused in /home/username/apps/sitename/textpattern/lib/txplib_db.php:247 
Stack trace: #0 /home/username/apps/sitename/textpattern/lib/txplib_db.php(247): mysqli_real_connect() 
#1 /home/username/apps/sitename/textpattern/lib/txplib_db.php(288): DB->__construct() 
#2 /home/username/apps/sitename/textpattern/publish.php(44): include_once('...') 
#3 /home/username/apps/sitename/index.php(69): include('...') 
#4 {main} thrown in /home/username/apps/sitename/textpattern/lib/txplib_db.php on line 247

Second message – the server people are restoring the DB’s

Fatal error: Uncaught mysqli_sql_exception: Permission denied in /home/username/apps/sitename/textpattern/lib/txplib_db.php:247 
Stack trace: #0 /home/username/apps/sitename/textpattern/lib/txplib_db.php(247): mysqli_real_connect() 
#1 /home/username/apps/sitename/textpattern/lib/txplib_db.php(288): DB->__construct() 
#2 /home/username/apps/sitename/textpattern/publish.php(44): include_once('...') 
#3 /home/username/apps/sitename/index.php(69): include('...') 
#4 {main} thrown in /home/username/apps/sitename/textpattern/lib/txplib_db.php on line 247

–^–

PS – funny thing, that DB server went down just when I was on my way to create a (manual) backup of the databases. Luckily I did not suffer any losses.


Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern

Offline

#2 2022-05-31 18:45:02

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,279
GitHub

Re: Database is down message

phiw13 wrote #333462:

But I wonder, is it possible for Textpattern to show the world (the public side at least) a friendlier message in such case?

This would be better at a web server level, in my opinion. You could shoehorn in some directives into your website config (assuming Apache), and pick some pretty-ish files as placeholders – here are some for starters: github.com/justinhartman/Webserver-Error-Pages

Bonus points: style some error pages per your website theme, and then save the static files in the Textpattern theme directory, making sure to allow direct access to the .html files, and have your web server use those instead.

Edit: changed URL.

Last edited by gaekwad (2022-05-31 18:54:58)

Offline

#3 2022-05-31 19:19:24

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,468
Website GitHub

Re: Database is down message

Yep, what Pete said. It’s impossible (at present) to do anything at the Textpattern level given that, well, the database is unavailable for whatever reason so there’s no way we can connect to it to fetch stuff.

The only thing we could do is fall back in the code to a well-known URL that could be served, if it exists, when the DB is down instead of throwing the vanilla text to the screen. Opinions welcome.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#4 2022-06-01 00:42:18

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 3,225
Website

Re: Database is down message

Setting up and stying the error pages is not a problem. I have some listed in my .htaccess already.

But how do I eventually catch this specific event to display the appropriate page? The HTTP server does not know anything about the DB.

I am tempted to nod in support of this (showing the vanilla screen for /textpattern/ is OK):

The only thing we could do is fall back in the code to a well-known URL that could be served, if it exists, when the DB is down instead of throwing the vanilla text to the screen. Opinions welcome.


Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern

Offline

Board footer

Powered by FluxBB