[Dovecot] Save/restore IMAP session state
Some future Dovecot version will have "imap-idle" processes where IDLEing IMAP connections get moved, so the system wouldn't waste so much memory for all the IDLEing imap processes. A week ago I thought I'd see how easy it would be to implement this. I got a basic proof of concept working as a "X-STATE" command.
Save the state:
a x-state
- STATE AQDLW45QdwAAAAMAAABuAQAAAAAAAFAcffYAPHnpFctbjlDbYQAAcEmzCwAA a OK State exported.
Restore the state:
b x-state AQDLW45QdwAAAAMAAABuAQAAAAAAAFAcffYAPHnpFctbjlDbYQAAcEmzCwAA b OK State imported.
This could also be used to implement quick session state restoring for webmails (as suggested by Michael Slusarz).
For getting the imap-idle process there would have to be code that:
- triggers the session saving when process is IDLEing
- figures out what filesystem paths the imap-idle should be looking at (i.e. paths to selected mailbox's dovecot.index.log file and maybe for e.g. maildir new/)
- send the session state string, paths and imap connection fd to imap-idle process via UNIX socket
- implement the actual imap-idle process
- implement a way for imap-idle process to send back the state and connection fd to restore the imap process
The patch is ugly and still missing many things. Anyway I thought I'd include it here just in case someone was really eager to continue implementing it. :) I'm not sure when I'll have time for it.
A full patch would probably have to have some session_save()/session_restore() functions in lib-storage API. But a quick and dirty way is possible to implement for v2.1 as well, as long as some IMAP extensions aren't used (most importantly rfc5267).
On 29.10.2012, at 18.53, Timo Sirainen wrote:
The patch is ugly and still missing many things. Anyway I thought I'd include it here just in case someone was really eager to continue implementing it. :) I'm not sure when I'll have time for it.
Oh, and of course I forgot one file out of the patch. Here's an updated one.
Quoting Timo Sirainen tss@iki.fi:
A week ago I thought I'd see how easy it would be to implement this. I got a basic proof of concept working as a "X-STATE" command.
[snip]
This could also be used to implement quick session state restoring for webmails (as suggested by Michael Slusarz).
Wow. We must have some sort of crazy mind-meld going on: I have been
working on this concept the last few days with the idea of generating
some sort of draft proposal to provoke further discussion going
forward. I would say great minds think alike, but that would be
giving myself too much credit.
So this provided the necessary motivation to finish the draft concept.
Now that I have (somewhat) figured out the RFC 2629 XML format for
doing this kind of thing, hopefully this has is presented in a
somewhat coherent format.
The draft, which is significantly more comprehensive than your
suggestion, can be found here:
https://raw.github.com/slusarz/horde-sandbox/master/imap-state-draft/draft-i...
Not sure if this should remain the forum for discussing this concept,
or if we should move to private messages (or even to the imap-protocol
list). Let me know your thoughts on this (or anyone else with an
interest).
michael
participants (2)
-
Michael M Slusarz
-
Timo Sirainen