There have been customers facing cyclic redirection of Virtual URI mappings such as HELPDESK-880 in which an infinite loop of redirects happen. A large amount of logs printed out. Most of CPU was allocated to these infinite loops. This cause running Magnolia instance crashes. Also we're lacking of tools to support this kind of human error.
Detect any new registering of Virtual URI mapping that might causing an infinite loop.
Because Virtual URI mapping could be configured by Regular expressions, we can't assert all input URLs, this proposed algorithm is not a 100% accuracy solution. Any improvement or alternative strategies are welcome.
> AKA: User Stories
> List concrete ways in which this feature will be used.
- Customer create and register a new Virtual URI mapping.
- System check for the cyclic referencing if any from the newly created one.
- If there was no issue, a new entry added to VirtualUriRegistry. Otherwise a new problem reported both to log and in Definitions app as a major problem.
> AKA: Design
> What is the overall approach to solve the problem. First summarize the high level overview in a few lines.
What we are having
Currently we are having a VirtualUriRegistry which could be imagine as list of mappings. Each mapping has only fromUri and toUri are the 2 major properties. A function "mapUri" from the VirtualUriMapping using an input uri and produce an output of toUri with its matching score.
How can we do the cyclic detection
Once a new mapping created and registered, we will do following checking:
- For whatever input that matched its fromUri, a unique toUri is produced. System will redirect / forward user to the new location.
- Cyclic redirection happen when the new location or the next nth new location reference back to its precedent one.
- Note that the backward referencing not necessary to be the original one, it could be any one along the redirection line. However if we supposed that we implemented this algorithm, then there were no cyclic referencing within our existing virtual URI mapping entries. The backward referencing could only go back to current one (the 1st checking URI which is the "toURI" of current config).
- Starting from new configured toUri and having a Set of traversed virtual URI mapping entries (non-loop-set).
- While still able to find the next mapped URI:
- Check if the next mapped URI exists in the non-loop-set. If yes then it's a cyclic one. Stop the finding here and reject the registration.
- Add the toUri to the set.
- Use the next mapped URI as the toUri
- Continue finding
- Stop finding if we can't find any new matched. Allow the newly created virtual URI mapping to be registered.
Discussion, Suggestions, Q&A
Feel free to comment or edit the page for any improvement.
> Possible Improvements
> Discarded Proposals