Re: failover mode

George Schlossnagle <[email protected]> Mon, 9 Aug 2004 15:39:57 -0400
Newsgroups gmane.comp.apache.mod-log-spread.user
Message-ID <[email protected]>
On Aug 9, 2004, at 3:28 PM, mpeters wrote:

> George Schlossnagle wrote:
>> On Aug 9, 2004, at 3:03 PM, mpeters wrote:
>>> I saw (in the change log) that mod_log_spread has support for a 
>>> failover mode. I didn't see any details on this in the README or 
>>> sample configurations so I have a few questions.
>>>
>>> Does this work if spread is down or if it cannot deliver the 
>>> message? Will this send logs locally? If this is the case, how do I 
>>> tell apache where to send the logs? Thanks in advance for any help.
>> It's documented in the header of mod_log_spread.c and in the INSTALL 
>> file.  It works if the primary log attempt fails.  ATM it is a 
>> spread-only feature, i.e. no local file-based logging as backup.
>
> Thanks george. I actually looked at mod_log_spread.c and saw that  it 
> only mentioned the failover spread group. What would it take to have 
> local file-based logging as a failover option? I would volunteer my 
> help if that helps.

Well, the support would need to be added.  It's not too much work.   
Probably the easiest way is to alter it so that either of the custom 
log targets can be any sort of target., then alter the portion of the 
code where the write occurs so as to be sensitive to what kind of log 
it is.  For example you might change config_log_state to have two 
pairs:

char *primaryLogLocation;
int      primaryLogType;
char  *failoverLogLocation;
int      failoverLogType;


primaryLogLocation would be basically a union of config_log_state.fname 
and config_log_state.spread_group, and primaryLogType would note which 
kind it was (spread group, piped log, regular log, whatever).  Same for 
secondary logs.  Then in config_log_transaction() where it says:

         if (cls->spread_group[0]) {
             spread_multicast_log(r, cls, str, len);
         }
         else {
                 write(cls->log_fd, str, len);
         }

you would do something like:

if(write_primary_log(r, cls, str, len) < 0) {
   ap_log_error(..., "failed to log to primary log facility");
   if(write_secondary_log(r, cls, str, len) < 0) {
     ap_log_error(..., "failed to log to secondary log facility, logline 
dropped");
   }
}

where of course the write_* functions above execute the logic to 
perform the write depending on the 'type' for their phase.

George