diff options
-rw-r--r-- | doc/howto/londiste3_simple_rep_howto.txt | 49 | ||||
-rw-r--r-- | doc/pgqd.txt | 1 | ||||
-rw-r--r-- | python/londiste/playback.py | 2 | ||||
-rw-r--r-- | python/londiste/setup.py | 2 | ||||
-rw-r--r-- | sql/londiste/expected/londiste_provider.out | 18 | ||||
-rw-r--r-- | sql/londiste/expected/londiste_provider_1.out | 26 | ||||
-rw-r--r-- | sql/ticker/pgqd.c | 1 |
7 files changed, 55 insertions, 44 deletions
diff --git a/doc/howto/londiste3_simple_rep_howto.txt b/doc/howto/londiste3_simple_rep_howto.txt index c9367aa6..74db0c97 100644 --- a/doc/howto/londiste3_simple_rep_howto.txt +++ b/doc/howto/londiste3_simple_rep_howto.txt @@ -5,14 +5,14 @@ This sample does the following actions: * sets up the databases - - creates a database 'l3simple_db1', which will be master + - creates a database 'l3simple', on host which will be master - populates this with pgbench schema and data - adds primary and foreign keys to make the db more realistic - - makes a copy of the database ('l3simple_db2') to be used as slave + - makes a copy of the database on another node to be used as slave * sets up replication from the master to slave database - - creates the root node on 'l3simple_db1' - - creates a leaf node on 'l3simple_db2' - - starts the ticker daemon + - creates the root node on the master node + - creates a leaf node on the slave node + - starts the ticker daemon on the master node - adds all tables to replication set on both databases - waits for the replication to complete @@ -25,7 +25,7 @@ It also runs pgbench to test that the replication actually happens and works pro Run the following SQL: ---- -CREATE DATABASE l3simple_db1; +CREATE DATABASE l3simple; ---- === Set up pgbench schema === @@ -36,7 +36,7 @@ populating it with sample data and later running SQL loads to be replicated. Run command : ---- -/usr/lib/postgresql/9.1/bin/pgbench -i -s 2 -F 80 l3simple_db1 +pgbench -i -s 2 -F 80 l3simple ---- === And add primary and foreign keys needed for replication === @@ -63,7 +63,7 @@ ALTER TABLE pgbench_history ADD CONSTRAINT pgbench_history_accounts_fk FOREIGN K then load it into database: ---- -psql l3simple_db1 -f /tmp/prepare_pgbenchdb_for_londiste.sql +psql l3simple -f /tmp/prepare_pgbenchdb_for_londiste.sql ---- @@ -74,7 +74,7 @@ psql -d postgres -c "CREATE DATABASE l3simple_db2;" pg_dump -s l3simple_db1 | psql l3simple_db2 ---- -Create configuration file st3simple/st3_l3simple_db1.ini +Create configuration file st3simple/st3_l3simple_primary.ini ---- [londiste3] @@ -86,40 +86,42 @@ pidfile = st3simple/pid/st3_l3simple_db1.pid ---- +REMINDER: open trust to the leaf host in pg_hba.conf, or add a user to auth as and include in the connstring + Create Londiste root node: ---- -londiste3 st3simple/st3_l3simple_db1.ini create-root node1 dbname=l3simple_db1 +londiste3 st3simple/st3_l3simple_primary.ini create-root node1 "dbname=l3simple host=10.199.59.194" ---- Run worker daemon for root node: ---- -londiste3 -d st3simple/st3_l3simple_db1.ini worker +londiste3 -d st3simple/st3_l3simple_primary.ini worker ---- -Create configuration file st3simple/st3_l3simple_db2.ini +Create configuration file st3simple/st3_l3simple_leaf.ini for worker daemon on target node: ---- [londiste3] -job_name = st3_l3simple_db2 -db = dbname=l3simple_db2 +job_name = st3_l3simple_leaf +db = dbname=l3simple queue_name = replika -logfile = st3simple/log/st3_l3simple_db2.log -pidfile = st3simple/pid/st3_l3simple_db2.pid +logfile = st3simple/log/st3_l3simple_leaf.log +pidfile = st3simple/pid/st3_l3simple_leaf.pid ---- Initialize node in target database: ---- -londiste3 st3simple/st3_l3simple_db2.ini create-leaf node2 dbname=l3simple_db2 --provider=dbname=l3simple_db1 +londiste3 st3simple/st3_l3simple_leaf.ini create-leaf node2 dbname=l3simple --provider="dbname=l3simple host=10.199.59.194" ---- Launch worker daemon for target database: ---- -londiste3 -d st3simple/st3_l3simple_db2.ini worker +londiste3 -d st3simple/st3_l3simple_leaf.ini worker ---- Create config file `st3simple/pgqd.ini` for PgQ ticker daemon: @@ -141,7 +143,7 @@ To generate some data traffic on the master database while replicating, run the following command in background: ---- -/usr/lib/postgresql/9.1/bin/pgbench -T 120 -c 5 l3simple_db1 -f /tmp/throttled.pgbench +pgbench -T 120 -c 5 l3simple -f /tmp/throttled.pgbench ---- The /tmp/throttled.pgbench contains the standard pgbench workload, except that @@ -151,8 +153,8 @@ Now add all the tables to replication, first on root node and then on the leaf: Run command : ---- -londiste3 st3simple/st3_l3simple_db1.ini add-table --all -londiste3 st3simple/st3_l3simple_db2.ini add-table --all +londiste3 st3simple/st3_l3simple_primary.ini add-table --all +londiste3 st3simple/st3_l3simple_leaf.ini add-table --all ---- @@ -164,13 +166,13 @@ The following command will run pgbench full speed with 5 parallel database connections generating database traffic for 10 seconds: ---- -/usr/lib/postgresql/9.1/bin/pgbench -T 10 -c 5 l3simple_db2 +pgbench -T 10 -c 5 l3simple ---- After this is done, you can check that the tables on both sides have the same data: ---- -londiste3 st3simple/st3_l3simple_db2.ini compare +londiste3 st3simple/st3_l3simple_leaf.ini compare ---- Compare command will establish the same logical point in time on provider and @@ -207,3 +209,4 @@ The "checksum" is computed by adding up hashtext() sums for all database rows. == Done == The setup of simple 2 node cluster is done. + diff --git a/doc/pgqd.txt b/doc/pgqd.txt index 4c873dac..d15fda62 100644 --- a/doc/pgqd.txt +++ b/doc/pgqd.txt @@ -60,6 +60,7 @@ Switches: # log into syslog #syslog = 1 #syslog_ident = pgqd + #syslog_facility = local0 ## optional timeouts ## diff --git a/python/londiste/playback.py b/python/londiste/playback.py index f21d7e58..c15a3f5b 100644 --- a/python/londiste/playback.py +++ b/python/londiste/playback.py @@ -726,7 +726,7 @@ class Replicator(CascadedWorker): res = self.exec_cmd(dst_curs, q, [self.queue_name, fname, sql, s_attrs], commit = False) ret = res[0]['ret_code'] if ret > 200: - self.log.info("Skipping execution of '%s'", fname) + self.log.warning("Skipping execution of '%s'", fname) if pgver >= 80300: dst_curs.execute("set local session_replication_role = 'replica'") return diff --git a/python/londiste/setup.py b/python/londiste/setup.py index 055be922..d374d92e 100644 --- a/python/londiste/setup.py +++ b/python/londiste/setup.py @@ -572,7 +572,7 @@ class LondisteSetup(CascadeAdmin): q = "select * from londiste.execute_start(%s, %s, %s, true, %s)" res = self.exec_cmd(db, q, [self.queue_name, fname, sql, attrs.to_urlenc()], commit = False) ret = res[0]['ret_code'] - if ret >= 300: + if ret > 200: self.log.warning("Skipping execution of '%s'", fname) continue if attrs.need_execute(curs, local_tables, local_seqs): diff --git a/sql/londiste/expected/londiste_provider.out b/sql/londiste/expected/londiste_provider.out index 126f2b91..d81dbfe0 100644 --- a/sql/londiste/expected/londiste_provider.out +++ b/sql/londiste/expected/londiste_provider.out @@ -86,11 +86,11 @@ select * from londiste.get_table_list('aset'); (0 rows) select ev_id, ev_type, ev_data, ev_extra1 from pgq.event_template; - ev_id | ev_type | ev_data | ev_extra1 --------+-----------------------+----------------------+----------------- - 1 | londiste.add-table | public.testdata | - 2 | I:id | id=1&txt=test%2ddata | public.testdata - 3 | londiste.remove-table | public.testdata | + ev_id | ev_type | ev_data | ev_extra1 +-------+-----------------------+--------------------+----------------- + 1 | londiste.add-table | public.testdata | + 2 | I:id | id=1&txt=test-data | public.testdata + 3 | londiste.remove-table | public.testdata | (3 rows) select * from londiste.local_show_missing('aset'); @@ -143,11 +143,9 @@ select tgname from pg_trigger where tgrelid = 'public.trg_test'::regclass order delete from londiste.table_info where table_name = 'public.trg_test'; select tgname from pg_trigger where tgrelid = 'public.trg_test'::regclass order by 1; - tgname -------------------------- - _londiste_aset - _londiste_aset_truncate -(2 rows) + tgname +-------- +(0 rows) -- handler test create table hdlr_test ( diff --git a/sql/londiste/expected/londiste_provider_1.out b/sql/londiste/expected/londiste_provider_1.out index 74e7a433..cdfc47f5 100644 --- a/sql/londiste/expected/londiste_provider_1.out +++ b/sql/londiste/expected/londiste_provider_1.out @@ -85,11 +85,11 @@ select * from londiste.get_table_list('aset'); (0 rows) select ev_id, ev_type, ev_data, ev_extra1 from pgq.event_template; - ev_id | ev_type | ev_data | ev_extra1 --------+-----------------------+----------------------+----------------- - 1 | londiste.add-table | public.testdata | - 2 | I:id | id=1&txt=test%2ddata | public.testdata - 3 | londiste.remove-table | public.testdata | + ev_id | ev_type | ev_data | ev_extra1 +-------+-----------------------+--------------------+----------------- + 1 | londiste.add-table | public.testdata | + 2 | I:id | id=1&txt=test-data | public.testdata + 3 | londiste.remove-table | public.testdata | (3 rows) select * from londiste.local_show_missing('aset'); @@ -140,10 +140,9 @@ select tgname from pg_trigger where tgrelid = 'public.trg_test'::regclass order delete from londiste.table_info where table_name = 'public.trg_test'; select tgname from pg_trigger where tgrelid = 'public.trg_test'::regclass order by 1; - tgname ----------------- - _londiste_aset -(1 row) + tgname +-------- +(0 rows) -- handler test create table hdlr_test ( @@ -180,3 +179,12 @@ select ev_id, ev_type, ev_data, ev_extra1, ev_extra4 from pgq.event_template whe 9 | I:id | id=3&txt=data3 | public.hdlr_test | (3 rows) +-- test proper trigger creation with add-table specific args +select * from londiste.local_add_table('aset', 'public.trg_test', array['ev_extra4=''test='' || txt', 'expect_sync', 'skip']); + ret_code | ret_note +----------+------------------------------ + 200 | Table added: public.trg_test +(1 row) + +insert into trg_test values (2, 'data2'); +ERROR: SKIP does not work in AFTER trigger. diff --git a/sql/ticker/pgqd.c b/sql/ticker/pgqd.c index 67dca88e..b7aa437c 100644 --- a/sql/ticker/pgqd.c +++ b/sql/ticker/pgqd.c @@ -51,6 +51,7 @@ static const struct CfKey conf_params[] = { CF_REL("database_list", CF_STR, database_list, 0, NULL), CF_ABS("syslog", CF_INT, cf_syslog, 0, "1"), CF_ABS("syslog_ident", CF_STR, cf_syslog_ident, 0, "pgqd"), + CF_ABS("syslog_facility", CF_STR, cf_syslog_facility, 0, "daemon"), CF_REL("check_period", CF_TIME_DOUBLE, check_period, 0, "60"), CF_REL("maint_period", CF_TIME_DOUBLE, maint_period, 0, "120"), CF_REL("retry_period", CF_TIME_DOUBLE, retry_period, 0, "30"), |