osCommerce France : Accueil Forum Portail osCommerce France Réponses aux questions Foire aux contributions

Bienvenue invité ( Connexion | Inscription )

> OSC2.3 rame et plante mon serveur, Too many connections (my sql)
frogger74
posté 21 Feb 2012, 23:02
Message #1


Ceinture blanche OSC
Icône de groupe

Groupe : Membres
Messages : 12
Inscrit : 21-February 12
Membre no 30622



Bonjour,



Je possède une boutique OSC 2.2, j'ai décidé de passer à la version 2.1.3, j'ai donc transféré le contenue de mon catalogue et compte client vers cette nouvelle version, j'ai en plus installé SPPC, QTPRO et ECOTAXE.

Mon OSC 2.3 fonctionne bien, sauf que cette version de OSC est très lente, même dans sa version de base, surtout le backoffice, celui ci est 10 fois plus lent que la version 2.2… je sais que je possède pas mal de produits (1500) mais quand même.

Au point de faire planter le serveur SQL, je suis sur un serveur dédié (1 giga de RAM), j'ai décidé il y à quelques jours de mettre en ligne le site, 4 heures après le serveur était saturé :

Code
Erreur Too many connections

Warning: mysql_connect() [function.mysql-connect]: Too many connections in /home/monsite.com/public_html/boutique/includes/functions/database.php on line 20

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/monsite.com/public_html/boutique/includes/functions/database.php on line 24

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/monsite.com/public_html/boutique/includes/functions/database.php on line 25

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/monsite.com/public_html/boutique/includes/functions/database.php on line 26

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/monsite.com/public_html/boutique/includes/functions/database.php on line 27
Unable to connect to database server!


J'ai donc demandé à mon héberger, celui ci me dit en gros m'indique que c'est le site osc 2.1.3 qui bug, une application php qui tourne en boucle, en me disant également que OSC, ce n'était pas viable….. bref je ne veux pas rentrer dans cette polémique, je cherche juste à comprendre ce qui cloche avec les fonction SQL, je pense que trop de connexion SQL sont ouverte …..

Voici le code de ma page function/database.php

