I recently updated our site to Drupal 7.26, as well as updated the Media and Entity modules, for security purposes. I followed the instructions carefully, including updating our staging/test site to be a mirror of the live site and performing the updates there first. Everything went fine on the test site; however, when I performed the same process on the live site, I received an error message, saying in brief:

Table 'dbtable.cache_page' doesn't exist

Regardless, nothing appeared broken; when I took the live site out of Maintenance Mode, everything displayed properly.

However, I can't clear caches: every time I do so, I get a useless error message: it gives no more information than, "there has been an error, try again later".

The Recent Log Messages contains an error message with the Location

http://www.mysite.com/admin_menu/flush-cache?token=something&destination=admin/reports/event/something

and the Message

PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'database.cache_page' doesn't exist: TRUNCATE {cache_page} ; Array ( ) in cache_clear_all() (line 165 of /home/mysite/public_html/includes/cache.inc).

Does anyone know

  1. why this happens, especially considering no such problem happened on the test site?
  2. how to fix it?

Comments

tbc_keyworth’s picture

OK, by referencing a related post at

https://drupal.org/node/2160645

I found other people have been having problems with missing 'cache_' tables. To that end, I tried to run the following SQL command on our MySQL database, using PHPMyAdmin:

CREATE TABLE IF NOT EXISTS `cache_page` (
  `cid` varchar(255) NOT NULL DEFAULT '' COMMENT 'Primary Key: Unique cache ID.',
  `data` longblob COMMENT 'A collection of data to cache.',
  `expire` int(11) NOT NULL DEFAULT '0' COMMENT 'A Unix timestamp indicating when the cache entry should expire, or 0 for never.',
  `created` int(11) NOT NULL DEFAULT '0' COMMENT 'A Unix timestamp indicating when the cache entry was created.',
  `serialized` smallint(6) NOT NULL DEFAULT '0' COMMENT 'A flag to indicate whether content is serialized (1) or not (0).',
  PRIMARY KEY (`cid`),
  KEY `expire` (`expire`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Cache table used to store compressed pages for anonymous...';

However, I keep getting these error messages:

ERROR 1146 (42S02): Table 'db.cache_page' doesn't exist

Now, the command will run IF I use another table name like 'cache_pages', there's no problem- the table gets created without a hitch. But I can neither create, NOR rename to, the actual table I need. Anyone encounter this?

Jaypan’s picture

Do you see the table in your database?

tbc_keyworth’s picture

No, the table is not visible in the database; I cannot create a table with the 'cache_page', nor can I create the table with another name and rename it to 'cache_page'.

Jaypan’s picture

It sounds like the table has become corrupted somehow to the point of not being readable at all. Maybe try to drop it first, then recreate it?

tbc_keyworth’s picture

A corrupted table makes sense; it concurs with other research I have done. Problem now is, I have tried to drop the table and re-create it, and that doesn't work either: I get "Unknown table 'cache_page'" as an error message, but I still can't create the table. I THINK the user privileges I'm functioning with are insufficient, and have turned to our hosting tech support for assistance.

tbc_keyworth’s picture

The 'cache_page' table in the database was corrupt; it was removed by renaming the *.ibd file on the server:

CT-5875-bash-4.1# mv -v /var/lib/mysql/[database]/cache_page.ibd{,bak.$(date --rfc-3339=date)}
`/var/lib/mysql/[database]/cache_page.ibd' -> `/var/lib/mysql/[database]/cache_page.ibdbak.2014-02-14'

Hopefully this will help the next person: if a Drupal 'cache_' table seems to disappear, and the Recent Log Messages includes a notice similar to this:

PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table '[database].cache_page' doesn't exist

then you can suspect a corrupt table is to blame.

Jaypan’s picture

For anyone who may come across this in the future, it's safe to delete and recreate cache_ tables, as the data is meant to be disposable. Other tables will cause issues, as the data is not meant to be disposable. Use with care.