Wed Aug 17 15:42:52 PDT 2005
- Previous message: [Slony1-commit] By cbbrowne: Add in discussion of what needs to be available in order to
- Next message: [Slony1-commit] By cbbrowne: A test script for the "lag_interval" parameter
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Log Message: ----------- Add "lag_interval" option to slon This allows a slon to have, passed to it, a time interval. The slon will then ignore events until they have become older than that interval. This allows the Gentle User to set up a subscriber that will steadily lag by 1 hour, so you could query an old state of the database. Modified Files: -------------- slony1-engine/doc/adminguide: slon.sgml (r1.17 -> r1.18) slonconf.sgml (r1.9 -> r1.10) slony1-engine/src/slon: confoptions.h (r1.24 -> r1.25) remote_listen.c (r1.21 -> r1.22) slon.c (r1.56 -> r1.57) -------------- next part -------------- Index: slonconf.sgml =================================================================== RCS file: /usr/local/cvsroot/slony1/slony1-engine/doc/adminguide/slonconf.sgml,v retrieving revision 1.9 retrieving revision 1.10 diff -Ldoc/adminguide/slonconf.sgml -Ldoc/adminguide/slonconf.sgml -u -w -r1.9 -r1.10 --- doc/adminguide/slonconf.sgml +++ doc/adminguide/slonconf.sgml @@ -318,6 +318,23 @@ </listitem> </varlistentry> + <varlistentry id="slon-config-lag-interval" xreflabel="lag_interval"> + <term><varname>lag_interval</varname> (<type>string/interval</type>)</term> + <indexterm> + <primary><varname>lag_interval</varname> configuration parameter</primary> + </indexterm> + <listitem> + <para>Indicates an interval by which this node should lag its + providers. If set, this is used in the event processing loop + to modify what events are to be considered for queueing; those + events newer than <command> now() - lag_interval::interval + </command> are left out, to be processed later. </para> + + <para>If the value is left empty, this logic will be ignored. + </para> + </listitem> + </varlistentry> + </variablelist> </sect1> </article> Index: slon.sgml =================================================================== RCS file: /usr/local/cvsroot/slony1/slony1-engine/doc/adminguide/slon.sgml,v retrieving revision 1.17 retrieving revision 1.18 diff -Ldoc/adminguide/slon.sgml -Ldoc/adminguide/slon.sgml -u -w -r1.17 -r1.18 --- doc/adminguide/slon.sgml +++ doc/adminguide/slon.sgml @@ -331,6 +331,20 @@ </listitem> </varlistentry> + <varlistentry> + <term><option>-l</option><replaceable class="parameter"> lag interval </replaceable></term> + <listitem> + <para> + <envar>lag_interval</envar> indicates an interval value such as + <command> 3 minutes </command> or <command> 4 hours </command> + or <command> 2 days </command> that indicates that this node is + to lag its providers by the specified interval of time. This + causes events to be ignored until they reach the age + corresponding to the interval. + </para> + </listitem> + </varlistentry> + </variablelist> </refsect1> <refsect1> Index: confoptions.h =================================================================== RCS file: /usr/local/cvsroot/slony1/slony1-engine/src/slon/confoptions.h,v retrieving revision 1.24 retrieving revision 1.25 diff -Lsrc/slon/confoptions.h -Lsrc/slon/confoptions.h -u -w -r1.24 -r1.25 --- src/slon/confoptions.h +++ src/slon/confoptions.h @@ -37,6 +37,7 @@ bool drop_indices; char *log_timestamp_format; char *sql_on_connection; +char *lag_interval; enum config_type { @@ -330,6 +331,20 @@ }, + { + { + (const char *)"lag_interval", + gettext_noop("A PostgreSQL value compatible with ::interval " + "which indicates how far behind this node should " + "lag its providers."), + NULL, + SLON_C_STRING + }, + &lag_interval, + NULL + }, + + #ifdef HAVE_SYSLOG { Index: remote_listen.c =================================================================== RCS file: /usr/local/cvsroot/slony1/slony1-engine/src/slon/remote_listen.c,v retrieving revision 1.21 retrieving revision 1.22 diff -Lsrc/slon/remote_listen.c -Lsrc/slon/remote_listen.c -u -w -r1.21 -r1.22 --- src/slon/remote_listen.c +++ src/slon/remote_listen.c @@ -57,7 +57,7 @@ static int remoteListen_receive_events(SlonNode * node, SlonConn * conn, struct listat *listat); - +extern char *lag_interval; /* * ---------- slon_remoteListenThread @@ -586,6 +586,7 @@ { SlonNode *origin; SlonDString query; + SlonDString q2; char *where_or_or; char seqno_buf[64]; PGresult *res; @@ -620,6 +621,11 @@ rtcfg_lock(); where_or_or = "where"; + if (lag_interval) { + dstring_init(&q2); + slon_mkquery(&q2, "where ev_timestamp < now() - '%s'::interval and (", lag_interval); + where_or_or = dstring_data(&q2); + } while (listat) { if ((origin = rtcfg_findNode(listat->li_origin)) == NULL) @@ -639,6 +645,9 @@ where_or_or = "or"; listat = listat->next; } + if (lag_interval) { + slon_appendquery(&query, ")"); + } slon_appendquery(&query, " order by e.ev_origin, e.ev_seqno"); rtcfg_unlock(); Index: slon.c =================================================================== RCS file: /usr/local/cvsroot/slony1/slony1-engine/src/slon/slon.c,v retrieving revision 1.56 retrieving revision 1.57 diff -Lsrc/slon/slon.c -Lsrc/slon/slon.c -u -w -r1.56 -r1.57 --- src/slon/slon.c +++ src/slon/slon.c @@ -121,7 +121,7 @@ InitializeConfOptions(); - while ((c = getopt(argc, argv, "f:a:d:s:t:g:c:p:o:q:r:hv")) != EOF) + while ((c = getopt(argc, argv, "f:a:d:s:t:g:c:p:o:q:r:l:hv")) != EOF) { switch (c) { @@ -169,6 +169,10 @@ set_config_option("desired_sync_time", optarg); break; + case 'l': + set_config_option("lag_interval", optarg); + break; + case 'h': errors++; break; @@ -254,6 +258,7 @@ fprintf(stderr, " -a <directory> directory to store SYNC archive files\n"); fprintf(stderr, " -q <num> Terminate when this node reaches # of SYNCs\n"); fprintf(stderr, " -r <num> # of syncs for -q option\n"); + fprintf(stderr, " -l <interval> this node should lag providers by this interval\n"); return 1; }
- Previous message: [Slony1-commit] By cbbrowne: Add in discussion of what needs to be available in order to
- Next message: [Slony1-commit] By cbbrowne: A test script for the "lag_interval" parameter
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Slony1-commit mailing list