Code
<?php
/*
   $Id$
   adapted for Separate Pricing Per Customer 2005/03/04

   osCommerce, Open Source E-Commerce Solutions
   http://www.oscommerce.com

   Copyright (c) 2007 osCommerce

   Released under the GNU General Public License
*/

   function tep_db_connect($server = DB_SERVER, $username = DB_SERVER_USERNAME, $password = DB_SERVER_PASSWORD, $database = DB_DATABASE, $link = 'db_link') {
     global $link;

     if (USE_PCONNECT == 'true') {
       $link = mysql_pconnect($server, $username, $password);
     } else {
       $link = mysql_connect($server, $username, $password);
     }
     if ($link) mysql_select_db($database);
// Modification pour ecriture de la base SGL en CHARSET UTF-8
mysql_query("SET CHARACTER SET 'utf8'", $link);
mysql_query("SET NAMES utf8", $link);
mysql_query("SET CHARACTER_SET_CLIENT=utf8", $link);
mysql_query("SET CHARACTER_SET_RESULTS=utf8", $link);
// Modification pour ecriture de la base SGL en CHARSET UTF-8

     return $link;
   }

   function tep_db_close($link = 'db_link') {
     global $link;

     return mysql_close($link);
   }

   function tep_db_error($query, $errno, $error) {
     die('<font color="#000000"><strong>' . $errno . ' - ' . $error . '<br /><br />' . $query . '<br /><br /><small><font color="#ff0000">[TEP STOP]</font></small><br /><br /></strong></font>');
   }

   function tep_db_query($query, $link = 'db_link') {
     global $link;

     if (defined('STORE_DB_TRANSACTIONS') && (STORE_DB_TRANSACTIONS == 'true')) {
       error_log('QUERY ' . $query . "\n", 3, STORE_PAGE_PARSE_TIME_LOG);
     }

     $result = mysql_query($query, $link) or tep_db_error($query, mysql_errno(), mysql_error());

     if (defined('STORE_DB_TRANSACTIONS') && (STORE_DB_TRANSACTIONS == 'true')) {
        $result_error = mysql_error();
        error_log('RESULT ' . $result . ' ' . $result_error . "\n", 3, STORE_PAGE_PARSE_TIME_LOG);
     }

     return $result;
   }

   function tep_db_perform($table, $data, $action = 'insert', $parameters = '', $link = 'db_link') {
     reset($data);
     if ($action == 'insert') {
       $query = 'insert into ' . $table . ' (';
       while (list($columns, ) = each($data)) {
         $query .= $columns . ', ';
       }
       $query = mb_substr($query, 0, -2) . ') values (';
       reset($data);
       while (list(, $value) = each($data)) {
         switch ((string)$value) {
           case 'now()':
             $query .= 'now(), ';
             break;
           case 'null':
             $query .= 'null, ';
             break;
           default:
             $query .= '\'' . tep_db_input($value) . '\', ';
             break;
         }
       }
       $query = mb_substr($query, 0, -2) . ')';
     } elseif ($action == 'update') {
       $query = 'update ' . $table . ' set ';
       while (list($columns, $value) = each($data)) {
         switch ((string)$value) {
           case 'now()':
             $query .= $columns . ' = now(), ';
             break;
           case 'null':
             $query .= $columns .= ' = null, ';
             break;
           default:
             $query .= $columns . ' = \'' . tep_db_input($value) . '\', ';
             break;
         }
       }
       $query = mb_substr($query, 0, -2) . ' where ' . $parameters;
     }

     return tep_db_query($query, $link);
   }

   function tep_db_fetch_array($db_query) {
     return mysql_fetch_array($db_query, MYSQL_ASSOC);
   }

   function tep_db_num_rows($db_query) {
     return mysql_num_rows($db_query);
   }

   function tep_db_data_seek($db_query, $row_number) {
     return mysql_data_seek($db_query, $row_number);
   }

   function tep_db_insert_id($link = 'db_link') {
     global $link;

     return mysql_insert_id($link);
   }

   function tep_db_free_result($db_query) {
     return mysql_free_result($db_query);
   }

   function tep_db_fetch_fields($db_query) {
     return mysql_fetch_field($db_query);
   }

   function tep_db_output($string) {
     return htmlspecialchars($string);
   }

   function tep_db_input($string, $link = 'db_link') {
     global $link;

     if (function_exists('mysql_real_escape_string')) {
       return mysql_real_escape_string($string, $link);
     } elseif (function_exists('mysql_escape_string')) {
       return mysql_escape_string($string);
     }

     return addslashes($string);
   }

   function tep_db_prepare_input($string) {
     if (is_string($string)) {
       return trim(tep_sanitize_string(stripslashes($string)));
     } elseif (is_array($string)) {
       reset($string);
       while (list($key, $value) = each($string)) {
         $string[$key] = tep_db_prepare_input($value);
       }
       return $string;
     } else {
       return $string;
     }
   }
