Kvstore repair

I was getting an error in the dashboard that kvstore was crashed.
I ran “mysqlcheck --repair --all-databases” which cleared the error.
The following appeared in the output:

asterisk.kvstore
warning  : Number of rows changed from 733 to 728
status   : OK

Is this of concern? What does kvstore do and do I need to do anything about it?
Thanks for any help you can provide…

KVStore does quite a bit… It is a key value store used throughout FreePBX. Typically the above repair removes corrupted extra bits. There is not usually any data loss.

I should mention 90% of freepbx database stuff is done in normal tables but the KVstore is where we want to move things in the future as it allows more flexibility in database choice.

Thank you, jfinstrom.

Dear jfinstrom,

I have a similar problem after the backups ran out and the server crashed from power failure.

I tried repairing the DB using mysqlcheck as well as the other common repair methods for MYSQL.

Unfortunately KVStore is the only table that cannot be repaired.

Can this table be rebuilt or restored in any way?

I still get this error on reboot
" [PDOException]
SQLSTATE[HY000]: General error: 144 Table ‘./asterisk/kvstore’ is marked as
crashed and last (automatic?) repair failed"

Can I replace the KVStore.* files from a fresh install and expect that the Key-Values are populated again ?

You will lose data. What is the command you are running to repair?

Hi.
I’ve tried.

Simple MySQL methods

  1. REPAIR TABLE
  2. mysqlcheck -u root -p --auto-repair --check --optimize --all-databases

Then

[[email protected] ~]# cd /var/lib/mysql/asterisk
[[email protected] asterisk]# myisamchk kvstore
Checking MyISAM file: kvstore
Data records: 34 Deleted blocks: 0
myisamchk: warning: Table is marked as crashed and last repair failed
myisamchk: warning: 15 clients are using or haven’t closed the table properly

  • check file-size
    myisamchk: warning: Size of indexfile is: 4729856 Should be: 10240
  • check record delete-chain
  • check key delete-chain
  • check index reference
  • check data record references index: 1
  • check data record references index: 2
  • check data record references index: 3
  • check record links
    myisamchk: error: got error: 5 when reading datafile at record: 34
    MyISAM-table ‘kvstore’ is corrupted
    Fix it using switch “-r” or “-o”

After that

[[email protected] asterisk]# myisamchk -r kvstore
- recovering (with sort) MyISAM-table 'kvstore'
Data records: 34
- Fixing index 1
myisamchk: error: myisam_sort_buffer_size is too small
MyISAM-table 'kvstore' is not fixed because of errors
Try fixing it by using the --safe-recover (-o), the --force (-f) option or by not using the --quick (-q) flag

[[email protected] asterisk]# service mysqld stop
Stopping mysqld:                                           [  OK  ]

[[email protected] asterisk]# myisamchk --silent --force --fast  kvstore.MYI
myisamchk: MyISAM file kvstore.MYI
myisamchk: warning: Table is marked as crashed and last repair failed
myisamchk: warning: Size of indexfile is: 4729856       Should be: 4096
myisamchk: error: got error: 5 when reading datafile at record: 34
Can't read whole record at 133008 (errno: 5)
Read error for block at: 136960 (error: 127); Skipped
myisamchk: Error reading file 'kvstore.MYD' (Errcode: 5)
Read error for block at: 137664 (error: 5); Skipped
myisamchk: Error reading file 'kvstore.MYD' (Errcode: 5)
Read error for block at: 139264 (error: 5); Skipped
Found link that points at 8029764350743048307 (outside data file) at 139272
myisamchk: Error reading file 'kvstore.MYD' (Errcode: 5)
Read error for block at: 139428 (error: 5); Skipped
myisamchk: MyISAM file kvstore.MYI
myisamchk: error: 127 when fixing table
MyISAM-table 'kvstore.MYI' is not fixed because of errors
Try fixing it by using the --safe-recover (-o), the --force (-f) option or by not using the --quick (-q) flag

After that

[[email protected] asterisk]# myisamchk --safe-recover kvstore
- recovering (with keycache) MyISAM-table 'kvstore'
Data records: 34
Can't read whole record at 133008 (errno: 5)
Read error for block at: 136960 (error: 127); Skipped
myisamchk: Error reading file 'kvstore.MYD' (Errcode: 5)
Read error for block at: 137664 (error: 5); Skipped
myisamchk: Error reading file 'kvstore.MYD' (Errcode: 5)
Read error for block at: 139264 (error: 5); Skipped
Found link that points at 8029764350743048307 (outside data file) at 139272
myisamchk: Error reading file 'kvstore.MYD' (Errcode: 5)
Read error for block at: 139428 (error: 5); Skipped
myisamchk: error: 127 for record at pos 140772
MyISAM-table 'kvstore' is not fixed because of errors
Try fixing it by using the --safe-recover (-o), the --force (-f) option or by not using the --quick (-q) flag

Kindly check the above attempts.

freepbx-13.0.127
Asterisk 13.9.1

when I try something like
#fwconsole firewall trust XX.XX.XX.XX/32

Attempting to add XX.XX.XX.XX/32 to Trusted Zone
  [PDOException]
  SQLSTATE[HY000]: General error: 144 Table './asterisk/kvstore' is marked as crashed and last
   (automatic?) repair failed

You can’t repair kvstore while the system is running. You need to shut down Asterisk before you can repair the table or change your repair command to something like this:

myisamchk --silent --force kvstore.MYI (leave off the “–fast”)

This means your hard drive has failed. Not ‘is failing’, ‘has failed’. Sorry.

2 Likes

I know this is a old thread but heres a easy fix for this.

cd /var/lib/mysql/asterisk
myisamchk --max-record-length=0 -r kvstore

If you want you can also backup the files before you use the above fix
mkdir ./backup & cp ./kvstore.* ./backup

his occurs because the entry of the invalid index indicates that the size of a BLOB field is larger than that specified

1 Like