Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQLSTATE[42S02]: Base table or view not found #71

Closed
coresh opened this issue Mar 5, 2016 · 15 comments
Closed

SQLSTATE[42S02]: Base table or view not found #71

coresh opened this issue Mar 5, 2016 · 15 comments

Comments

@coresh
Copy link

coresh commented Mar 5, 2016

After initial installation:
modman clone https://github.com/madalinoprea/magneto-debug
and
n98-magerun.phar cache:flush

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'magento1.sheep_debug_request_info' doesn't exist, query was: DESCRIBE `sheep_debug_request_info`

#0  lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)
#1  app/code/core/Zend/Db/Statement.php(291): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
#2  lib/Zend/Db/Adapter/Abstract.php(480): Zend_Db_Statement->execute(Array)
#3  lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('DESCRIBE `sheep...', Array)
#4  lib/Varien/Db/Adapter/Pdo/Mysql.php(504): Zend_Db_Adapter_Pdo_Abstract->query('DESCRIBE `sheep...', Array)
#5  lib/Zend/Db/Adapter/Pdo/Mysql.php(171): Varien_Db_Adapter_Pdo_Mysql->query('DESCRIBE `sheep...')
#6  lib/Varien/Db/Adapter/Pdo/Mysql.php(1694): Zend_Db_Adapter_Pdo_Mysql->describeTable('sheep_debug_req...', NULL)
#7  app/code/core/Mage/Core/Model/Resource/Abstract.php(212): Varien_Db_Adapter_Pdo_Mysql->describeTable('sheep_debug_req...')
#8  app/code/core/Mage/Core/Model/Resource/Db/Abstract.php(586): Mage_Core_Model_Resource_Abstract->_prepareDataForTable(Object(Sheep_Debug_Model_RequestInfo), 'sheep_debug_req...')
#9  app/code/core/Mage/Core/Model/Resource/Db/Abstract.php(449): Mage_Core_Model_Resource_Db_Abstract->_prepareDataForSave(Object(Sheep_Debug_Model_RequestInfo))
#10 app/code/core/Mage/Core/Model/Abstract.php(318): Mage_Core_Model_Resource_Db_Abstract->save(Object(Sheep_Debug_Model_RequestInfo))
#11 .modman/magneto-debug/code/Debug/Model/Observer.php(163): Mage_Core_Model_Abstract->save()
#12 .modman/magneto-debug/code/Debug/Model/Observer.php(226): Sheep_Debug_Model_Observer->saveProfiling()
#13 app/code/core/Mage/Core/Model/App.php(1357): Sheep_Debug_Model_Observer->onLayoutGenerate(Object(Varien_Event_Observer))
#14 app/code/core/Mage/Core/Model/App.php(1336): Mage_Core_Model_App->_callObserverMethod(Object(Sheep_Debug_Model_Observer), 'onLayoutGenerat...', Object(Varien_Event_Observer))
#15 app/Mage.php(448): Mage_Core_Model_App->dispatchEvent('controller_acti...', Array)
#16 app/code/core/Mage/Core/Controller/Varien/Action.php(350): Mage::dispatchEvent('controller_acti...', Array)
#17 app/code/core/Mage/Core/Controller/Varien/Action.php(269): Mage_Core_Controller_Varien_Action->generateLayoutBlocks()
#18 app/code/core/Mage/Adminhtml/Controller/Action.php(275): Mage_Core_Controller_Varien_Action->loadLayout(NULL, true, true)
#19 app/code/core/Mage/Adminhtml/controllers/IndexController.php(81): Mage_Adminhtml_Controller_Action->loadLayout()
#20 app/code/core/Mage/Core/Controller/Varien/Action.php(418): Mage_Adminhtml_IndexController->loginAction()
#21 app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(254): Mage_Core_Controller_Varien_Action->dispatch('login')
#22 app/code/core/Mage/Core/Controller/Varien/Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#23 app/code/core/Mage/Core/Model/App.php(365): Mage_Core_Controller_Varien_Front->dispatch()
#24 app/Mage.php(683): Mage_Core_Model_App->run(Array)
#25 index.php(83): Mage::run('', 'store')
#26 {main}
@madalinoprea
Copy link
Owner

Hi @coresh,

I've tried a clean install and everything went smooth on my side.

After module is installed and configuration cache is flushed, module's configuration is parsed and observers are registered (from your stacktrace this already happened) and then SQL setup scripts responsible to create database scripts are run (which seems was not happened in your case).

  • What version of Magento do you use?
  • What do you get if you execute these SQL queries?
select * from core_cache_option;
select * from core_resource where code = 'sheep_debug_setup';

My proposal is to retry installation and see if consistently you get into same state.

  1. First you will have to clean up and force setup scripts to be re-executed:
-- Uninstall
DROP TABLE IF EXISTS sheep_debug_request_info;
DELETE FROM core_resource WHERE code = 'sheep_debug_setup';
  1. Cache flush
  2. Load a page (to regenerate cache and run setup scripts)
  3. Check if setup scripts run:
