Steve Singer ssinger_pg at sympatico.ca
Sat Mar 17 10:06:54 PDT 2007
On Sat, 17 Mar 2007, Steve Singer wrote:

The attached patch against 1.2 should fix this bug by not
executing your DDL on the event node.

If your DDL has errors then you won't find out about it 
until slon tries to execute it on the other node (slonik won't give you an 
error but making changes just on your subscribers can have the potential 
for all sorts of trouble if your not careful)



> On Sat, 17 Mar 2007, Mikko Partio wrote:
>
> Your getting this because your EVENT_NODE is 1 but you only want to execute 
> the script on 2.
>
> Slonik probably should have a check to see if you have specified an only 
> excecute different than your event node and just submit the script into the 
> queue at that stage.
>
> Another option is to require the event node be equal to the only execute 
> node.
>
>
>
>> Hi,
>> 
>> slonik's EXECUTE SCRIPT -documentation says that:
>> 
>> EXECUTE ONLY ON = ival
>> 
>>   (Optional) The ID of the only node to actually execute the script.
>>   This option causes the script to be propagated by all nodes but
>>   executed only by one. The default is to execute the script on all
>>   nodes that are subscribed to the set.
>> 
>> 
>> In my experience this property is not working correctly, and here's the 
>> proof ("tiuhti" is origin and "viuhti" subscriber):
>> 
>> slony1 at tiuhti:~$ psql -d cldb -c "CREATE TABLE testtable (id int)" -h 
>> tiuhti
>> CREATE TABLE
>> slony1 at tiuhti:~$ psql -d cldb -c "CREATE TABLE testtable (id int)" -h 
>> viuhti
>> CREATE TABLE
>> 
>> slony1 at tiuhti:~$ cat drop_table_testtable.sql
>> DROP TABLE testtable;
>> 
>> slony1 at tiuhti:~$ cat droptest.slonik
>> #!/usr/bin/slonik
>> 
>> CLUSTER NAME=climate;
>> 
>> NODE 1 ADMIN CONNINFO = 'dbname=cldb host=tiuhti user=slony1';
>> NODE 2 ADMIN CONNINFO = 'dbname=cldb host=viuhti user=slony1';
>> 
>> EXECUTE SCRIPT (
>>       SET ID = 1,
>>       FILENAME = '/home/slony1/drop_table_testtable.sql',
>>       EVENT NODE = 1,
>>       EXECUTE ONLY ON = 2
>> );
>> 
>> slony1 at tiuhti:~$ slonik droptest.slonik
>> DDL script consisting of 1 SQL statements
>> DDL Statement 0: (0,21) [DROP TABLE testtable;]
>> Submit DDL Event to subscribers...
>> DDL on origin - PGRES_TUPLES_OK
>> 
>> slony1 at tiuhti:~$ psql -d cldb -c "\d testtable" -h viuhti
>> Did not find any relation named "testtable".
>> 
>> This is what I expected, but
>> 
>> slony1 at tiuhti:~$ psql -d cldb -c "\d testtable" -h tiuhti
>> Did not find any relation named "testtable".
>> 
>> Wooah - the script dropped table testtable from both nodes although I 
>> specified the "execute only on" -option. Is there something I'm missing or 
>> is there a bug?
>> 
>> Regards
>> 
>> MP
>> 
>> _______________________________________________
>> Slony1-general mailing list
>> Slony1-general at lists.slony.info
>> http://lists.slony.info/mailman/listinfo/slony1-general
>> 
>
> _______________________________________________
> Slony1-general mailing list
> Slony1-general at lists.slony.info
> http://lists.slony.info/mailman/listinfo/slony1-general
>
-------------- next part --------------
Index: slonik/slonik.c
===================================================================
RCS file: /slony1/slony1-engine/src/slonik/slonik.c,v
retrieving revision 1.67.2.6
diff -c -w -r1.67.2.6 slonik.c
*** slonik/slonik.c	15 Mar 2007 18:52:02 -0000	1.67.2.6
--- slonik/slonik.c	17 Mar 2007 16:30:55 -0000
***************
*** 3916,3921 ****
--- 3916,3926 ----
  		}
  		strncpy(dest, dstring_data(&script) + startpos, endpos-startpos);
  		dest[STMTS[stmtno]-startpos] = 0;
+ 
+ 		if(stmt->only_on_node==-1 ||
+ 		   stmt->only_on_node ==stmt->ev_origin) 
+ 		  {
+ 
  		  slon_mkquery(&query, dest);
  		  printf("DDL Statement %d: (%d,%d) [%s]\n", stmtno, startpos, endpos, dest);
  		  free(dest);
***************
*** 3933,3938 ****
--- 3938,3955 ----
  		    }
  		  /* rstat = PQresultStatus(res); */
  		  /* printf ("Success - %s\n", PQresStatus(rstat)); */
+ 
+ 		  }
+ 		else {
+ 
+ 		    /**
+ 		     * Do not execute
+ 		     */
+ 		    printf("Skipping EXECUTE SCRIPT on node %d only for %d\n",
+ 			   stmt->only_on_node, stmt->ev_origin);
+ 		}
+ 
+ 
  	}
  	
  	printf("Submit DDL Event to subscribers...\n");


More information about the Slony1-general mailing list