Merge lp:~catch-drupal/pressflow/path_slow_query into lp:pressflow

Proposed by Nathaniel Catchpole
Status: Rejected
Rejected by: David Strauss
Proposed branch: lp:~catch-drupal/pressflow/path_slow_query
Merge into: lp:pressflow
Diff against target: 98 lines (+20/-18)
3 files modified
includes/common.inc (+6/-1)
modules/path/path.module (+1/-1)
modules/path_alias_cache/path_alias_cache.module (+13/-16)
To merge this branch: bzr merge lp:~catch-drupal/pressflow/path_slow_query
Reviewer Review Type Date Requested Status
Nathaniel Catchpole (community) Disapprove
Narayan Newton Pending
David Strauss Pending
Review via email: mp+57707@code.launchpad.net

This proposal supersedes a proposal from 2010-12-01.

Description of the change

Backporting selective full rebuilding of the path alias whitelist from Drupal 7.

 - update fixed an omission that meant the new code never actually stopped the slow query from running.
 - added a default argument for the whitelist rebuild.
 - remove path_alias_flush_caches() - the whitelist is stored in cache_path, and it doesn't matter if the other caches get stale. This was causing the whitelist query (which is very, very slow) to run every cron run.

To post a comment you must log in.
Revision history for this message
Narayan Newton (nnewton-drupal) wrote : Posted in a previous version of this proposal

Taking this to review, testing a deploy currently.

Revision history for this message
Narayan Newton (nnewton-drupal) wrote : Posted in a previous version of this proposal

This looks good to me and has been working well on two client sites. Marking approved. This also merges cleanly with 6.20.

review: Approve
Revision history for this message
David Strauss (davidstrauss) wrote : Posted in a previous version of this proposal

I'll interpret Narayan's approval as a sign I should check this out for
merging. Cool beans.
On Jan 5, 2011 4:01 PM, "Narayan Newton" <email address hidden> wrote:
> Review: Approve
> This looks good to me and has been working well on two client sites.
Marking approved. This also merges cleanly with 6.20.
> --
>
https://code.launchpad.net/~catch-drupal/pressflow/path_slow_query/+merge/42333
> You are requested to review the proposed merge of
lp:~catch-drupal/pressflow/path_slow_query into lp:pressflow.

Revision history for this message
Nathaniel Catchpole (catch-drupal) wrote : Posted in a previous version of this proposal

Friendly bump, just found this causing issues on another client site, and thought this had been committed until I did a fresh checkout.

Revision history for this message
Nathaniel Catchpole (catch-drupal) wrote :

Another way to fix the hook_flush_caches() issue would be to put this into a variable instead of using cache_get()/cache_set() for the whitelist. This is was D7 does but it's more of a change, so leaving as it is for now.

102. By Nathaniel <catch@catch-toshiba>

Merge in trunk.

103. By Nathaniel <catch@catch-toshiba>

Use a variable instead of cache system for the whitelist - the cache maintains itself, and the rebuild query is extremely slow on large data sets. Also patches Drupal 7 core version.

Revision history for this message
Nathaniel Catchpole (catch-drupal) wrote :

Just made a new push here to use a variable rather than the cache system. The cache maintains itself pretty well, and rebuilding is extremely expensive, so it is better to only rebuild it when absolutely requested rather than when {cache_path} might get wiped in general.

Revision history for this message
Judah Anthony (judahanthony) wrote :

May I ask the progress of this branch?

Revision history for this message
Nathaniel Catchpole (catch-drupal) wrote :

I'm now working in https://github.com/tag1consulting/pressflow6/tree/path_alias_slow_query - was getting hard to manage multiple branches in bzr.

review: Disapprove
Revision history for this message
David Strauss (davidstrauss) wrote :

Just to let folks here know, I've moved Pressflow 6 to GitHub: https://github.com/pressflow/6

Please post any new requested changes as pull requests there for review and integration.

Revision history for this message
David Strauss (davidstrauss) wrote :

Pressflow 6 is now maintained on GitHub, so I'm marking this merge as rejected.

Unmerged revisions

103. By Nathaniel <catch@catch-toshiba>

Use a variable instead of cache system for the whitelist - the cache maintains itself, and the rebuild query is extremely slow on large data sets. Also patches Drupal 7 core version.

102. By Nathaniel <catch@catch-toshiba>

Merge in trunk.

101. By Nathaniel Catchpole <catch@catch-laptop>

