moinmoin takes 15 seconds to "Edit"

Hey guys,
yesterday I tried to solve a www/moinmoin misbehaviour.

Problem: Whenever I want to "Edit" a wiki-page it takes exactly 15 seconds until the Edit-view appears. Every other action in the wiki like viewing pages, logging in, etc. works instantaneously.

Tests:
1.) Problem appeared first under www/apache22 and I was neither able to locate the root cause nor fix it.
2.) Installed www/lighttpd to try if problem still exists. -> Yes

I will stay with lighttpd for some other reasons, so further configs etc. are specific for lighttpd.

As every click on "Edit" takes exactly 15 secs to get into the Edit-view I think it's some kind of error and timeout.
For lighttpd I switched all flags in /usr/local/etc/lighttpd/conf.d/debug.conf on, so I saw that lighttpd does apparently "nothing" (for 15 secs) between getting the HTTP-request and sending its answer (<-- only when switching to Edit-mode).
The funny thing here is: Even if I set the fcgi-idle-timeout to 2 secs every "Edit" takes 15 secs to start.

If I use the fast-cgi-script directly from lighttpd (will post configs later) it takes (roughly?) 15 seconds to get the first page served - even in View-mode.
If I use the www/spawn-fcgi via /etc/rc.conf to get the PHP/fast-cgi processes up and running beforehand, the first view gets served immediately.

So my assumption is: I have some problem with the configuration of (choose one or more): www/lighttpd, www/spawn-fcgi, www/moinmoin

Has someone out there a clue where I can "see" more what's going on there behind the scenes? As I am just beginning to learn about the spawn-fcgi usage.
Maybe I have totally ignored something obvious?

Thanks in advance
 
relevant parts of

rc.conf
Code:
lighttpd_enable="YES"
spawn_fcgi_enable="YES"
spawn_fcgi_flags="-s /usr/local/www/wiki/moin.sock -u 80 -g 80 -U 80 -G 80 -- /usr/local/www/wiki/moin.fcgi"

lighttpd-moin.conf
Code:
# redirect / to wiki
url.rewrite = ( "^/$" => "/wiki/" )

# for static files
alias.url += ( "/moin_static" => "/usr/local/www/wiki/" )

# fast_cgi part
fastcgi.server = (  "/wiki" =>
  (( "docroot"   => "/",
     "min-procs" => 1,
     "max-procs" => 1,
     # attach to socket from spawn-fcgi (rc.conf)
     "socket"     => "/usr/local/www/wiki/moin.sock",
     "idle-timeout" => 2,
     "check-local" => "disable",
     "broken-scriptfilename" => "enable",
  ))
)


/tmp/moin.log with logging setting to "DEBUG"
Code:
DEBUG 2013-02-18 21:30:08,229 MoinMoin.i18n:324 falling back to english, requested string not in 'de' 
                              translation: 'SlideShow'
DEBUG 2013-02-18 21:30:08,328 MoinMoin.web.session:185 finalize userobj = <MoinMoin.user.User at 0x809967ab8 name:'' 
                              valid:0>, setuid = None
DEBUG 2013-02-18 21:30:10,069 MoinMoin.wsgiapp:240 client accepts language 'de-DE', weight 1
DEBUG 2013-02-18 21:30:10,070 MoinMoin.wsgiapp:240 client accepts language 'de', weight 0.8
DEBUG 2013-02-18 21:30:10,071 MoinMoin.wsgiapp:242 moin supports language 'de'
DEBUG 2013-02-18 21:30:10,071 MoinMoin.wsgiapp:254 setup_i18n_preauth returns 'de'
DEBUG 2013-02-18 21:30:10,072 MoinMoin.web.session:151 get_session for sid None
DEBUG 2013-02-18 21:30:10,073 MoinMoin.web.session:166 get_session returns session <MoinSession {}>
DEBUG 2013-02-18 21:30:10,073 MoinMoin.auth:480 session started for user None
DEBUG 2013-02-18 21:30:10,074 MoinMoin.auth:465 setup_suid returns None, None
DEBUG 2013-02-18 21:30:10,075 MoinMoin.wsgiapp:264 either no valid user or no specific language configured in user profile, 
                              using lang setup by setup_i18n_preauth
DEBUG 2013-02-18 21:30:10,076 MoinMoin.wsgiapp:266 setup_i18n_postauth returns 'de'
>15 secs later - nothing logs/happens here ...>
DEBUG 2013-02-18 21:30:25,108 MoinMoin.i18n:324 falling back to english, requested string not in 'de' translation: u'StartSeite'
DEBUG 2013-02-18 21:30:25,119 MoinMoin.i18n:324 falling back to english, requested string not in 'de' translation: 'SiteNavigation'
DEBUG 2013-02-18 21:30:25,138 MoinMoin.i18n:324 falling back to english, requested string not in 'de' translation: u'StartSeite'
DEBUG 2013-02-18 21:30:25,200 MoinMoin.web.session:185 finalize userobj = <MoinMoin.user.User at 0x809938e60 name:'' valid:0>, 
                              setuid = None

