CVS User Account cvsuser
Tue Mar 21 09:59:27 PST 2006
Log Message:
-----------
Add in -x option - command_on_logarchive

Upon completing a SYNC with archive logging, run the specified command,
passing it the name of the log file as argument

Modified Files:
--------------
    slony1-engine/doc/adminguide:
        slonconf.sgml (r1.11 -> r1.12)
        slonik_ref.sgml (r1.43 -> r1.44)
    slony1-engine/src/slon:
        confoptions.h (r1.27 -> r1.28)
        remote_worker.c (r1.109 -> r1.110)
        slon.c (r1.64 -> r1.65)

-------------- next part --------------
Index: slonconf.sgml
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/doc/adminguide/slonconf.sgml,v
retrieving revision 1.11
retrieving revision 1.12
diff -Ldoc/adminguide/slonconf.sgml -Ldoc/adminguide/slonconf.sgml -u -w -r1.11 -r1.12
--- doc/adminguide/slonconf.sgml
+++ doc/adminguide/slonconf.sgml
@@ -192,6 +192,56 @@
 
   </variablelist>
 </sect1>
+<sect1 id="slon-archive-logging">
+  <title> Archive Logging Options </title>
+  <variablelist>
+    <varlistentry id="slon-config-archive-dir" xreflabel="slon_conf_archive_dir">
+      <term><varname>archive_dir</varname> (<type>text</type>)</term>
+      <indexterm>
+        <primary><varname>archive_dir</varname> configuration parameter</primary>
+      </indexterm>
+      <listitem>
+        <para>This indicates in what directory sync archive files should be stored.
+        </para>
+      </listitem>
+    </varlistentry>
+
+    <varlistentry id="slon-config-command-on-logarchive" xreflabel="slon_conf_command_on_log_archive">
+      <term><varname>command_on_logarchive</varname> (<type>text</type>)</term>
+      <indexterm>
+        <primary><varname>command_on_logarchive</varname> configuration parameter</primary>
+      </indexterm>
+      <listitem>
+        <para>This indicates a Unix command to be submitted each time
+        an archive log is successfully generated.
+        </para>
+
+        <para> The command will be passed one parameter, namely the
+        full pathname of the archive file.  Thus, supposing we have
+        the settings...</para>
+
+        <command>command_on_logarchive = <filename>/usr/local/bin/logstuff</filename></command>
+        <command>archive_dir = <filename>/var/log/slony1/archivelogs/payroll</filename></command>
+
+        <para> A typical log file might be named something like
+        <filename>/var/log/slony1/archivelogs/payroll/slony1_log_1_00000000000000000036.sql</filename></para>
+
+        <para> The command run after that SYNC was generated would be: </para>
+
+        <command><filename>/usr/local/bin/logstuff</filename> <filename>/var/log/slony1/archivelogs/payroll/slony1_log_1_00000000000000000036.sql</filename></command>
+
+        <warning> <para> Note that this is run via
+        <function>system(const char *COMMAND)</function>; if the
+        program that is run takes five minutes to run, that will defer
+        the next <command>SYNC</command> by five minutes.  You
+        probably don't want the archiving command to do much
+        <quote>in-line</quote> work.</para></warning>
+
+      </listitem>
+    </varlistentry>
+    
+  </variablelist>
+</sect1>
 <sect1 id="slon-config-interval">
   <title>Event Tuning</title>
   <variablelist>
Index: slonik_ref.sgml
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/doc/adminguide/slonik_ref.sgml,v
retrieving revision 1.43
retrieving revision 1.44
diff -Ldoc/adminguide/slonik_ref.sgml -Ldoc/adminguide/slonik_ref.sgml -u -w -r1.43 -r1.44
--- doc/adminguide/slonik_ref.sgml
+++ doc/adminguide/slonik_ref.sgml
@@ -1848,6 +1848,30 @@
 	inserting new entries into the index.</para></listitem>
      </itemizedlist>
      