SELECT * FROM core_resource WHERE code = 'sheep_debug_setup';
DESCRIBE sheep_debug_request_info;

You should get something similar to:

screen shot 2016-03-06 at 10 34 06

screen shot 2016-03-06 at 10 33 23

@madalinoprea
Copy link
Owner

Hi @coresh,

Do you still get this error?

Cheers,
Mario

@coresh
Copy link
Author

coresh commented Mar 9, 2016

Hi, Mario,

First of all: Thanks for your quick and complete reply.

Issue still not solved (output: the same)

Version: EE 1.14.2.2

select * from core_resource where code = 'sheep_debug_setup';

code, version, data_version
sheep_debug_setup, 1.6.0, 1.6.0

select * from core_cache_option;

# code, value
block_html, 1
collections, 1
config, 1
config_api, 1
config_api2, 1
eav, 1
full_page, 1
layout, 1
translate, 1

i can't find CREATE table sheep_debug_request_info syntax:

$ grep -RHni sheep_debug_request_info /m/
/m/.modman/magneto-debug/code/Debug/Block/Abstract.php:89:            $this->requestInfo = Mage::registry('sheep_debug_request_info') ?: Mage::getSingleton('sheep_debug/observer')->getRequestInfo();
/m/.modman/magneto-debug/code/Debug/Block/View.php:22:            $this->requestInfo = Mage::registry('sheep_debug_request_info');
/m/.modman/magneto-debug/code/Debug/Test/Block/View.php:19:        $this->replaceRegistry('sheep_debug_request_info', 'registry data');
/m/.modman/magneto-debug/code/Debug/Test/Model/RequestInfo.php:42:        $this->assertEquals('sheep_debug_request_info', $resourceModel->getMainTable());
/m/.modman/magneto-debug/code/Debug/controllers/IndexController.php:84:        Mage::register('sheep_debug_request_info', $requestInfo);
/m/.modman/magneto-debug/code/Debug/etc/config.xml:20:                        <table>sheep_debug_request_info</table>
/m/.modman/magneto-debug/docs/uninstall.md:13:DROP TABLE IF EXISTS `sheep_debug_request_info`;

In the same time magneto-debug version 1.5 worked like a charm

@coresh
Copy link
Author

coresh commented Mar 9, 2016

Regarding magneto-debug version 1.6
issue: solved after commenting line 163 of:
.modman/magneto-debug/code/Debug/Model/Observer.php


    /**
     * Saves request info model.
     *
     * @throws Exception
     */
    public function saveProfiling()
    {
        if (!$this->canCollect() || !Mage::helper('sheep_debug')->canPersist()) {
            return;
        }

        if (!$this->getRequestInfo()->getIsStarted()) {
            return;
        }

        // $this->getRequestInfo()->save();
    }

@madalinoprea
Copy link
Owner

Did you try to run to remove core_resource entry and flush the cache and you had the same error?

Table is created by https://github.com/madalinoprea/magneto-debug/blob/master/code/Debug/sql/sheep_debug_setup/install-1.3.0.php#L11

I've reinstalled everything on Magento EE 1.14.2.1 and everything worked as expected:

# remove tables and resources
❯❯❯ n98-magerun db:console                                                                                                                                                                 
mysql> drop table sheep_debug_request_info;
Query OK, 0 rows affected (0.01 sec)
mysql> DELETE FROM core_resource WHERE code = 'sheep_debug_setup';
Query OK, 1 row affected (0.01 sec)
# get update
❯❯❯ modman update magneto-debug

# manually trigger setup install
❯❯❯ n98-magerun  sys:setup:run                                                                                                                                                           
❯❯❯ n98-magerun db:console                                                                                                                                                                 
mysql> describe sheep_debug_request_info;
+----------------+---------------+------+-----+---------+----------------+
| Field          | Type          | Null | Key | Default | Extra          |
+----------------+---------------+------+-----+---------+----------------+
| id             | int(11)       | NO   | PRI | NULL    | auto_increment |
| token          | varchar(255)  | NO   | MUL | NULL    |                |
| http_method    | varchar(32)   | NO   |     | NULL    |                |
| store_id       | smallint(6)   | NO   |     | NULL    |                |
| request_path   | varchar(255)  | NO   | MUL | NULL    |                |
| response_code  | smallint(6)   | NO   |     | NULL    |                |
| ip             | varchar(255)  | YES  |     | NULL    |                |
| session_id     | varchar(255)  | YES  | MUL | NULL    |                |
| date           | datetime      | NO   |     | NULL    |                |
| rendering_time | decimal(15,2) | YES  |     | NULL    |                |
| query_time     | decimal(15,2) | YES  |     | NULL    |                |
| query_count    | int(11)       | NO   |     | NULL    |                |
| time           | decimal(15,2) | YES  |     | NULL    |                |
| peak_memory    | int(11)       | NO   |     | NULL    |                |
| info           | mediumblob    | NO   |     | NULL    |                |
+----------------+---------------+------+-----+---------+----------------+
15 rows in set (0.00 sec)