// BOF Separate Pricing Per Customer, adapted from sample code in user comments on
   // http://www.php.net/manual/en/function.mysql-list-tables.php
   // Wrap DB_DATABASE with Back Ticks, Fixes Hyphens in Database Name, code from
   // Jef Stumpf/Krumbsnatcher: http://forums.oscommerce.com/index.php?showtopic=53436&view=findpost&p=563454
   function tep_db_table_exists($table, $link = 'db_link') {
       $result = tep_db_query("show table status from `" . DB_DATABASE . "`");
       while ($list_tables = tep_db_fetch_array($result)) {
         if ($list_tables['Name'] == $table) {
             return true;
         }
       }
       return false;
   }

   function tep_db_check_age_specials_retail_table() {
       $result = tep_db_query("show table status from `" . DB_DATABASE . "`");
       $last_update_table_specials = "2000-01-01 12:00:00";
       $table_srp_exists = false;
       while ($list_tables = tep_db_fetch_array($result)) {
       if ($list_tables['Name'] == TABLE_SPECIALS_RETAIL_PRICES) {
         $table_srp_exists = true;
         $last_update_table_srp = $list_tables['Update_time'];
       }
         if ($list_tables['Name'] == TABLE_SPECIALS) {
         $last_update_table_specials = $list_tables['Update_time'];
         }
       } // end while

       if(!$table_srp_exists || ($last_update_table_specials > $last_update_table_srp)) {
          if ($table_srp_exists) {
              $query1 = "truncate " . TABLE_SPECIALS_RETAIL_PRICES . "";
              if (tep_db_query($query1)) {
                      $query2 = "insert into " . TABLE_SPECIALS_RETAIL_PRICES . " select s.products_id, s.specials_new_products_price, s.status, s.customers_group_id from " . TABLE_SPECIALS . " s where s.customers_group_id = '0'";
                      $result =  tep_db_query($query2);
                  }
          } else { // table specials_retail_prices does not exist
              $query1 = "create table " . TABLE_SPECIALS_RETAIL_PRICES . " (products_id int NOT NULL default '0', specials_new_products_price decimal(15,4) NOT NULL default '0.0000', status tinyint, customers_group_id smallint, primary key (products_id) )";
              $query2 = "insert into " . TABLE_SPECIALS_RETAIL_PRICES . " select s.products_id, s.specials_new_products_price, s.status, s.customers_group_id from " . TABLE_SPECIALS . " s where s.customers_group_id = '0'";
              if( tep_db_query($query1) && tep_db_query($query2) ) {
                   ; // execution succesfull
                  }
                 } // end else
             } // end if(!$table_srp_exists || ($last_update_table_specials....
         }

   function tep_db_check_age_products_group_prices_cg_table($customer_group_id) {
       $result = tep_db_query("show table status from `" . DB_DATABASE . "`");
       $last_update_table_pgp = strtotime('2000-01-01 12:00:00');
       $table_pgp_exists = false;
       while ($list_tables = tep_db_fetch_array($result)) {
             if ($list_tables['Name'] == TABLE_PRODUCTS_GROUP_PRICES.$customer_group_id) {
                 $table_pgp_exists = true;
                 $last_update_table_pgp = strtotime($list_tables['Update_time']);
             } elseif ($list_tables['Name'] == TABLE_SPECIALS ) {
                 $last_update_table_specials = strtotime($list_tables['Update_time']);
             } elseif ($list_tables['Name'] == TABLE_PRODUCTS ) {
                 $last_update_table_products = strtotime($list_tables['Update_time']);
             } elseif ($list_tables['Name'] == TABLE_PRODUCTS_GROUPS ) {
                 $last_update_table_products_groups = strtotime($list_tables['Update_time']);
             }
       } // end while

     if ($table_pgp_exists == false) {
       $create_table_sql = "create table " . TABLE_PRODUCTS_GROUP_PRICES.$customer_group_id . " (products_id int NOT NULL default '0', products_price decimal(15,4) NOT NULL default '0.0000', specials_new_products_price decimal(15,4) default NULL, status tinyint, primary key (products_id) )";
       $fill_table_sql1 = "insert into " . TABLE_PRODUCTS_GROUP_PRICES.$customer_group_id ." select p.products_id, p.products_price, NULL as specials_new_products_price, NULL as status FROM " . TABLE_PRODUCTS . " p";
       $update_table_sql1 = "update " . TABLE_PRODUCTS_GROUP_PRICES.$customer_group_id ." ppt left join " . TABLE_PRODUCTS_GROUPS . " pg using(products_id) set ppt.products_price = pg.customers_group_price where ppt.products_id = pg.products_id and pg.customers_group_id ='" . $customer_group_id . "'";
       $update_table_sql2 = "update " . TABLE_PRODUCTS_GROUP_PRICES.$customer_group_id ." ppt left join " . TABLE_SPECIALS . " s using(products_id) set ppt.specials_new_products_price = s.specials_new_products_price, ppt.status = s.status where ppt.products_id = s.products_id and s.customers_group_id = '" . $customer_group_id . "'";
             if ( tep_db_query($create_table_sql) && tep_db_query($fill_table_sql1) && tep_db_query($update_table_sql1) && tep_db_query($update_table_sql2) ) {
                      return true;
             }
         } // end if ($table_pgp_exists == false)
    
         if ( ($last_update_table_pgp < $last_update_table_products && (time() - $last_update_table_products > (int)MAXIMUM_DELAY_UPDATE_PG_PRICES_TABLE * 60) ) || $last_update_table_specials > $last_update_table_pgp || $last_update_table_products_groups > $last_update_table_pgp ) { // then the table should be updated
       $empty_query = "truncate " . TABLE_PRODUCTS_GROUP_PRICES.$customer_group_id . "";
       $fill_table_sql1 = "insert into " . TABLE_PRODUCTS_GROUP_PRICES.$customer_group_id ." select p.products_id, p.products_price, NULL as specials_new_products_price, NULL as status FROM " . TABLE_PRODUCTS . " p";
       $update_table_sql1 = "update " . TABLE_PRODUCTS_GROUP_PRICES.$customer_group_id ." ppt left join " . TABLE_PRODUCTS_GROUPS . " pg using(products_id) set ppt.products_price = pg.customers_group_price where ppt.products_id = pg.products_id and pg.customers_group_id ='" . $customer_group_id . "'";
       $update_table_sql2 = "update " . TABLE_PRODUCTS_GROUP_PRICES.$customer_group_id ." ppt left join " . TABLE_SPECIALS . " s using(products_id) set ppt.specials_new_products_price = s.specials_new_products_price, ppt.status = s.status where ppt.products_id = s.products_id and s.customers_group_id = '" . $customer_group_id . "'";
       if ( tep_db_query($empty_query) && tep_db_query($fill_table_sql1) && tep_db_query($update_table_sql1) && tep_db_query($update_table_sql2) ) {
           return true;
       }
         } else { // no need to update
              return true;
         } // end checking for update

   }

