Database Errors-What Causes This


My site was down and I checked the database in cPanel and did the repair. I saw several times:

warning : Table is marked as crashed

warning : 1 client is using or hasn’t closed the table properly

I also saw “error occured” on the customer side, but it seemed like admin was OK. Typically, both interfaces are affected when something is wrong with the database.

Can anyone please explain the above warnings and how to prevent.



Update: I saw this database error in admin when I fixed database (partial):

Error: Incorrect key file for table './database_name/cscart_sessions.MYI'; try to repair it (126)

Query: REPLACE INTO cscart_sessions (session_id, area, expiry, data) VALUES ('4c3f7c2d6aae6377d9a69fd231752a32', 'A', '1415968195', 'settings|a:2:{s:14:"cart_languageA";a:2:{s:5:"value";s:2:"EN";s:6:"expiry";i:1416167277;}s:19:"secondary_currencyA";a:2:{s:5:"value";s:3:"USD";s:6:"expiry";i:1416167277;}}_validator_data|a:1:{s:2:"ua";s:72:"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:33.0) Gecko/20100101 Firefox/33.0";}auth|a:14:{s:4:"area";s:1:"A";s:7:"user_id";s:1:"1";s:10:"tax_exempt";s:1:"N";s:10:"last_login";s:10:"1415916637";s:13:"usergroup_ids";a:0:{}s:9:"order_ids";a:0:{}s:11:"act_as_user";b:0;s:10:"this_login";i:1415960963;s:25:"password_change_timestamp";s:10:"1407286634";s:10:"company_id";i:0;s:7:"is_root";s:1:"Y";s:7:"referer";s:90:"Administration panel";b:0;}cart|a:0:{}last_edited_items|a:10:{i:3869836857;a:4:{s:4:

There was more after the above

The backtrace had:

/home/treasure/public_html/core/fn.database.php (db_error): 259

/home/treasure/public_html/core/class.session.php (db_query): 100

/home/treasure/public_html/core/class.session.php (save): 74

Normally this happens when your server runs out of resources (usually memory) to service the traffic on your site. Increase your server's memory or work with your host to identify what resources are failing and causing mysql to crash.

[quote name='tbirnseth' timestamp='1416016139' post='197057']

Normally this happens when your server runs out of resources (usually memory) to service the traffic on your site. Increase your server's memory or work with your host to identify what resources are failing and causing mysql to crash.


apsolute overload problem… you are hitting resources limits…if you are on shared hosting… check cpanel…

Thanks for your input. Been having database errors more often recently. Host has applied all memory setting based on CS-Cart Support recommendations. Temp space is at least 4-5 times the database size.

This morning, had errors: no one on the site.

I only have about 40 - 50 visitors per 24 hour period, except when during sales, I may have up to 20-30 visitors within an hour. This is rare. Errors occur even when no one is on the site.

However, I recently turned on statistics (had off per recommendations from cs-cart forum) and find there is much activity with crawlers/robots. Have seen 300 page views from one in China. This is as much as 30 customers look at over a day. There are more crawlers per period of time then customers.

Could these crawlers/robots be the cause of resource usage? It's obviously not due to customer usage or my own, which is minimal. I can find ways to restrict most of them.

I am on a shared server. With only 30-50 customers a day, I don't think I am at the level where a dedicated server is required.

As stated above, my host said they did everything recommended regarding resource allocation. Let me know if you have any recommendation of resource allocation/settings that I can check and can be set for shared servers.

Thanks for your help.


May want to check “Cscart_Stored_Sessions”. Sounds like you are getting zinged by bots too. We had to turn on mod_security and block some of the IP addresses of the bots to slow it down. Sadly though we still get plenty of data base errors and the professional “ah shucks” too.

Please note that I can't seem to get an answer out of CS-Cart if you are able to use mod_security or not. They tend to avoid the issue and do not give a straight answer that I can find. Plus you may not be able to put it on a shared server, but it sounds like some shared servers have it. I'm just not for sure.

Is the site you are getting the errors on using CS 2.2.4?

Shared service is just that. You are at the mercy of what others are doing on that same server and it will be invisible to you.

A VPS is not that expensive and is a much better solution for a business.

Your host should be able to determine what is causing mysld to crash and thereby corrupting your tables.

Note you don't need mod_security with cs-cart. However if you run other software on your site (like Wordpress) then it might be a good idea.

We do not have Wordpress on our server. Our problems were with CS-Cart and bots hitting us which caused this stored sessions file growing to an enormous size.

In regards to a VPS, we tried that route but with little luck. With 3 different host our server shut down constantly because there were never enough resources for CS. At first we thought it was the host, then we realized it had more to do with CS. Sadly, many of the same sites work fine or better on a shared package than they do on a VPS. In order to get CS to function at any decent speed and not shut down the virtual private server we had to go to a dedicated server. The problem at that point is if the bots start to hit your site it will kill a server too. So that was why we had to turn on mod_security.

While I respect Tony's opinion on mod_security there are other veterans of the cart that say you should have it installed. So who knows. I do wish CS-Cart admin would offer their advise, but so far I have not seen a solid answer from them.

Clips, never did answer your question. Yes, I am using CS 2.2.4?.

Site has been down most of the weekend with constant database errors. Most related to temp tables, but there are many others.


Wanna post some of the errors? Temp file issues are usually a result of inadequate disk space for either temporary tables created for searches (most likely) or for joins (less likely), By default, mySQL uses /tmp as it's tempoarry storage area. Generally this is a small space. Suggest you have your host re-configure it to a larger area but probably not on the same drive as the actual database tables and indexes.