Closed (fixed)
Project:
Mobile Tools
Version:
6.x-1.x-dev
Component:
Code
Priority:
Critical
Category:
Bug report
Assigned:
Reporter:
Created:
3 Dec 2009 at 23:01 UTC
Updated:
14 Oct 2011 at 20:54 UTC
Jump to comment: Most recent file
We recently installed mobile_tools on a relatively high traffic site and noticed that the variables cache started being re-written to the database almost constantly. Our site has a lot of modules installed, so the associated database writes quickly became a resource issue. We tracked the issue down to the mobile_tools_boot function. By commenting out the two variable set calls, we drastically reduced database writes:
if ($_SESSION['mobile-tools-site-type'] == 'mobile' || $theme_switched) {
// variable_set('default_main_nodes', variable_get('default_nodes_main_mobile', 5));
}
else {
// variable_set('default_main_nodes', variable_get('default_nodes_main_original', 10));
}
Those variables don't get used on our site, so the fix above worked for us. However, I wanted to open an issue since it could affect others. We can probably come up with a patch, but I wanted to go ahead mention the issue first.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | mobile_tools-variable-cache.patch | 2.2 KB | john morahan |
Comments
Comment #1
twom commentedHi,
Performance is an issue with theme switching in Drupal. However, I don't see immediate why commenting out these to variables reduces the database rewrites... If you can help me out with this, I can optimize the module.
Further, as you will see in the module, I do something stupid, being clearing the cache at almost each page request.
The only two ways to resolve this is:
- to write a different cache mechanism (should not be too hard)
- redirect each page request to the same url, but with a new argument e.g. ?mobile=true, this way the mobile page is being cached
Performance clearly need some thought! :)
Comment #2
twom commentedbtw, the module seems to clear the cache in the hook_boot: cache_clear_all(NULL, 'cache_page', TRUE);
This has to change!!!
Comment #3
john morahan commentedThis only tackles the variables not the page cache
Comment #4
twom commentedPart of the issue has been fixed in a previous release: the cache is not cleared for every page request.
I removed also the setting of the variables in the boot method.
This is open for testing :)
Tom
Comment #5
twom commentedComment #6
domesticat commentedI'm upgrading this to critical while I test this patch. 6.x-1.12 stable, with this bug, can fill a mysqlbinlog in under a half an hour on a not-busy personal site. I shudder to think of what it could do to a truly busy site. On my site it was continually writing and trashing over 70K of mysql query data for every single page load.
I need about a day to test this issue -- my mysqlbinlog is still a bit artificially inflated because the cache is still rebuilding -- but if this indeed fixes the issue, I would urge you in the strongest possible terms to roll this into a stable release ASAP.
Comment #7
twom commentedHi,
Thank you for helping out and testing. Let me know what your findings are.
I'll create a stable release when your findings are ok.
Thanks,
Tom
Comment #8
domesticat commentedI'm only able to do limited testing (I only have one mobile device to test with) but the binlogs aren't whirling out of control and performance has improved. I'm marking this RTBC so we can get it into a stable release ASAP.
Comment #9
kiphaas7 commented#1: You could always look at the source code of the Domain module (more specifically the Domain Theme module) how they handle switching...
Comment #10
domesticat commentedNudging this issue again. The fix is working, at least on our end, and some sort of fix REALLY needs to be rolled into the stable release, ASAP.
Comment #11
twom commentedI did some updates on the dev version to change the way caching is handled if theme switching is being used.
I added the mobile_tools_cache.inc file that overwrites the default caching in order to support theme switching. No cache clears are being used anymore in the module...
However if you are using a non-default caching mechanism, you should have a look at the mobile_tools_cache.inc file to learn how to work with caching.
Feedback appreciated!
PS: the dev should be rather stable.
Comment #12
domesticat commented@twom - If the dev is stable, please release it as a new stable version. Some users will not or cannot use -dev versions on their site per contract terms, and won't upgrade to a dev version. A new stable version is appropriate in this case.
Comment #13
minoroffense commentedI'm going to close this since I'm assuming it's been committed already. Please reopen if necessary.