+     <warning><para> This operation can take a (potentially distinctly)
+     non-zero period of time.  If you have a great deal of data in a
+     particular set of tables, it may take hours or even (if <quote>a
+     great deal</quote> indicates <quote>tens or hundreds gigabytes of
+     data</quote>) possibly multiple days for this event to
+     complete.</para>
+
+     <para> The <command>SUBSCRIBE SET</command> request will,
+     nonetheless, return fairly much immediately, even though the work
+     is merely <quote>in progress.</quote> If you need to set up
+     subscriptions for a set of cascading nodes, you will need to wait
+     for each subscriber to complete subscribing before submitting
+     requests for subscriptions that use that node as a provider.  If
+     you don't, it won't be a big deal: <command>slonik</command> will
+     check the node, discover that it is not yet an active provider
+     for the set, and report back:</para>
+
+<programlisting>
+ Slony-I: provider 2 is not an active forwarding node for replication set 1
+</programlisting>
+
+     <para> In effect, such subscription requests will be ignored
+     until the provider is ready.</para>
+</warning>
 
      <note><para> If you need to revise subscription information for a
        node, you <emphasis>also</emphasis> submit the new information
@@ -2393,7 +2417,11 @@
     <para> In &slony1; version 1.2, the DDL script is split into
     statements, and each is submitted separately.  As a result, it is
     fine for later statements to refer to objects or attributes
-    created or modified in earlier statements. </para>
+    created or modified in earlier statements.  Furthermore, in
+    version 1.2, the <command>slonik</command> output includes a
+    listing of each statement as it is processed, on the set origin
+    node.  Similarly, the statements processed are listed in slon logs
+    on the other nodes.</para>
    </refsect1>
   </refentry>
 
Index: confoptions.h
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/src/slon/confoptions.h,v
retrieving revision 1.27
retrieving revision 1.28
diff -Lsrc/slon/confoptions.h -Lsrc/slon/confoptions.h -u -w -r1.27 -r1.28
--- src/slon/confoptions.h
+++ src/slon/confoptions.h
@@ -40,6 +40,7 @@
 char	   *log_timestamp_format;
 char	   *sql_on_connection;
 char	   *lag_interval;
+char       *command_on_logarchive;
 
 enum config_type
 {
@@ -370,6 +371,20 @@
 		NULL
 	},
 
+	{
+		{
+			(const char *)"command_on_logarchive",
+			gettext_noop("Command to run (probably a shell script) "
+				     "every time a log archive is committed. "
+				     "This command will be passed one parameter: "
+				     "The full pathname of the archive file"
+				),
+			NULL,
+			SLON_C_STRING
+		},
+		&command_on_logarchive,
+		NULL
+	},
 
 
 #ifdef HAVE_SYSLOG
Index: remote_worker.c
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/src/slon/remote_worker.c,v
retrieving revision 1.109
retrieving revision 1.110
diff -Lsrc/slon/remote_worker.c -Lsrc/slon/remote_worker.c -u -w -r1.109 -r1.110
--- src/slon/remote_worker.c
+++ src/slon/remote_worker.c
@@ -4909,6 +4909,13 @@
 	if (archive_dir)
 	{
 		close_log_archive();
+		if (command_on_logarchive) {
+			char command[512];
+			sprintf(command, "%s %s", command_on_logarchive, archive_name);
+			slon_log(SLON_INFO, "remoteWorkerThread_%d: Run Archive Command %s\n",
+				 node->no_id, command);
+			system(command);
+		}
 	}
 
 	/*
Index: slon.c
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/src/slon/slon.c,v
retrieving revision 1.64
retrieving revision 1.65
diff -Lsrc/slon/slon.c -Lsrc/slon/slon.c -u -w -r1.64 -r1.65
--- src/slon/slon.c
+++ src/slon/slon.c
@@ -101,6 +101,7 @@
 	fprintf(stderr, "    -p <filename>         slon pid file\n");
 	fprintf(stderr, "    -f <filename>         slon configuration file\n");
 	fprintf(stderr, "    -a <directory>        directory to store SYNC archive files\n");
+	fprintf(stderr, "    -x <command>          program to run after writing archive file\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");
@@ -171,7 +172,7 @@
 
 	InitializeConfOptions();
 
-	while ((c = getopt(argc, argv, "f:a:d:s:t:g:c:p:o:q:r:l:hv?")) != EOF)
+	while ((c = getopt(argc, argv, "f:a:d:s:t:g:c:p:o:q:r:l:x:hv?")) != EOF)
 	{
 		switch (c)
 		{
@@ -234,6 +235,10 @@
 				exit(0);
 				break;
 
+			case 'x':
+				set_config_option("command_on_logarchive", optarg);
+				break;
+
 			default:
 				fprintf(stderr, "unknown option '%c'\n", c);
 				errors++;



More information about the Slony1-commit mailing list