inc-cache.php3 inc-public-global.php3 1.64 1.153 1.65 1.154

Update of /home/spip-cvs/spip
In directory alan:/tmp/cvs-serv27391

Modified Files:
  inc-cache.php3 inc-public-global.php3
Log Message:
problème de perf MYSQL quand une foule de process attaquent en même temps la table d'invalidation

Index: inc-public-global.php3

RCS file: /home/spip-cvs/spip/inc-public-global.php3,v
retrieving revision 1.153
retrieving revision 1.154
diff -u -d -r1.153 -r1.154
--- inc-public-global.php3 10 Oct 2004 07:02:33 -0000 1.153
+++ inc-public-global.php3 22 Oct 2004 16:21:38 -0000 1.154
@@ -121,17 +121,17 @@
     }
   }

- // Calculer le chemin putatif du cache
- $chemin_cache = generer_nom_fichier_cache('', $fond);
-
   // Faut-il effacer des pages invalidees ?
   if (lire_meta('invalider')) {
     include_ecrire('inc_meta.php3');
     lire_metas();
     if (lire_meta('invalider'))
- retire_caches($chemin_cache);
+ retire_caches();
   }

+ // Calculer le chemin putatif du cache
+ $chemin_cache = generer_nom_fichier_cache('', $fond);
+
   // Peut-on utiliser un fichier cache ?
   determiner_cache($delais, $use_cache, $chemin_cache);

Index: inc-cache.php3

RCS file: /home/spip-cvs/spip/inc-cache.php3,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -d -r1.64 -r1.65
--- inc-cache.php3 19 Oct 2004 19:56:02 -0000 1.64
+++ inc-cache.php3 22 Oct 2004 16:21:38 -0000 1.65
@@ -88,35 +88,25 @@
}

// Supprimer les caches marques "x"
-function retire_caches($chemin_prioritaire = '') {
+function retire_caches() {
   if ($GLOBALS['flag_ecrire']) return;

- // inutile de ramer si tout est invalide, on n'est pas tout seul
- $max = 30;
- // mais recuperer en priorite notre chemin
- if ($chemin_prioritaire)
- $order = "ORDER BY fichier != '$chemin_prioritaire'";
+ // signaler
+ effacer_meta('invalider');
+ ecrire_metas();

- // faire le boulot de suppression
- $q = spip_query("SELECT DISTINCT fichier FROM spip_caches
- WHERE type='x' $order LIMIT 0,$max");
- if ($n = @spip_num_rows($q)) {
+ // recuperer la liste des caches voues a la suppression
+ $suppr = array();
+ $q = spip_query("SELECT fichier FROM spip_caches WHERE type='x'");
+ while ($r = spip_fetch_array($q))
+ $suppr[$r['fichier']] = true;
+
+ if ($n = count($suppr)) {
     spip_log ("Retire $n caches");
- while (list($cache) = spip_fetch_array($q)) {
+ foreach ($suppr as $cache => $ignore)
       retire_cache($cache);
- $supprimes[] = "'$cache'";
- }
     spip_query("DELETE FROM spip_caches WHERE "
- .calcul_mysql_in('fichier', join(',',$supprimes)) );
- }
-
- // marque comme fait
- if (count($supprimes) < $max) {
- effacer_meta('invalider');
- ecrire_metas();
- } else {
- ecrire_meta('invalider', 'oui');
- ecrire_metas();
+ .calcul_mysql_in('fichier', "'".join("','",$supprimes)."'") );
   }
}

@@ -152,7 +142,7 @@
   // ne jamais recalculer pour les moteurs de recherche, proxies...
   if ($HTTP_SERVER_VARS['REQUEST_METHOD'] == 'HEAD')
     $ok_cache = true;
- spip_log("'$ok_cache'");
+ #spip_log("'$ok_cache'");
   return $ok_cache;
}