]> sipb.mit.edu Git - ikiwiki.git/blob - doc/bugs/git_mail_notification_race.mdwn
3538b0764736ac765672d79321a96dabdb0feb24
[ikiwiki.git] / doc / bugs / git_mail_notification_race.mdwn
1 I was suprised to receive two mails from ikiwiki about one web edit:
2
3          1   F Oct 30 To joey+ikiwiki update of ikiwiki's plugins/contrib/gallery.mdwn by http://arpitjain11.myopenid.com/
4          1   F Oct 30 To joey+ikiwiki update of ikiwiki's plugins/contrib/gallery.mdwn by http://arpitjain11.myopenid.com/
5
6 The first of these had the correct diff for the changes made by the web
7 edit (00259020061577316895370ee04cf00b634db98a).
8
9 But the second had a diff for modifications I made to ikiwiki code
10 around the same time (2a6e353c205a6c2c8b8e2eaf85fe9c585c1af0cd).
11
12 I'm now fairly sure a race is involved. Note that the name of the modified
13 page is correct, while the diff was not. The git rcs_commit code first
14 gets the list of modified page(s) and then gets the diff, and apparently my
15 other commit happened in the meantime, so HEAD changed.
16
17 Seems that the rcs_notify for git assumes that HEAD is the commit
18 that triggered the ikiwiki run, and that it won't change while the function is
19 running. Both assumptions are bad. Git does no locking and another commit
20 can come in at any time.
21
22 Notice that the equivilant code for subversion is careful to look at $REV.
23 git's post-update hook doesn't have an equivilant of $REV. Its post-receive hook
24 does, but I'm not sure if that's an appropriate hook for ikiwiki to be using
25 for this. Switching existing wikis to use a different hook would be tricky..
26
27 I've avoided part of the race; now the code does:
28
29 1. Get commit info for HEAD commit.
30 2. Extract file list from that.
31 3. Extract sha1 of commit from it too.
32 4. git diff sha1^ sha1
33
34 Still seems like there can be a race if another commit comes in before step #1.
35 In this case, two post-receive hooks could run at the same time, and both
36 see the same sha1 as HEAD, so two diffs might be sent for second commit and no
37 diff for the first commit.
38
39 Ikiwiki's own locking prevents this from happenning if both commits are web
40 edits. At least one of the two commits has to be a non-web commit.
41
42 ----
43
44 A related problem is that if two commits are made separately but then
45 pushed in together, the commit code only looks at the HEAD commit, which
46 is the second one. No notification is sent for the first.
47
48 ----
49
50 Based on all of these problems with using the post-update hook, ikiwiki
51 should be changed to use the post-receive hook, which provides enough
52 information to avoid the assumuptions that led to these problems.
53 Transitioning existing wikis to using a new hook will be interesting. Also,
54 this hook is only present in git >= 1.5.0.7.
55 --[[Joey]]