Add a patch tag
[ikiwiki.git] / doc / bugs / ikiwiki_overzealously_honours_locks_when_asked_for_forms.mdwn
1 When an `ikiwiki` instance is holding a lock, a web user clicking on "add comment" (for example) will have to wait for the lock to be released.  However, all they are then presented with is a web form.  Perhaps CGI requests that are read-only (such as generating a comment form, or perhaps certain types of edits) should ignore locks? Of course, I'd understand that the submission would need to wait for a lock. — [[Jon]]
2
3 > Ikiwiki has what I think of as the Big Wiki Lock (remembering the "Big
4 > Kernel Lock"). It takes the exclusive lock before loading any state,
5 > to ensure that any changes to that state are made safely.
6
7 > A few CGI actions that don't need that info loaded do avoid taking the
8 > lock.
9
10 > In the case of showing the comment form, the comments
11 > plugin needs CGI session information to be loaded, so it can check if
12 > the user is logged in, and so it can add XSRF prevention tokens based on
13 > the session ID. (Actually, it might be possible to rely on
14 > `CGI::Session`'s own locking of the sessions file, and have a hook that
15 > runs with a session but before the indexdb is loaded.)
16
17 > But, the comment form also needs to load the indexdb, in order to call
18 > `check_canedit`, which matches a pagespec, which can need to look things
19 > up in the indexdb. (Though the pagespecs that can do that are unlikely
20 > to be relevant when posting a comment.)
21
22 > I've thought about trying to get rid of the Big Wiki Lock from time to
23 > time. It's difficult though; if two ikiwikis are both making changes
24 > to the stored state, it's hard to see a way to reconcile them. (There
25 > could be a daemon that all changes are fed thru using a protocol, but
26 > that's really complicated, and it'd almost be better to have a single
27 > daemon that just runs ikiwiki; a major architectural change.)
28
29 > One way that *almost* seems it could work is to have a entry path
30 > that loads everything read-only, without a lock. And then in read-only
31 > mode, `saveindex` would be an error to run. However, both the commenting
32 > code and the page edit code currently have the same entry path for
33 > drawing the form as is used for handling the posted form, so they would
34 > need to be adapted to separate that into two code paths. --[[Joey]]