@madalinoprea
Copy link
Owner

@coresh, yes that line will try to persist some info to the missing table. I wouldn't remove that. It will make the module useless :D

I can provide you raw SQL to create table by hand, but I would like to understand what is happening and why setup script is not running on your installation.

@coresh
Copy link
Author

coresh commented Mar 9, 2016

MariaDB [m0ent11422]> drop table sheep_debug_request_info;
ERROR 1051 (42S02): Unknown table 'magento1.sheep_debug_request_info'

@madalinoprea
Copy link
Owner

In your case that's expected, you don't have that table.

@coresh
Copy link
Author

coresh commented Mar 9, 2016

Dear Mario,
According to the setup:

magneto-debug/code/Debug/sql/sheep_debug_setup/install-1.3.0.php

I can't find the syntax with: CREATE TABLE sheep_debug_request_info...
As for the rest of the setup process no issues was found

@madalinoprea
Copy link
Owner

Table is added via Magento DDL object (Varien_Db_Adapter_Pdo_Mysql), see newTable call.

I notice that you use MariaDB. Maybe you use a different connection class that doesn't implement newTable?!

Query that is used to create the table is this:

CREATE TABLE `sheep_debug_request_info` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Id',
  `token` varchar(255) NOT NULL COMMENT 'Request Token',
  `http_method` varchar(32) NOT NULL COMMENT 'Http Method',
  `store_id` smallint(6) NOT NULL COMMENT 'Store Id',
  `request_path` varchar(255) NOT NULL COMMENT 'Request Path',
  `response_code` smallint(6) NOT NULL COMMENT 'Http Response Status Code',
  `ip` varchar(255) DEFAULT NULL COMMENT 'Customer IP',
  `session_id` varchar(255) DEFAULT NULL COMMENT 'Session Id',
  `date` datetime NOT NULL COMMENT 'Date',
  `rendering_time` decimal(15,2) DEFAULT NULL COMMENT 'Total Rendering Time',
  `query_time` decimal(15,2) DEFAULT NULL COMMENT 'Total Query Time',
  `query_count` int(11) NOT NULL COMMENT 'Total number of queries',
  `time` decimal(15,2) DEFAULT NULL COMMENT 'Total Time',
  `peak_memory` int(11) NOT NULL COMMENT 'Peak Memory used in bytes',
  `info` mediumblob NOT NULL COMMENT 'Serialized Info',
  PRIMARY KEY (`id`),
  KEY `IDX_SHEEP_DEBUG_REQUEST_INFO_TOKEN` (`token`),
  KEY `IDX_SHEEP_DEBUG_REQUEST_INFO_SESSION_ID` (`session_id`),
  KEY `IDX_SHEEP_DEBUG_REQUEST_INFO_REQUEST_PATH` (`request_path`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COMMENT='sheep_debug_request_info';

@coresh
Copy link
Author

coresh commented Mar 9, 2016

After creating the table

sheep_debug_request_info

magneto-debug v 1.6 worked like a charm
without commenting the 163 line: $this->getRequestInfo()->save();
Thanks for your perfect project and real-time support 👍

@madalinoprea
Copy link
Owner

No problem. Still I think we didn't resolve the root cause but at least you can use it.

Cheers,
Mario

@coresh
Copy link
Author

coresh commented Mar 9, 2016

Magic instance:

  1. modman remove magneto-debug
  2. drop table sheep_debug_request_info;
  3. modman clone https://github.com/madalinoprea/magneto-debug
  4. redis-cli FLUSHALL (n98-magerun.phar cache:flush)
  5. refreshing browser
    So issue with
SQLSTATE[42S02]: Base table or view not found: 1146 Table magento1.sheep_debug_request_info doesn't exist, query was: DESCRIBE sheep_debug_request_info
DELETE FROM core_resource WHERE code = sheep_debug_setup;

refreshing browser
table sheep_debug_request_info: created

Result: NO issue

So: issue may be around initial setup install-1.3.0.php.
Quick analyze of:

magneto-debug/code/Debug/sql/sheep_debug_setup/install-1.3.0.php

No problem detected
Strange behave...

@madalinoprea
Copy link
Owner

Is not me is you :)

I've also tried to replicate this issue using redis as cache backend, flushing cache using redis-cli and everything worked as expected at step 5.

Setup script is executed fist.
screen shot 2016-03-10 at 11 50 20

Profiling started
screen shot 2016-03-10 at 11 50 40

Profiling save (table should be there)
screen shot 2016-03-10 at 11 50 49

@coresh
Copy link
Author

coresh commented Mar 10, 2016

Any success?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants