So I guess my index is corrupted in some weird way (probably I managed
to create two mails with the same docid). I've worked around it by commenting
out the assert, but any idea how to fix my index?

Did this happen right after you sent a message? I had to fix this by doing a dump and rebuilding the index.

- Mike