Replication Master Daemon for Cyrus IMAP

Background

Download code here: pushmail.c.

This was written as a way to support multiple replicas for Cyrus IMAP 2.3.x replication without having to modify the Cyrus code.

Basically it works by maintaining separate log files for each replica that are created by duplicating the normal log file that Cyrus creates. The host-specific log files are then pushed independently to each replica by firing off a separate copy of sync_client.

Rather than keeping track of log file offsets, etc., this takes the simpler approach of a lot of appending and moving and deleting files. I think the in overall scheme of a Cyrus server, the overhead is probably insignificant, and I think it adds a fair amount of robustness as the state is kept pretty well in the log copies. The program can be started and stopped asyncronously with Cyrus itself, can crash and be restarted, etc., and maintain it's proper place without losing replication events. It knows how to resume operation from various failed states and intermediate log file conditions and do the right thing the most efficient way (I think).

I am throwing this out to the public rather quickly because there has been some related discussion on the Cyrus IMAP mailing list and I am interested in comments. At this time, any documentation is non-existant except what I am writing here now and the source code itself.

The command-line arguments are a list of replica host names or addresses, along with a few options that control operation:

-b causes the program to daemonize and run in the background. This also implies logging errors to syslog rather than to stderr.

-p pidfile creates a pid file containing the daemon's process ID.

-i interval specifies the interval at which the master log file (the one written by Cyrus itself) is polled for changes and copied into the individual replica log files.

-t interval specifies the interval at which the individual replicas are pushed changes. Note that this applies to replica names appearing after the option, so make it come before all replicas to affect all of them, or replicas can have different intervals by specifiying it between.

The code tries to do the right thing as far as file locking, error handling, etc., but probably has not been reviewed carefully enough at this point. I have been running this for about six months (as of August 2006) in a two-replica configuration with a set of about seven active but "non-production" mailboxes, meaning mailboxes of myself and a few other test users. I have not seen any issues that I would attribute to this code.

Note that I am running Cyrus in a chroot environment so the pathname of the sync log file that is currently compiled-in is probably not appropriate elsewhere and will need to be changed in the code. Probably this should have a command-line option.

Source Code

Download pushmail.c.

Questions? Comments?

If you have questions, comments, or requests on this software, please let me know. I can be emailed at david@madole.net.

I would also enjoy hearing from you if you are using this software or have created some other solution for this scenario.



Web hosting by
Omd3.com Hosting Services
David S. Madole
2006-08-29 1330 GMT