Failure after Pi reboot

Hi,

I have just had to restart my Pi after about 42 days of continuous running as I couldn't reconnect to it via it's ad-hoc usb wi-fi connection ( i had removed the usb dongle for use in something else) Now after restarting, I am getting the following error in my web browser:

Warning: mysqli::mysqli(): (HY000/2002): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /var/www/emoncms/index.php on line 26

Warning: mysqli::query(): Couldn't fetch mysqli in /var/www/emoncms/Modules/user/user_model.php on line 345

Fatal error: Call to a member function fetch_array() on a non-object in /var/www/emoncms/Modules/user/user_model.php on line 346

 

Raspbian seems to be running ok on the Pi, and I can ssh into it without any problems. Any advise? I'm afraid mysql is something of a mystery to me :(

 

*edit* I did a controlled shutdown of the Pi through the wired ethernet connection.

PhilThy's picture

Re: Failure after Pi reboot

Any suggestions on what I can backup/recover from this?

There appears to be some sort of failure in mysql or the database(s) and, as I have no idea as to how I can fix this, I guess the best thing to do would be to reinstall everything.

I would like to salvage my feeds if possible, and anything else that would make it all a little easier.

Mattia Rossi's picture

Re: Failure after Pi reboot

ssh into the pi, sudo to root , and check whether mysql is running:

root@raspberrypi:/home/pi# ps auwx | grep mysql
root      2091  0.0  0.1   1752   564 ?        S    Oct20   0:00 /bin/sh /usr/bin/mysqld_safe
root      2484  7.0 36.5 320088 181688 ?       Sl   Oct20 474:58 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=root --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/run/mysqld/mysqld.sock --port=3306
root      2485  0.0  0.1   1844   600 ?        S    Oct20   0:00 logger -t mysqld -p daemon.error
root     31454  0.0  0.1   3544   812 pts/0    S+   15:49   0:00 grep mysql

 

If it is then you probably have some corrupted tables: run

mysqlcheck --auto-repair -A -p

and wait for it to finish

If mysql isnt running try to start the daemon in debug mode and see whether it logs some errors:

root@raspberrypi:/home/pi# mysqld -debug

 

 

PhilThy's picture

Re: Failure after Pi reboot

Hi Mattia, thankyou for your assitance.

root@emoncmspi:~# ps auwx | grep mysql
root      2965  0.0  0.3   3540   808 pts/0    S+   20:01   0:00 grep mysql           # I guess this means its not running

root@emoncmspi:~# mysqld -debug
131025 20:03:01 [Note] Plugin 'FEDERATED' is disabled.                                                                                                                                         
131025 20:03:01 InnoDB: The InnoDB memory heap is disabled                                                                                                                                     
131025 20:03:01 InnoDB: Mutexes and rw_locks use GCC atomic builtins                                                                                                                           
131025 20:03:01 InnoDB: Compressed tables use zlib 1.2.7                                                                                                                                       
131025 20:03:01 InnoDB: Using Linux native AIO                                                                                                                                                 
131025 20:03:01 InnoDB: Initializing buffer pool, size = 128.0M                                                                                                                                
131025 20:03:01 InnoDB: Completed initialization of buffer pool                                                                                                                                
131025 20:03:01 InnoDB: highest supported file format is Barracuda.                                                                                                                            
InnoDB: Database page corruption on disk or a failed                                                                                                                                           
InnoDB: file read of page 3.                                                                                                                                                                   
InnoDB: You may have to recover from a backup.                                                                                                                                                 
131025 20:03:01  InnoDB: Page dump in ascii and hex (16384 bytes):     # edited as it is to long to post!

 

InnoDB: End of page dump
131025 20:03:05  InnoDB: Page checksum 2116304490, prior-to-4.0.14-form checksum 2101561512
InnoDB: stored checksum 4240430359, prior-to-4.0.14-form stored checksum 2101561512
InnoDB: Page lsn 0 10675, low 4 bytes of lsn at page end 10675
InnoDB: Page number (if stored to page already) 3,
InnoDB: space id (if created with >= MySQL-4.1.1 and stored already) 0
InnoDB: Page may be a system page
InnoDB: Database page corruption on disk or a failed
InnoDB: file read of page 3.
InnoDB: You may have to recover from a backup.
InnoDB: It is also possible that your operating
InnoDB: system has corrupted its own file cache
InnoDB: and rebooting your computer removes the
InnoDB: error.
InnoDB: If the corrupt page is an index page
InnoDB: you can also try to fix the corruption
InnoDB: by dumping, dropping, and reimporting
InnoDB: the corrupt table. You can use CHECK
InnoDB: TABLE to scan your table for corruption.
InnoDB: See also http://dev.mysql.com/doc/refman/5.5/en/forcing-innodb-recovery.html
InnoDB: about forcing recovery.
InnoDB: Ending processing because of a corrupt database page.
131025 20:03:05  InnoDB: Assertion failure in thread 3060551680 in file buf0buf.c line 3616
InnoDB: We intentionally generate a memory trap.
InnoDB: Submit a detailed bug report to http://bugs.mysql.com.
InnoDB: If you get repeated assertion failures or crashes, even
InnoDB: immediately after the mysqld startup, there may be
InnoDB: corruption in the InnoDB tablespace. Please refer to
InnoDB: http://dev.mysql.com/doc/refman/5.5/en/forcing-innodb-recovery.html
InnoDB: about forcing recovery.
19:03:05 UTC - mysqld got signal 6 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
We will try our best to scrape up some info that will hopefully help
diagnose the problem, but since we have already crashed,
something is definitely wrong and this may fail.

key_buffer_size=16777216
read_buffer_size=131072
max_used_connections=0
max_threads=151
thread_count=0
connection_count=0
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 346080 K  bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

Thread pointer: 0x0
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
stack_bottom = 0 thread_stack 0x30000
The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
information that should help you find out what is causing the crash.
 

Mattia Rossi's picture

Re: Failure after Pi reboot

You are right ... Google is your friend in this case .... Try to follow the method described here:http://stackoverflow.com/questions/14837653/cannot-start-mysql and if you can successfully recover then think about switching to myisam as a storage method and about not using the sd card to store the data

Mattia Rossi's picture

Re: Failure after Pi reboot

Here's a link to a post that contains a script to migrate tables to myisam:

http://openenergymonitor.blogspot.co.uk/2013/06/load-stats-for-myisam-vs...

 

 

 

 

PhilThy's picture

Re: Failure after Pi reboot

Thanks for your input Mattia, unfortunately it does not appear to be repairable. I am not to concerned about losing the database data, but I am not looking forward to setting up all the feeds and dashboard views again (I have quite a few). Can I backup this data somehow or am I resigned to losing that as well?

Mattia Rossi's picture

Re: Failure after Pi reboot

If you cannot manage to dump the db then I'm afraid you're out of luck. All the config info is stored in the mysql tables... Have you tried increasing the value of innodb_force_recovery?

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.