magento - index management - Cannot initialize the indexer process

Posted by Damodar Bashyal on September 27, 2011

 

First thing I would like to say is I absolutely hate re-indexing manually on Magento. But as we all Magento Developers have no choice but to fix it and make client and boss happy. We encounter errors that gives more headache if we don't find the solution straight away. Sometimes I have to browse through so many magento forums pages with no luck. So, I'm going to show you how to fix this annoying magento reindexing error. When I tried to re-index products first I got this error.

Cannot initialize the indexer process.

Then again when I re-tried it, I got below error:

There was a problem with reindexing process.SQLSTATE[HY000]: General error: 1005 Can't create table 'magento.catalog_category_flat_store_1' (errno: 150)

So, I run index from command line:

php shell/indexer.php reindexall

But I got the following error again:

Category Flat Data index process unknown error: exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 1005 Can't create table './magento.catalog_category_flat_store_1.frm' (errno: 150)' in /home/magento/public_html/lib/Zend/Db/Statement/Pdo.php: 228

But these few lines saved me. Run these sql commands on phpMyadmin or command line to your magento database and you will be able to reindex again.

ALTER TABLE catalog_category_entity ENGINE=INNODB;
ALTER TABLE core_store ENGINE=INNODB;

I also deleted all the .locks file from the var/locks folder. If none found then make sure, the var/locks folder is writable.

Then I re-run the indexer and everything was back to normal. yay!

[email protected] [~/public_html/shell]# php indexer.php reindexall
Product Attributes index was rebuilt successfully
Product Prices index was rebuilt successfully
Catalog URL Rewrites index was rebuilt successfully
Product Flat Data index was rebuilt successfully
Category Flat Data index was rebuilt successfully
Category Products index was rebuilt successfully
Catalog Search Index index was rebuilt successfully
Stock Status index was rebuilt successfully
Tag Aggregation Data index was rebuilt successfully

UPDATE:

I had reindex issue again and fixed by deleting flat tables and then reindexed successfully.

I created list of flat tables by running below command on mysql.

SELECT CONCAT('DROP TABLE ', table_name, ';') AS sql_statements
FROM    information_schema.tables AS tb
WHERE   table_schema = 'database_name'
AND     `table_name` like 'catalog_%flat%'
ORDER BY table_name;

I got below result:

DROP TABLE catalog_category_flat_store_1; 
DROP TABLE catalog_category_flat_store_10;
DROP TABLE catalog_category_flat_store_2; 
DROP TABLE catalog_category_flat_store_3; 
DROP TABLE catalog_category_flat_store_4; 
DROP TABLE catalog_category_flat_store_5; 
DROP TABLE catalog_category_flat_store_6; 
DROP TABLE catalog_category_flat_store_7; 
DROP TABLE catalog_category_flat_store_8; 
DROP TABLE catalog_category_flat_store_9; 
DROP TABLE catalog_product_flat_1;        
DROP TABLE catalog_product_flat_10;       
DROP TABLE catalog_product_flat_6;        
DROP TABLE catalog_product_flat_7;        
DROP TABLE catalog_product_flat_8;        
DROP TABLE catalog_product_flat_9; 

And then I ran each sql statement to delete flat tables.

Did that solved your re-indexing issue in your magento admin? Let me know if you know any other tips and tricks to solve this bug or issue.

Please like and +1 to support us.

ajay jain posted on - Thursday 24th of November 2011 10:38:03 PM

Hi,

nice post . i have resolved my bug

Mikal posted on - Thursday 24th of May 2012 10:31:32 AM

Thank you for sharing, it saves me a day.

kriss posted on - Saturday 14th of April 2012 10:13:03 PM

did not work using 1.6.1

atwix posted on - Wednesday 25th of July 2012 11:58:42 AM

Thanks for information. Our team has also investigated and described this topic in the article http://www.atwix.com/magento/process-magento-indexes-from-command-line/ We hope this information will be useful. You’re welcome to check it out and leave your feedback

cristian posted on - Tuesday 30th of October 2012 10:18:51 AM

Worked! After trying 1000 things, this finally did it. Thank you!!!!!

Rob de koning posted on - Saturday 19th of January 2013 10:55:53 AM

Thanks for sharing! this worked great in Magento 1.7.0.2

andy posted on - Monday 11th of February 2013 07:40:42 PM

I still get an error:-

PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/sqlite.so' - /usr/lib64/php/modules/sqlite.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: Directive 'safe_mode' is deprecated in PHP 5.3 and greater in Unknown on line 0

oginome posted on - Tuesday 19th of March 2013 08:38:51 AM

It fixed the problem, thx. ~

But I can't alter the tables back to MyISAM.
Seems due to the foreign key constraint.
When try to drop the foreign key, it returns another error : #1025 - Error on rename of... ... ...

Can anyone post the steps to alter these 2 tables from innodb to myisam? thx. thx.

Alex posted on - Thursday 4th of July 2013 11:39:17 AM

Hey I had the same problem and nothing fixed it. WIth Mage 1.7 , I simply went to the admin/system/configuration/catalog then "frontend", switched Use Flat Catalog Product to "Yes". Reindex worked. Then back there, switched it back to "no". Reindex again, it worked. Hope it helps :D

PS : I don't know if it is related, but I did truncate the catalog_product_fat tables, and empty var folder before (it didn't change anything until I did what's up there, tho)

PS 2 : Problem initially happened after my Reindex timed out.

hhref posted on - Wednesday 28th of August 2013 09:43:49 AM

YOU MADE MY DAY TOO!!!

Guillermo posted on - Wednesday 28th of August 2013 09:43:49 AM

Thanks a lot! I tried many different options, but this did the trick!

Shadow On The Sun posted on - Monday 11th of November 2013 12:15:39 PM

Hey! Thanks for this! Saved my day!

Prashant posted on - Saturday 28th of June 2014 10:54:19 AM

thanx man! you saved alot of developement time...........

Rob posted on - Wednesday 11th of December 2013 07:40:57 AM

How do i trace and find the dublicated tables. I understand that magento has 400 tables.

James Simpson posted on - Sunday 19th of January 2014 11:22:49 PM

It didn't work for the issue I am having with the Product Price index. And so far I think I've tried everything/

Ilia posted on - Saturday 19th of July 2014 04:31:13 AM

thanks! in my case i needed to change table name to mg_xxx (like mg_core_store)

Jeffrey Meyer posted on - Wednesday 23rd of July 2014 09:38:28 AM

awesome fixed it in just a few seconds.
Thank you for the help!

filipe posted on - Saturday 28th of June 2014 10:54:19 AM

wowwwwwww. Thanksss so much!

shaima posted on - Sunday 5th of October 2014 12:14:59 AM

My product price not re indexing .i try every thing no success , plz help me out

Andhi Irawan posted on - Wednesday 17th of September 2014 10:59:50 AM

not working in me.still have this message :

Next exception 'Zend_Db_Statement_Exception' with message 'SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`data_2014`.`catalog_category_product_index`, CONSTRAINT `catalog_category_product_index_ibfk_3` FOREIGN KEY (`product_id`) REFERENCES `catalog_product_entity` (`entity_id`) ON DELETE CASCADE)' in /usr/share/nginx/html/data.2014/lib/Zend/Db/Statement/Pdo.php:234

saqib posted on - Tuesday 21st of April 2015 07:41:04 AM

I Resolved this Thanks
 
not published on website


QR Code: magento - index management - Cannot initialize the indexer process