// EOF Separate Pricing Per Customer
?>



Peut être que SPPC etc pourrait être mieux adapté au autres contribution, du moin dans sa gestion de mysql... non? n'étant pas un grand expert en mysql , je patauge.. unsure.gif

Mais cela n'explique pas quel en serait la cause… d'autant que j'avais essayé de récupérer un peu de vitesse en supprimant des functions, mais çà n'y change rien, le problème doit être identique pour le backoffice , voir même pire , car il faut attendre presque 20 secondes à chaque action clique. (c'est sur que c'est plus rapide si je n'est qu'une centaine de produits.)

Peut être aussi le serveur dédié qui commence à saturer (1 Giga de ram), voir aussi le module MySQL du serveur (max_connections) qui pourrait être paramétré à la hausse… mais je pense qu'une optimisation du code de L'osc 2.3 serait plus intéressant.

ensuite en cherchant un peu j'ai trouvé ceci dans configure.php, y'a t'il un rapport ?
Code
define('USE_PCONNECT', 'false');
define('STORE_SESSIONS', 'mysql');


Donc, je pense changer d'hébergeur, pour passer sur un serveur dédié plus performant et infogéré par une équipe à l'écoute, car l'hébergeur actuel, n'a que faire de mes problèmes… ainsi un diagnostique pourrait être entrepris…

Bref, si vous avez une idée sur ce problème, je suis preneur… car je suis très déçu par la version OSC2.3 et je ne sais pas ou chercher, je commence à regretter son installation. confused.gif ??:

Merci pour votre aide cool.gif

Ce message a été modifié par frogger74 - 23 Feb 2012, 09:12.
Go to the top of the page
 
 
Start new topic
Réponse(s)
krokus
posté 25 Feb 2012, 10:31
Message #2


Ceinture orange+ OSC
Icône de groupe

Groupe : Membres
Messages : 337
Inscrit : 23-February 07
Membre no 15518



Bonjour, etant sur un mutualise avec + de 2000 produits et osc 2.3, je peus te dire que ce n'est pas la 2.3 qui est en cause mais certainement un addon mal installe ou non prevue pour la 2.3.
Maintenant je ne suis pas un as, mais plus d'info sur ta config serveur serait interessant.


--------------------
Ms2.3+Category Description+Ckeditor+Colissimo+EasyPopulate+Header tags seo+Otf autothumb+PIM osSlideshow+Theme switcher+Ultimate Seo Urls+Icone stock+crawlprotect+Who's Online Enhancement+Master password+lien suivi colis
Go to the top of the page
 

