Description
Once Xapian search has been enabled for the wiki updating a page results into IIS throwing an unhandled exception.
Steps to reproduce
run a MoinMoin wiki instance within a win32 environment using the IIS 7.5 webserver and the isapi_wsgi handler (more infos regarding the setup can be found here)
- install the Xapian python bindings for the win32 platform
- enable the Xapian index based search for the wiki
Component selection
unhandled excpetion is thrown within the _indexingRequest() method of the MoinMoin\search\builtin.py module.
1 def _indexingRequest(self, request): 2 """ Return a new request that can be used for index building. 3 4 This request uses a security policy that lets the current user 5 read any page. Without this policy some pages will not render, 6 which will create broken pagelinks index. 7 8 @param request: current request 9 """ 10 import copy 11 from MoinMoin.security import Permissions 12 from MoinMoin.logfile import editlog 13 14 class SecurityPolicy(Permissions): 15 16 def read(self, *args, **kw): 17 return True 18 #winpdb breakpoint for debugging purposes 19 import rpdb2 20 rpdb2.start_embedded_debugger("""...Removed-password-from-output...""") 21 r = copy.copy(request) #<-- IIS exception is caused
Details
It is possible to update the index entries of a wiki page by using a standalone commandline (script).
Yet despite the script succeeds the STDOUT of the script contains the following messages reporting that a runtime error has occured:
Exception RuntimeError: 'maximum recursion depth exceeded while calling a Python object' in <type 'exceptions.AttributeError'> ignored Exception RuntimeError: 'maximum recursion depth exceeded while calling a Python object' in <type 'exceptions.AttributeError'> ignored
The mentioned error messages do not seem to be a real exception as the script successfully finishes and updates Xapian index for the given page without having to catch the exceptions. Furthermore adding exception handling to the script does not catch the messages they are still printed to STDOUT of the script.
As the wiki is hosted as a ISAPI application within IIS the following isapi_wsgi handler is used.
I also tried to wrap the MoinMoin wsgi application with an additional Exception handler ( as described here http://lucumr.pocoo.org/2007/5/21/getting-started-with-wsgi ) because I wanted to prevent any exception being propagated to ISS. But the IIS exception still occurs. Maybe preventing the exception message being propagated to IIS was not possible for the same reasons it is not possible to suppress the messages to STDOUT within the commandline script?
MoinMoin Version |
1.9.3 |
OS and Version |
Windows 7 32bit |
Python Version |
2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)] |
Server Setup |
IIS 7.5 |
Server Details |
MoinMoin is running as wsgi application using the isapi_wsgi_0.4.2 handler package; Xapian bindings version 1.2.8 |
Language you are using the wiki in (set in the browser/UserPreferences) |
language_default = 'en' taken from the wikiconfig.py |
Workaround
- apart from disabling the Xapian based search no workaround is possible.
Discussion
I had a similary error under apache2 with mod_wsgi
[error] Exception RuntimeError: 'maximum recursion depth exceeded while calling a Python object' in <type 'exceptions.AttributeError'> ignored
- Problem
Now the problem is that when checking for an exception, we do exactly that: check whether the raised exception is a subclass of a given type. If the raised exception occurred just after a recursion overflow, it can happen that subclass checking overflows the recursion count again. However, since we don't want the newly raised exception (during exception subclass checking) to overwrite the original one, so we just write out it (using PyErr_WriteUnraisable, precisely) and then discard it. See here: http://bugs.python.org/issue5508
- Solution
- Ignore it
Linux
I added this changeset (http://hg.moinmo.in/moin/1.9/rev/5f5faedac588) and if I try to save a page now, I receive this error.
ERROR 2012-06-09 01:07:32,141 MoinMoin.wsgiapp:293 An exception has occurred [https://www.heavy.ch/rock/Lost%20and%20Found]. Traceback (most recent call last): File "/home/lotek/lib/python2.6/MoinMoin/wsgiapp.py", line 282, in __call__ response = run(context) File "/home/lotek/lib/python2.6/MoinMoin/wsgiapp.py", line 88, in run response = dispatch(request, context, action_name) File "/home/lotek/lib/python2.6/MoinMoin/wsgiapp.py", line 136, in dispatch response = handle_action(context, pagename, action_name) File "/home/lotek/lib/python2.6/MoinMoin/wsgiapp.py", line 195, in handle_action handler(context.page.page_name, context) File "/home/lotek/lib/python2.6/MoinMoin/action/edit.py", line 164, in execute savemsg = pg.saveText(savetext, rev, trivial=trivial, comment=comment) File "/home/lotek/lib/python2.6/MoinMoin/PageEditor.py", line 1148, in saveText results = events.send_event(e) File "/home/lotek/lib/python2.6/MoinMoin/events/__init__.py", line 257, in send_event retval = handle(event) File "/home/lotek/lib/python2.6/MoinMoin/events/xapian_index.py", line 77, in handle handle_changed(event) File "/home/lotek/lib/python2.6/MoinMoin/events/xapian_index.py", line 51, in handle_changed index.update_item(event.page.page_name) File "/home/lotek/lib/python2.6/MoinMoin/search/builtin.py", line 180, in update_item self.do_queued_updates() File "/home/lotek/lib/python2.6/MoinMoin/search/Xapian/indexing.py", line 216, in do_queued_updates self._index_page(request, connection, pagename, mode='update') File "/home/lotek/lib/python2.6/MoinMoin/search/Xapian/indexing.py", line 372, in _index_page updated = self._index_page_rev(request, connection, pagename, revno, mode=mode) File "/home/lotek/lib/python2.6/MoinMoin/search/Xapian/indexing.py", line 409, in _index_page_rev mimetype = 'text/%s' % page.pi['format'] # XXX improve this File "/home/lotek/lib/python2.6/MoinMoin/Page.py", line 252, in get_pi self.__pi = self.parse_processing_instructions() File "/home/lotek/lib/python2.6/MoinMoin/Page.py", line 961, in parse_processing_instructions request.setPragma(key, val) AttributeError: 'FakeRequest' object has no attribute 'setPragma'
the error is generated by my pragma stuff (in the wiki page itself):
#pragma keywords Hard, Rock, Magazin, Heavy, Metal, Schweiz, Glam, Hairmetal, HeavyMetal, Hardrock, Glamrock, Pop, PopMetal, Zeitschrift, Magazin, eZine, Newspaper, Information, Musik, Music, RockHeavy, Rock.Heavy.ch #pragma description Lost'n'Found - Das Heavy Metal Wiki und Online Rock Magazin unter Rock.Heavy.ch
after i removed those pragma, I could save the page.
Linux version 2.6.32-220.4.2.el6.x86_64 (mockbuild@c6b18n3.bsys.dev.centos.org) (gcc version 4.4.6 20110731 (Red Hat 4.4.6-3) (GCC) ) #1 SMP Tue Feb 14 04:00:16 GMT 2012
- Python 2.6
- Apache/2.2.17
- Mod_wsgi 3.2
bye -- MarcelHäfner 2012-06-09 08:04:59
Thanks for the feedback. Such stuff was somehow expected as (due to copy.copy not really working), we started with a rather empty FakeRequest object there. I'll have a look ASAP. -- ThomasWaldmann 2012-06-09 14:52:12
Thanks, it works now without any error message. -- MarcelHäfner 2012-06-09 16:03:10
RenamePage Fails
If I try to rename a page it fails with AttributeError: 'FakeRequest' object has no attribute 'parsePageLinks_running'. I use the latest rev and same configuration as obove (linux, mod-wsgi, python 2.6, etc.)
ERROR 2012-06-27 13:14:24,189 MoinMoin.wsgiapp:293 An exception has occurred [https://www.heavy.ch/lotek/MoinMoinWiki/Development1.7]. Traceback (most recent call last): File "/home/lotek/lib/python2.6/MoinMoin/wsgiapp.py", line 282, in __call__ response = run(context) File "/home/lotek/lib/python2.6/MoinMoin/wsgiapp.py", line 88, in run response = dispatch(request, context, action_name) File "/home/lotek/lib/python2.6/MoinMoin/wsgiapp.py", line 136, in dispatch response = handle_action(context, pagename, action_name) File "/home/lotek/lib/python2.6/MoinMoin/wsgiapp.py", line 195, in handle_action handler(context.page.page_name, context) File "/home/lotek/lib/python2.6/MoinMoin/action/RenamePage.py", line 183, in execute RenamePage(pagename, request).render() File "/home/lotek/lib/python2.6/MoinMoin/action/__init__.py", line 214, in render success, self.error = self.do_action() File "/home/lotek/lib/python2.6/MoinMoin/action/RenamePage.py", line 66, in do_action success, msgs = self.page.renamePage(newpagename, comment) File "/home/lotek/lib/python2.6/MoinMoin/PageEditor.py", line 652, in renamePage send_event(event) File "/home/lotek/lib/python2.6/MoinMoin/events/__init__.py", line 257, in send_event retval = handle(event) File "/home/lotek/lib/python2.6/MoinMoin/events/xapian_index.py", line 73, in handle handle_renamed(event) File "/home/lotek/lib/python2.6/MoinMoin/events/xapian_index.py", line 29, in handle_renamed index.update_item(event.page.page_name) File "/home/lotek/lib/python2.6/MoinMoin/search/builtin.py", line 180, in update_item self.do_queued_updates() File "/home/lotek/lib/python2.6/MoinMoin/search/Xapian/indexing.py", line 216, in do_queued_updates self._index_page(request, connection, pagename, mode='update') File "/home/lotek/lib/python2.6/MoinMoin/search/Xapian/indexing.py", line 372, in _index_page updated = self._index_page_rev(request, connection, pagename, revno, mode=mode) File "/home/lotek/lib/python2.6/MoinMoin/search/Xapian/indexing.py", line 425, in _index_page_rev multivalued_fields['linkto'] = page.getPageLinks(request) File "/home/lotek/lib/python2.6/MoinMoin/Page.py", line 1490, in getPageLinks links = self.parsePageLinks(request) File "/home/lotek/lib/python2.6/MoinMoin/Page.py", line 1513, in parsePageLinks if request.parsePageLinks_running.get(pagename, False): AttributeError: 'FakeRequest' object has no attribute 'parsePageLinks_running'
2012-07-05: AttributeError: 'FakeRequest' object has no attribute 'clock'
And still not working now "clock" attribut error.
ERROR 2012-07-05 18:53:28,508 MoinMoin.wsgiapp:293 An exception has occurred [ht tps://www.heavy.ch/rock/best]. Traceback (most recent call last): File "/home/lotek/lib/python2.6/MoinMoin/wsgiapp.py", line 282, in __call__ response = run(context) File "/home/lotek/lib/python2.6/MoinMoin/wsgiapp.py", line 88, in run response = dispatch(request, context, action_name) File "/home/lotek/lib/python2.6/MoinMoin/wsgiapp.py", line 136, in dispatch response = handle_action(context, pagename, action_name) File "/home/lotek/lib/python2.6/MoinMoin/wsgiapp.py", line 195, in handle_acti on handler(context.page.page_name, context) File "/home/lotek/lib/python2.6/MoinMoin/action/RenamePage.py", line 183, in e xecute RenamePage(pagename, request).render() File "/home/lotek/lib/python2.6/MoinMoin/action/__init__.py", line 214, in ren der success, self.error = self.do_action() File "/home/lotek/lib/python2.6/MoinMoin/action/RenamePage.py", line 66, in do _action success, msgs = self.page.renamePage(newpagename, comment) File "/home/lotek/lib/python2.6/MoinMoin/PageEditor.py", line 652, in renamePa ge send_event(event) File "/home/lotek/lib/python2.6/MoinMoin/events/__init__.py", line 257, in sen d_event retval = handle(event) File "/home/lotek/lib/python2.6/MoinMoin/events/xapian_index.py", line 73, in handle handle_renamed(event) File "/home/lotek/lib/python2.6/MoinMoin/events/xapian_index.py", line 29, in handle_renamed index.update_item(event.page.page_name) File "/home/lotek/lib/python2.6/MoinMoin/search/builtin.py", line 180, in upda te_item self.do_queued_updates() File "/home/lotek/lib/python2.6/MoinMoin/search/Xapian/indexing.py", line 216, in do_queued_updates self._index_page(request, connection, pagename, mode='update') File "/home/lotek/lib/python2.6/MoinMoin/search/Xapian/indexing.py", line 372, in _index_page updated = self._index_page_rev(request, connection, pagename, revno, mode=mo de) File "/home/lotek/lib/python2.6/MoinMoin/search/Xapian/indexing.py", line 425, in _index_page_rev multivalued_fields['linkto'] = page.getPageLinks(request) File "/home/lotek/lib/python2.6/MoinMoin/Page.py", line 1490, in getPageLinks links = self.parsePageLinks(request) File "/home/lotek/lib/python2.6/MoinMoin/Page.py", line 1521, in parsePageLink s request.clock.start('parsePageLinks') AttributeError: 'FakeRequest' object has no attribute 'clock'
See repo or please test fakerequest.diff.
Plan
- Priority:
- Assigned to:
- Status:
fixed by http://hg.moinmo.in/moin/1.9/rev/5f5faedac588 - needs more testing by xapian indexing users on all platforms
fixed setPragma/getPragma AttributeError: http://hg.moinmo.in/moin/1.9/rev/aaf543f558d9
fixed getPageLinks_running AttributeError: http://hg.moinmo.in/moin/1.9/rev/aba21f8db240
more fixes: http://hg.moinmo.in/moin/1.9/rev/9fd0e9e1b4a5 + refactored in http://hg.moinmo.in/moin/1.9/rev/fc11712e0df0