Problem/Motivation
The redirect module uses the flood system to detect loops:
if (flood_is_allowed('redirection', 5, 15, $session_id ? $session_id : NULL)) {
flood_register_event('redirection', 60, $session_id ? $session_id : NULL);
}
This causes two problems:
- Because anonymous sessions are "lazy", $session_id is almost never committed to the session table, nor is a cookie actually sent. The result is that $session_id is different for each subsequent request, so the loop detection doesn't work. Also, the {flood} table fills with non-existent session records.
- The threshold is set to 5 redirects every 15 seconds. A crawler or fast mouse operator (think tabs) can easily exceed this limit. When the limit is exceeded, the result is usually a 404 instead of the requested page.
Proposed resolution
Remove the loop detection. It doesn't work and anyway, it's the client's job.
It's technologically impossible to track redirects using session cookies in a way that's free of race conditions. HTTP just doesn't provide a facility to track state within a redirect chain.
Remaining tasks
patch needs review
User interface changes
none
API changes
none
Comments
Comment #1
Mark Theunissen commentedI agree, we triggered this just in general testing. The browser can handle it.
Patch attached to remove this.
Comment #2
Mark Theunissen commentedComment #3
Mark Theunissen commentedBump! Any chance this could get into the next beta?
Comment #4
mfbThis is also seriously inefficient for high-traffic sites - bootstrapping drupal and doing a database lookup is bad enough for handling redirects, we should definitely avoid database writes.
Comment #5
a.ross commentedAfter the update to RC1, we're getting the message about infinite loop on every page. Could this expose another underlying bug? If not, I think it's time for this patch to be committed.
Edit: the error occurred only on pages with redirects, removing and re-adding the redirects fixes the notice.
Comment #6
philbar commentedI am also receiving the infinite loop error. Reverting back to redirect 7.x-1.0-beta4
Comment #7
dlumberg commentedAlso getting this error on lots of pages after update to rc-1
Comment #8
hass commentedComment #9
hass commentedThere may be another underlying issue that has caused this issue. I guess it's the auto path that is added on updates.
For me it was a taxonomy term (
taxonomy/term/52) with current aliastag/foothat also had a redirection fromtag/foototaxonomy/term/52defined. The redirect module need to make sure that this is not possible and delete redirections aliases that point to the same url like the current alias.BUG: This means redirection module redirects from
tag/foototag/foo. A clear FAIL.Workaround: Manual delete colliding aliases from redirects list at
admin/config/search/redirect/list.Comment #10
hass commentedComment #11
hass commentedFor the next release we also need an update hook to delete all the overriding redirects that will cause endless loops and bring the site down.
Comment #12
hass commentedIn http://api.drupal.org/api/drupal/includes%21path.inc/function/path_save/7 we can catch all alias changes with http://api.drupal.org/api/drupal/modules%21path%21path.api.php/function/... and delete the alias from the redirect table.
Comment #13
hass commentedI would also suggest to remove these logic as the input/duplicate need to be blocked somewhat earlier or at least change to class error:
Comment #14
hass commentedFound a node that had the current alias also as redirect to itself defined. This node was NOT listed in the redirect list as warning.
Comment #15
hass commentedMarked #1793230: Infinite loops as duplicate
Comment #16
SeeWatson commentedI'm getting this error after updating to RC1: "The webpage at webpage.com has resulted in too many redirects. Clearing your cookies for this site or allowing third-party cookies may fix the problem. If not, it is possibly a server configuration issue and not a problem with your computer."
This has happened due to the automatic redirect creation. On some pages, we changed the URL, and then changed it back. Therefore, it has a redirect that is pointing it to itself. Is there any way to check for this and delete/ignore the redirect? We have this on 100+ pages, so it's not workable to remove them manually.
Comment #17
pjcdawkins commentedMarked #1796596: Fix and prevent circular redirects as duplicate.
Comment #18
paulmckibbenUpgrading to rc1 has caused infinite loops for me as well. Is there a patch for this issue?
Comment #19
paulmckibbenThe following mysql command seemed to fix the infinite loop issues for me, without breaking any URL aliases.
Comment #20
hass commentedMarked #1799430: Too Many Redirects 310 Error when alias and redirect is same as duplicate.
Comment #21
hass commentedDisabled Automatically create redirects when URL aliases are changed for now as several node revision updates cause loops. Editors don't understand this.
Comment #22
eule commentedhi,
i get the same problem..i use rc1 ...so if i try to visit my blog post under ./blogs/anyuser i get the msg
Oops, looks like this request tried to create an infinite loop. We do not allow such things here. We are a professional website!
i mean this is a standart drupal path and has nothing to do with any redirection
Comment #23
hass commentedWe should change the message to "This is a malfunctioning and untested module. Don't use me if you have a professional site!" *G*
Comment #24
grendzy commentedThe post in #18 that set "needs work" wasn't reviewing the patch. I think the patch in #1 is the correct fix for the session / flood problem.
Checking for loops in the database could be a follow-up patch.
Comment #25
hass commentedThe flood detection makes sense, but it's just an error that pop's up that should never happen and the underlying issue is that there are duplicate redirects created for existing aliases. So if this would work properly, there is no need to remove the flood detection. Setting CNW to get this critical bug fixed.
Comment #26
dave reidHass, then can you please file a new and separate issue, rather than continuing to derail what this issue was about?
Comment #27
hass commentedThere is a lot of details in this case and 3 duplicates linking to this case. No.
Comment #28
mfbI don't see much rationale for flood / loop detection but *if* it is somehow determined that it's useful then it needs to be made optional, for reasons of performance on high-traffic sites specified in #4
Comment #29
dave reidRe-opened #1796596: Fix and prevent circular redirects as it is not a duplicate of this issue. I found it also terribly difficult to perform a copy-paste so that the details from this issue were also available in the other issue.
</sarcasm>Comment #30
eule commentedsry ..but i love hass big mouth ...he does not know that he is not always right
Comment #31
hass commented@dave: try this copy paste with an iphone. Let me know when you completed this. *sarcasm*
@eule: i do not see anything in this case from #2+ where I'm wrong.
Comment #32
eric_a commentedAnyone care to review the approach and patch in #3 at #1796596: Fix and prevent circular redirects?
Comment #33
grendzy commentedI think it's impossible to track redirects using session cookies in a way that's free of race conditions. HTTP just doesn't provide a facility to track state within a redirect chain. Because of this, removing the flood system seems preferable to trying to improve it or make it optional.
Comment #34
roborracle commentedFor what it's worth, I can say that I applied the patch in #1 and it removed my loop errors.
Comment #35
JGO commentedSomething is defintatly wrong with this module atm! I had this error: 'Oops, looks like this request tried to create an infinite loop. We do not allow such things here. We are a professional website!'.
I hoped fixing it by applying the patch, but after applying the patch I got a browser error too many redirects, so it was right! Afterwards I disabled the redirect module and all works fine now.
Conclusion: current module is certainly flawed. BTW I used 7.x-1.0-rc1 together with this patch.
Comment #36
eric_a commented@JGO: Try the latest patch in #1796596: Fix and prevent circular redirects. It aims to prevent a direct redirect to self, which I guess accounts for the majority of looping issues.
Comment #37
marcoka commentedits interesting. loop detecting is triggered here if i do
site/foo node/2
foo node/2
i do not see no loop :) have updated the whole drupal+all contribs to latest versions
Comment #38
ewenss commentedCan we please make this module UNAVAILABLE or CARRY A BIG WARNING IN RED at its download page?
Since my infinite loop occurred at my home page (mydomain.com) and I don't have shell access to run MYSQL commands, it looks like I have no other option but to nuke my entire Drupal installation and start from scratch recreating my pages - 100 hours of work, right down the crapper.
Or is there some other way I can fix this?
Comment #39
damien_vancouver commented@ewenss,
Download phpMyAdmin and then upload its files to a subfolder of your Drupal installation on the server (e.g. a folder called "phpmyadmin" right below index.php would work). Then you should be able to connect to http://yoursite.example.com/phpmyadmin/index.php and you will be presented with a MySQL login page.
Enter the username and password for your MySQL database connection that's found in your settings.php file (sites/default/settings.php, or sites/mysite.example.com/settings.php) and that should let you into your database so you can delete the offending duplicate rows.
(one way if you are not using multiple languages is to run the query from #19 using the "SQL" tab).
You can back up your database before you start using the "Export" tab. There's lots of good online phpmyadmin tutorials. Or if you get stuck you can send me a private message through Drupal.org and I'll give you a few more hints. Don't throw that 100 hours of work away!
Comment #40
eric_a commentedOr just go straight to your modules page and disable Redirect.
@ewenss, please don't post the same request in multiple related issues.
And let's keep code issues code issues and support forums support forums.
Comment #41
rooby commented+1 for fixing the underlying problem and not masking it with this message.
If this message must remain, it should be an error message, not a status message. End users should not be seeing strange error messages that provide them no value.
@ewenss:
If you are running a drupal site where you have no database access at all, you have bigger issues than the redirect module.
Comment #42
rooby commentedMarked #1841432: Improve error and log messages when redirect loop detection triggered as a duplicate of this.
Comment #43
damien_vancouver commentedAlso marked #1817976: Updating an entity with an URL alias that matches an existing redirect causes bad data and circular redirect as a duplicate of this. Below is some of the discussion from there that is relevant to how to do loop/flood detection and reporting:
#4
Posted by Eric_A on November 8, 2012 at 8:38pm
With new entities come new aliases. Existing entities have their aliases changed often enough when editors can't make up their mind. Content language changes at times and thus the alias.
I don't think it makes sense to boldly delete a redirect entity every time there's a (temporary) conflict. We just need to make sure to not proceed with the redirect at a moment in time when it clearly makes no sense.
(One of the challenges with the current system is that node redirects do not simply redirect to a hard coded node path. It redirects to whatever the currently active alias may be.)
#5
Posted by Eric_A on November 8, 2012 at 8:48pm
And another note on the proposed query. The options part should be taken into account as well. Those columns are serialized arrays, though. So I'm not a 100% convinced you will always catch them all. Only processing in PHP will.
#6
Posted by azinck on December 7, 2012 at 9:10pm
There are a number of ways collisions between aliases and redirects like this can occur. I'm not sure there's a blanket set of logic that we can apply for resolving such collisions and since the path-related hooks (like hook_path_update) are often the only reliable place to detect the collisions that's too late to give a user a chance to make a decision on how to resolve the problem.
What if, instead, we were to build a report to show alias and redirect collisions? We might also give provide some tools there for cleaning up the collisions. To build such a report we need to think through exactly what entails a collision. I started thinking that through but my head began to hurt so I'll leave it for another day :).
#7
Posted by azinck on December 7, 2012 at 10:09pm
A closely related discussion: #1288768: Conflict between an old redirect (with Redirect module) and a new automatic alias (with Pathauto).
#8
Posted by matglas86 on December 10, 2012 at 7:38pm
@azinck thats a good idea. Even if its just to get our head around the different ways collisions can happen. We can work out the different situations and test we could build to try and fix it.
Comment #44
charles belovThe issue here is that this situation has occurred for me just renaming a page's title. Staff needs to know that if this happens, the webmaster needs to take corrective action. I suggest this be kept but the error message be made more informative, e.g., report the page address to the webmaster.
Comment #44.0
charles belovupdate remaining tasks
Comment #45
scott.allison commentedI've created the following patch that will at least correctly identify the error as such, and provide some more helpful information
Comment #46
yannickooIt would be cool if the watchdog entry also contains the source and destination information.
Comment #47
grendzy commentedI appreciate everyones feedback and patches, and I definitely understand wanting to improve the flippant error message. I do strongly believe the session-based approach is inherently unfixable, due to the stateless nature of HTTP (as described in the issue summary).
I'd also like to clarify the RTBC status was set in response to the patch in #1.
Comment #48
grendzy commented#1: redirect_remove_flood-1263832-1.patch queued for re-testing.
Comment #49
a.ross commentedI have to agree with that. The only loop detection the module should do is to prevent broken aliases being made in the first place. It would make more sense to have all the redirects of an entity pointing to the main URL and update them all when the main URL changes. Then just remove the redirect of which the source URL equals the entity's new main URL (if it exists).
Comment #50
hass commentedDave asked for critical issues in the queue. Setting priority.
Comment #51
dave reidI never *asked* for critical issues hass, so do not put words in my mouth EVER.
Comment #52
hass commentedIf the module is broken we name this critical.
Comment #54
blazindrop commentedWe experienced the same issue and the message:
was showing up on our public facing pages because we had some circular references between aliases and redirects. I know this was a site building issue but the fact this message shows to public users is unprofessional in itself; it's not the users fault that happened.
I had to run a query like the one in #19 but if you redirect camel-case URLs (e.g. /Products -> /products) that query may not work if you use a case-insensitive MySQL collation (which is default). You must do a string sensitive comparison in that case forcing one of your comparison operands to a case-sensitive collation:
delete r from redirect r inner join url_alias u on u.source = r.redirect and r.source = u.alias collate utf8_binComment #55
fenstrat#1796596: Fix and prevent circular redirects has a working patch (it handles existing aliases, and also includes tests), so marking this one as duplicate.
Comment #56
mfbOk, I created #2119157: Improve performance on high-traffic sites by making database writes optional for making flood detection optional.
Comment #56.0
mfbclarify race problem
Comment #57
Sneakyvv commentedThe patch from #1 didn't apply. That's why it failed testing.
This patch has correct line numbers and has been created using latest dev version which this issue is pointing to.
Comment #58
Sneakyvv commentedfenstrat, I'm reopening this issue since #1796596: Fix and prevent circular redirects is addressing the issue by trying to prevent circular references.
This issue is about discussing the removal of a mechanism that isn't foolproof. In other words grendzy has a valid point by saying "it's the client's job".
Also triggering the test bot for the previous patch in #57.
Comment #59
fenstrat@Sneakyvv isn't this what is being achieved in #2119157: Improve performance on high-traffic sites by making database writes optional?
Comment #60
mfbI submitted #2119157: Improve performance on high-traffic sites by making database writes optional because I was starting to give up hope that this "feature" would be removed, not because I think it should stay.
The arguments above seem pretty clear, for example, Drupal 7 has lazy sessions, so HTTP clients don't have the session cookie that would be required to make the redirect loop detection even work in the first place. If the client is logged in then there is a session cookie, but it's still pointless because browsers have their own built-in capability to detect redirect loops.
Comment #61
fenstratOk having re-read this issue from the top I'm convinced. While I'm far from the authority on this I'm going to go out on a limb and mark this as RTBC.
Prevention of loops is covered by #1796596: Fix and prevent circular redirects. Removing session based detection is covered here.
Comment #62
hefox commentedJust adding a version to use with stable.
Agree with issue; got a page with 404ing images and keep getting this message (404ing images will be handled separately, but don't want the user seeing the message, etc.)
Comment #63
dave reidCommitted #57 to 7.x-1.x. Thank you everyone for your help here.