Les messages de ce sujet
- frogger74   OSC2.3 rame et plante mon serveur   21 Feb 2012, 23:02
- - krokus   Bonjour, etant sur un mutualise avec + de 2000 pro...   25 Feb 2012, 10:31
- - frogger74   Citation (krokus @ 25 Feb 2012, 10:31) Bo...   26 Feb 2012, 14:15
- - Gnidhal   Bonjour, déjà évoqué ailleurs, tu as à ta disposi...   26 Feb 2012, 15:10
- - frogger74   Merci Gnidhal, Tu me met sur la voix, j'ai m...   26 Feb 2012, 23:27
- - FoxP2   Citation (frogger74 @ 21 Feb 2012, 23:02)...   27 Feb 2012, 07:49
- - Gnidhal   Citation (FoxP2 @ 27 Feb 2012, 07:49) 10 ...   27 Feb 2012, 09:31
- - frogger74   Citation (Gnidhal @ 27 Feb 2012, 09:31) C...   27 Feb 2012, 11:56
- - frogger74   Bon, pour ceux que çà intéresse, j'avance dans...   27 Feb 2012, 15:05
- - Gnidhal   houla! STOOOOP! Mon exemple de boucle for...   27 Feb 2012, 16:52
- - frogger74   Déjà l'infographiste que je suis à ses limites...   27 Feb 2012, 18:40
- - Gnidhal   Citation (frogger74 @ 27 Feb 2012, 18:40)...   27 Feb 2012, 19:02
- - frogger74   Salut! En fait , je compte passer sur un ser...   27 Feb 2012, 21:19
- - Gnidhal   ce n'est pas la base qui est mal ficelée, ce s...   27 Feb 2012, 22:43
- - FoxP2   Le développement, ça ne s'invente pas, ça s...   28 Feb 2012, 00:21
- - frogger74   J'avais déjà fait appel à un développeur, mais...   28 Feb 2012, 10:23
- - FoxP2   Citation (frogger74 @ 28 Feb 2012, 10:23)...   28 Feb 2012, 10:54
- - paddybl   salut à tous, comme on parle d'ecotax je me p...   28 Feb 2012, 16:48
- - Gnidhal   Citation (paddybl @ 28 Feb 2012, 16:48) l...   28 Feb 2012, 17:46
- - frogger74   Salut Paddybl, Citation (paddybl @ 28 Feb 20...   28 Feb 2012, 23:19
- - paddybl   Je suis d'accord avec toi gnidhal,c'est pa...   29 Feb 2012, 09:28
- - Gnidhal   Citation (paddybl @ 29 Feb 2012, 09:28) m...   29 Feb 2012, 09:44
- - paddybl   tient j'ai retrouvé ca en réponse à un courrie...   29 Feb 2012, 11:26
- - FoxP2   il y a une piste à explorer : étant donné que le s...   29 Feb 2012, 11:50
- - paddybl   je dis pas le contraire fox... il étaient tout à f...   29 Feb 2012, 12:08
- - Gnidhal   @paddybl Si je résume ce qui est dit dans les docu...   29 Feb 2012, 12:37
- - paddybl   tient j'ai retrouvé l'exemple de facture c...   29 Feb 2012, 12:54
- - paddybl   frogger74 m'a envoyé sont fichier categories ...   29 Feb 2012, 15:30
- - paddybl   bien je modifie moi même le code pour ne plus fair...   29 Feb 2012, 16:01
- - Gnidhal   on peut toujours optimiser un peu : une façon de d...   29 Feb 2012, 16:32
- - paddybl   pas béte en effet. au final qu'en j'avais ...   29 Feb 2012, 17:29
- - frogger74   Bonjour à tous! Merci à vous et désolé de ré...   8 Mar 2012, 09:50
- - davas   Bonjour, Merci à tous pour tous vos contributions...   1 Nov 2012, 10:52


Reply to this topicStart new topic
1 utilisateur(s) sur ce sujet (1 invité(s) et 0 utilisateur(s) anonyme(s))
0 membre(s) :

 



RSS Version bas débit Nous sommes le : 19th March 2024 - 08:48
Ce site est déclaré auprès de la commision Nationale
de l'Informatique et des Libertés (déclaration n°: 1043896)