So seems to be something with the locale settings or so.
Will investigate further. Tending to ask the moinmoin-guys.
 
missed some maintenance commands the last releases (from: http://moinmo.in/HelpOnMoinCommand):

Clean Page caches
# moin --config-dir=/usr/local/www/wiki --wiki-url=http://www.gq.lan/wiki maint cleancache

Migrate Pages to newer version
# moin --config-dir=/usr/local/www/wiki --wiki-url=http://www.gq.lan/wiki migration data
(proceeded without errors, bringing my wiki-pages to current version)


Rebuilt the config files from /usr/share/moin/config/wikiconfig.py and /usr/share/moin/server/moin.fcgi.

Always restarting with:
# pkill -f moin.fcgi && sleep 3 ; /usr/local/etc/rc.d/spawn-fcgi start && /usr/local/etc/rc.d/lighttpd restart
to get a clean restart
 
Have been on #moin (IRC) for about two hours now. No solution found ... yet.
Even tried going back to apache22 with wsgi - no change :(
 
After digging into the Python code I narrowed the error down to:
/usr/local/lib/python2.7/site-packages/MoinMoin/logfile/editlog.py

When switching to "Edit"-mode it goes into the Class "EditLog" -> function "add" and drops out there at:
Code:
hostname = socket.gethostbyaddr(host)[0]
raising a socket.error

"host" in this case is a string with the IP-address of the coneecting client.

Funny thing is: If I execute the statements manually in a Python shell, everything works fine.
 
As the moinmoin-wiki is running in an ezjail, maybe it's a problem with access rights for the user "www" to use "socket.gethostbyaddr"?
Because the Python documentation for socket has a note
Changed in version 2.6: socket.error is now a child class of IOError.

Code:
WARNING 2013-02-21 13:26:45,531 MoinMoin.PageEditor:1316 >>> editlog.Editlog - start
WARNING 2013-02-21 13:26:45,531 MoinMoin.logfile.editlog:177 >>> EditLog.add: host: None
WARNING 2013-02-21 13:26:45,532 MoinMoin.logfile.editlog:179 >>> EditLog.add: host: 192.168.0.18
WARNING 2013-02-21 13:26:45,532 MoinMoin.logfile.editlog:182 >>> EditLog.add: log_reverse_dns_lookup
WARNING 2013-02-21 13:26:45,532 MoinMoin.logfile.editlog:184 >>> EditLog.add: config.charset: utf-8
WARNING 2013-02-21 13:26:45,533 MoinMoin.logfile.editlog:185 >>> type(192.168.0.18) <type 'str'>
WARNING 2013-02-21 13:27:00,537 MoinMoin.logfile.editlog:196 >>> EditLog.add: socket.err hostname: 192.168.0.18
WARNING 2013-02-21 13:27:00,540 MoinMoin.logfile.editlog:197 >>> I/O error(2): Host name lookup failure
WARNING 2013-02-21 13:27:00,542 MoinMoin.logfile.editlog:198 >>> Unexpected error: <class 'socket.herror'>
WARNING 2013-02-21 13:27:00,544 MoinMoin.logfile.editlog:210 >>> EditLog.add: hostname after unicode: 192.168.0.18
WARNING 2013-02-21 13:27:00,546 MoinMoin.logfile.editlog:219 >>> EditLog.add: comment = wikiutil.clean_input BEFORE
WARNING 2013-02-21 13:27:00,548 MoinMoin.logfile.editlog:221 >>> EditLog.add: comment = wikiutil.clean_input AFTER
WARNING 2013-02-21 13:27:00,553 MoinMoin.PageEditor:1320 >>> editlog.Editlog - stop

- Warning-level is set by me
- ">>>" denotes logging.warnings inserted by me
- linenumbers do no longer match the original file-linenumbers as I inserted lots of debug/logging-messages ;)
 
insert the following settings into your [moinmoin-instance]/wikiconfig:

(within the Class Config-block, so keep the leading spaces)
Code:
    force_ip = True
    log_reverse_dns_lookups = False

This avoids using reverse DNS lookups,so just plain IP-addresses are logged in the edit-logs.

Attention:
# dig -x 192.168.0.18 works without problems and latencies.

The same for interactive Python session (as root):
Code:
import socket
host = socket.gethostbyaddr('192.168.0.18')[0]
Without problems or latency, too.

So IMHO I think it has something to do with the unprivileged "www" user within the jails being unable to use the resolver-functions.

Btw: It is not the raw_sockets-option for the jails. I allowed with raw_sockets for the jail with
# sysctl security.jail.allow_raw_sockets=1
and restarted the jail - NO change.

Does this sound reasonable?
 
activated a shell for user "www".
# dig -x 192.168.0.18
fails with timeout, couldn't read /etc/resolv.conf.

# chmod 0644 /etc/resolv.conf
resolved the "dig" as well as the "log_reverse_dns_lookups" (above).

So now: Double fixed.
Thanks, kpa
 
Back
Top