Remove path_alias_cache_flush_caches() - stops the whitelist being rebuilt every cron run.

100. By Nathaniel <catch@catch-toshiba>

Add default argument for path_alias_cache_path_whitelist_rebuild().

99. By Nathaniel <catch@catch-toshiba>

Minus the typo.

98. By Nathaniel <catch@catch-toshiba>

Actually stop the slow query from running.

97. By Nathaniel Catchpole <catch@catch-laptop>

#612878 - path alias cache slow query on node inserts.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'includes/common.inc'
2--- includes/common.inc 2011-06-01 07:13:05 +0000
3+++ includes/common.inc 2011-07-01 04:46:30 +0000
4@@ -127,8 +127,13 @@
5 /**
6 * Reset the static variable which holds the aliases mapped for this request.
7 */
8-function drupal_clear_path_cache() {
9+function drupal_clear_path_cache($path = NULL) {
10 drupal_lookup_path('wipe');
11+ $modules = module_implements('lookup_path');
12+ if (!empty($modules)) {
13+ $module = reset($modules);
14+ module_invoke($module, 'path_alias_whitelist_rebuild', $path);
15+ }
16 }
17
18 /*
19
20=== modified file 'modules/path/path.module'
21--- modules/path/path.module 2011-05-26 02:56:05 +0000
22+++ modules/path/path.module 2011-07-01 04:46:30 +0000
23@@ -120,7 +120,7 @@
24 db_query("DELETE FROM {url_alias} WHERE src = '%s'", $path);
25 }
26 }
27- drupal_clear_path_cache();
28+ drupal_clear_path_cache($path);
29 }
30
31
32
33=== modified file 'modules/path_alias_cache/path_alias_cache.module'
34--- modules/path_alias_cache/path_alias_cache.module 2010-10-22 15:37:23 +0000
35+++ modules/path_alias_cache/path_alias_cache.module 2011-07-01 04:46:30 +0000
36@@ -1,15 +1,6 @@
37 <?php
38
39 /**
40- * Implementation of hook_flush_caches().
41- *
42- * @return array
43- */
44-function path_alias_cache_flush_caches() {
45- return array('cache_path');
46-}
47-
48-/**
49 * Implementation of hook_lookup_path
50 *
51 * This version of lookup_path is almost exactly what is in core, but adds a cache table.
52@@ -28,18 +19,17 @@
53
54 // Retrieve the path alias whitelist.
55 if (!isset($cache['whitelist'])) {
56- if ($cached = cache_get('path_alias_whitelist', 'cache_path')) {
57- $cache['whitelist'] = $cached->data;
58- } else {
59- $cache['whitelist'] = path_alias_cache_path_alias_whitelist_rebuild();
60+ $whitelist = variable_get('path_alias_whitelist', NULL);
61+ if (!isset($whitelist)) {
62+ $whitelist = path_alias_cache_path_alias_whitelist_rebuild();
63 }
64+ $cache['whitelist'] = $whitelist;
65 }
66
67 $path_language = $path_language ? $path_language : $language->language;
68
69 if ($action == 'wipe') {
70 $cache = array();
71- $cache['whitelist'] = path_alias_cache_path_alias_whitelist_rebuild();
72 }
73 elseif ($cache['whitelist'] && $path != '') {
74 if ($action == 'alias') {
75@@ -198,7 +188,14 @@
76 * @return
77 * An array containing a white list of path aliases.
78 */
79-function path_alias_cache_path_alias_whitelist_rebuild() {
80+function path_alias_cache_path_alias_whitelist_rebuild($path = NULL) {
81+ // Don't rebuild the path alias whitelist for already whitelisted paths.
82+ if (!empty($path) && $whitelist = variable_get('path_alias_whitelist', NULL)) {
83+ if (isset($whitelist[strtok($path, '/')])) {
84+ return TRUE;
85+ }
86+ }
87+
88 // For each alias in the database, get the top level component of the system
89 // path it corresponds to. This is the portion of the path before the first "/"
90 // if present, otherwise the whole path itself.
91@@ -207,7 +204,7 @@
92 while ($row = db_fetch_object($result)) {
93 $whitelist[$row->path] = TRUE;
94 }
95- cache_set('path_alias_whitelist', $whitelist, 'cache_path');
96+ variable_set('path_alias_whitelist', $whitelist);
97 return $whitelist;
98 }
99

Subscribers

People subscribed via source and target branches

to status/vote changes: