LOG: query: begin; select getdatabaseencoding(); commit LOG: query: SET autocommit TO 'on';DROP DATABASE "master" DROP DATABASE LOG: query: begin; select getdatabaseencoding(); commit LOG: query: SET autocommit TO 'on';DROP DATABASE "slave" DROP DATABASE LOG: query: begin; select getdatabaseencoding(); commit LOG: query: SET autocommit TO 'on';CREATE DATABASE "master" CREATE DATABASE LOG: query: begin; select getdatabaseencoding(); commit LOG: query: SET autocommit TO 'on';CREATE DATABASE "slave" CREATE DATABASE Using lib '/home/dpavlin/private/home_html/projects/rserv///lib/rserv.so' Connecting to dbname=master LOG: query: begin; select getdatabaseencoding(); commit Connecting to dbname=slave LOG: query: begin; select getdatabaseencoding(); commit LOG: query: BEGIN LOG: query: BEGIN LOG: query: set transaction isolation level serializable LOG: query: set transaction isolation level serializable LOG: query: create table _RSERV_SERVERS_ (server serial primary key, host text not null, port int4 default 5432, dbase text not null, unique(host,port,dbase)) NOTICE: CREATE TABLE will create implicit sequence '_rserv_servers__server_seq' for SERIAL column '_rserv_servers_.server' NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index '_rserv_servers__pkey' for table '_rserv_servers_' NOTICE: CREATE TABLE / UNIQUE will create implicit index '_rserv_servers__host_key' for table '_rserv_servers_' LOG: query: create table _RSERV_SERVERS_ (server serial primary key, host text not null, port int4 default 5432, dbase text not null, unique(host,port,dbase)) NOTICE: CREATE TABLE will create implicit sequence '_rserv_servers__server_seq' for SERIAL column '_rserv_servers_.server' NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index '_rserv_servers__pkey' for table '_rserv_servers_' NOTICE: CREATE TABLE / UNIQUE will create implicit index '_rserv_servers__host_key' for table '_rserv_servers_' LOG: query: insert into _RSERV_SERVERS_ (server, host, port, dbase) values (0,'localhost',5432,'master') LOG: query: insert into _RSERV_SERVERS_ (server, host, port, dbase) values (0,'localhost',5432,'master') LOG: query: create table _RSERV_TABLES_ (tname name not null, cname name not null, reloid oid primary key, key int4 not null) NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index '_rserv_tables__pkey' for table '_rserv_tables_' LOG: query: create table _RSERV_TABLES_ (tname name not null, cname name not null, reloid oid primary key, key int4 not null) NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index '_rserv_tables__pkey' for table '_rserv_tables_' LOG: query: create table _RSERV_LOG_ (reloid oid REFERENCES _RSERV_TABLES_(reloid) ON DELETE CASCADE ON UPDATE CASCADE, logid int4 not null, logtime timestamp not null, insert smallint, update smallint, delete smallint, key text, server int4, CONSTRAINT only_one CHECK (insert+update+delete=1)) NOTICE: CREATE TABLE will create implicit trigger(s) for FOREIGN KEY check(s) LOG: query: create table _RSERV_LOG_ (reloid oid REFERENCES _RSERV_TABLES_(reloid) ON DELETE CASCADE ON UPDATE CASCADE, logid int4 not null, logtime timestamp not null, insert smallint, update smallint, delete smallint, key text, server int4, CONSTRAINT only_one CHECK (insert+update+delete=1)) NOTICE: CREATE TABLE will create implicit trigger(s) for FOREIGN KEY check(s) LOG: query: create index _RSERV_LOG_INDX_DLT_ID_ on _RSERV_LOG_ (delete, logid) WHERE delete = 1 LOG: query: create index _RSERV_LOG_INDX_DLT_ID_ on _RSERV_LOG_ (delete, logid) WHERE delete = 1 LOG: query: create index _RSERV_LOG_INDX_UPD_ID_ on _RSERV_LOG_ (update, logid) WHERE update = 1 LOG: query: create index _RSERV_LOG_INDX_UPD_ID_ on _RSERV_LOG_ (update, logid) WHERE update = 1 LOG: query: create index _RSERV_LOG_INDX_INS_ID_ on _RSERV_LOG_ (insert, logid) WHERE insert = 1 LOG: query: create index _RSERV_LOG_INDX_INS_ID_ on _RSERV_LOG_ (insert, logid) WHERE insert = 1 LOG: query: create index _RSERV_LOG_INDX_TM_ID_ on _RSERV_LOG_ (logtime, logid) LOG: query: create index _RSERV_LOG_INDX_TM_ID_ on _RSERV_LOG_ (logtime, logid) LOG: query: create index _RSERV_LOG_INDX_REL_KEY_ on _RSERV_LOG_ (reloid, key) LOG: query: create index _RSERV_LOG_INDX_REL_KEY_ on _RSERV_LOG_ (reloid, key) LOG: query: CREATE VIEW _RSERV_HUMAN_LOG_ AS SELECT log.logid, tab.tname AS table_name, tab.cname AS column_name, log.key AS column_value, log.insert, log.update, log.delete, log.logtime FROM _RSERV_LOG_ log, _RSERV_TABLES_ tab WHERE tab.reloid = log.reloid ORDER BY log.logtime LOG: query: CREATE VIEW _RSERV_HUMAN_LOG_ AS SELECT log.logid, tab.tname AS table_name, tab.cname AS column_name, log.key AS column_value, log.insert, log.update, log.delete, log.logtime FROM _RSERV_LOG_ log, _RSERV_TABLES_ tab WHERE tab.reloid = log.reloid ORDER BY log.logtime LOG: query: CREATE VIEW _RSERV_DAILY_LOG_ AS SELECT count(*) AS "# records", to_char(_rserv_log_.logtime, 'YYYY-MM-DD') AS day FROM _rserv_log_ GROUP BY day LOG: query: CREATE VIEW _RSERV_DAILY_LOG_ AS SELECT count(*) AS "# records", to_char(_rserv_log_.logtime, 'YYYY-MM-DD') AS day FROM _rserv_log_ GROUP BY day LOG: query: create table _RSERV_SYNC_ (server int REFERENCES _RSERV_SERVERS_(server) ON DELETE CASCADE ON UPDATE CASCADE, syncid int4 not null, synctime timestamp, status int4 not null, minid int4 not null, maxid int4 not null, active text) NOTICE: CREATE TABLE will create implicit trigger(s) for FOREIGN KEY check(s) LOG: query: create table _RSERV_SYNC_ (server int REFERENCES _RSERV_SERVERS_(server) ON DELETE CASCADE ON UPDATE CASCADE, syncid int4 not null, synctime timestamp, status int4 not null, minid int4 not null, maxid int4 not null, active text) NOTICE: CREATE TABLE will create implicit trigger(s) for FOREIGN KEY check(s) LOG: query: create index _RSERV_SYNC_INDX_SRV_ID_ on _RSERV_SYNC_ (server, syncid) LOG: query: create index _RSERV_SYNC_INDX_SRV_ID_ on _RSERV_SYNC_ (server, syncid) LOG: query: create sequence _rserv_sync_seq_ LOG: query: create sequence _rserv_sync_seq_ LOG: query: CREATE FUNCTION _rserv_log_() RETURNS opaque AS '/home/dpavlin/private/home_html/projects/rserv///lib/rserv.so' LANGUAGE 'c' LOG: query: CREATE FUNCTION _rserv_log_() RETURNS opaque AS '/home/dpavlin/private/home_html/projects/rserv///lib/rserv.so' LANGUAGE 'c' LOG: query: CREATE FUNCTION _rserv_sync_(int4) RETURNS int4 AS '/home/dpavlin/private/home_html/projects/rserv///lib/rserv.so' LANGUAGE 'c' LOG: query: CREATE FUNCTION _rserv_sync_(int4) RETURNS int4 AS '/home/dpavlin/private/home_html/projects/rserv///lib/rserv.so' LANGUAGE 'c' LOG: query: CREATE FUNCTION _rserv_debug_(int4) RETURNS int4 AS '/home/dpavlin/private/home_html/projects/rserv///lib/rserv.so' LANGUAGE 'c' LOG: query: CREATE FUNCTION _rserv_debug_(int4) RETURNS int4 AS '/home/dpavlin/private/home_html/projects/rserv///lib/rserv.so' LANGUAGE 'c' LOG: query: CREATE FUNCTION _rserv_xid_() RETURNS int4 AS '/home/dpavlin/private/home_html/projects/rserv///lib/rserv.so' LANGUAGE 'c' LOG: query: CREATE FUNCTION _rserv_xid_() RETURNS int4 AS '/home/dpavlin/private/home_html/projects/rserv///lib/rserv.so' LANGUAGE 'c' LOG: query: create table _RSERV_SLAVE_TABLES_ (tname name not null, cname name not null, reloid oid not null, key int4 not null) LOG: query: create table _RSERV_SLAVE_TABLES_ (tname name not null, cname name not null, reloid oid not null, key int4 not null) LOG: query: create table _RSERV_SLAVE_SYNC_ (syncid int4 not null, synctime timestamp) LOG: query: create table _RSERV_SLAVE_SYNC_ (syncid int4 not null, synctime timestamp) LOG: query: INSERT INTO _RSERV_SERVERS_ (host,dbase) VALUES ('localhost','slave') LOG: query: INSERT INTO _RSERV_SERVERS_ (host,dbase) VALUES ('localhost','slave') LOG: query: COMMIT LOG: query: COMMIT LOG: query: begin; select getdatabaseencoding(); commit create table t1 (i int, t text, d timestamp default 'now', uniq serial); LOG: query: create table t1 (i int, t text, d timestamp default 'now', uniq serial); NOTICE: CREATE TABLE will create implicit sequence 't1_uniq_seq' for SERIAL column 't1.uniq' CREATE TABLE LOG: query: begin; select getdatabaseencoding(); commit create table t1 (i int, t text, d timestamp default 'now', uniq serial); LOG: query: create table t1 (i int, t text, d timestamp default 'now', uniq serial); NOTICE: CREATE TABLE will create implicit sequence 't1_uniq_seq' for SERIAL column 't1.uniq' CREATE TABLE master server nr: 0 LOG: query: begin; select getdatabaseencoding(); commit LOG: query: BEGIN LOG: query: select pgc.oid, pga.attnum from pg_class pgc, pg_attribute pga where pgc.relname = 't1' and pgc.oid = pga.attrelid and pga.attname = 'uniq' LOG: query: create trigger _RSERV_TRIGGER_T_ after insert or update or delete on "t1" for each row execute procedure _rserv_log_('4',0) NOTICE: CreateTrigger: changing return type of function _rserv_log_() from OPAQUE to TRIGGER LOG: query: insert into _RSERV_TABLES_ (tname, cname, reloid, key) values ('t1', 'uniq', 270481, 4) LOG: query: COMMIT master server nr: 1 LOG: query: begin; select getdatabaseencoding(); commit LOG: query: BEGIN LOG: query: select pgc.oid, pga.attnum from pg_class pgc, pg_attribute pga where pgc.relname = 't1' and pgc.oid = pga.attrelid and pga.attname = 'uniq' LOG: query: create trigger _RSERV_TRIGGER_T_ after insert or update or delete on "t1" for each row execute procedure _rserv_log_('4',1) NOTICE: CreateTrigger: changing return type of function _rserv_log_() from OPAQUE to TRIGGER LOG: query: insert into _RSERV_TABLES_ (tname, cname, reloid, key) values ('t1', 'uniq', 270490, 4) LOG: query: COMMIT LOG: query: begin; select getdatabaseencoding(); commit LOG: query: BEGIN LOG: query: select pgc.oid, pga.attnum from pg_class pgc, pg_attribute pga where pgc.relname = 't1' and pgc.oid = pga.attrelid and pga.attname = 'uniq' LOG: query: insert into _RSERV_SLAVE_TABLES_ (tname, cname, reloid, key) values ('t1', 'uniq', 270481, 4) LOG: query: COMMIT LOG: query: begin; select getdatabaseencoding(); commit LOG: query: BEGIN LOG: query: select pgc.oid, pga.attnum from pg_class pgc, pg_attribute pga where pgc.relname = 't1' and pgc.oid = pga.attrelid and pga.attname = 'uniq' LOG: query: insert into _RSERV_SLAVE_TABLES_ (tname, cname, reloid, key) values ('t1', 'uniq', 270490, 4) LOG: query: COMMIT LOG: query: begin; select getdatabaseencoding(); commit insert into t1 values (1, 'one insert master'); LOG: query: insert into t1 values (1, 'one insert master'); LOG: query: update _RSERV_LOG_ set logid = 143663, logtime = now(), insert = 1, update = 0, delete = 0, server = 0 where reloid = 270481 and key = '1' LOG: query: insert into _RSERV_LOG_ (reloid, logid, logtime, insert, update, delete, key, server) values (270481, 143663, now(), 1, 0, 0, '1', 0) LOG: query: SELECT 1 FROM ONLY "public"."_rserv_tables_" x WHERE "reloid" = $1 FOR UPDATE OF x INSERT 270503 1 LOG: query: begin; select getdatabaseencoding(); commit insert into t1 values (2, 'two insert master'); LOG: query: insert into t1 values (2, 'two insert master'); LOG: query: update _RSERV_LOG_ set logid = 143666, logtime = now(), insert = 1, update = 0, delete = 0, server = 0 where reloid = 270481 and key = '2' LOG: query: insert into _RSERV_LOG_ (reloid, logid, logtime, insert, update, delete, key, server) values (270481, 143666, now(), 1, 0, 0, '2', 0) LOG: query: SELECT 1 FROM ONLY "public"."_rserv_tables_" x WHERE "reloid" = $1 FOR UPDATE OF x INSERT 270505 1 LOG: query: begin; select getdatabaseencoding(); commit insert into t1 values (101, '101 insert on slave'); LOG: query: insert into t1 values (101, '101 insert on slave'); LOG: query: update _RSERV_LOG_ set logid = 143669, logtime = now(), insert = 1, update = 0, delete = 0, server = 1 where reloid = 270490 and key = '1' LOG: query: insert into _RSERV_LOG_ (reloid, logid, logtime, insert, update, delete, key, server) values (270490, 143669, now(), 1, 0, 0, '1', 1) LOG: query: SELECT 1 FROM ONLY "public"."_rserv_tables_" x WHERE "reloid" = $1 FOR UPDATE OF x INSERT 270507 1 Master connection is dbname=slave Slave connection is dbname=master Connecting to dbname=slave LOG: query: begin; select getdatabaseencoding(); commit Connecting to dbname=master LOG: query: begin; select getdatabaseencoding(); commit GetServerId: host localhost, database master LOG: query: SELECT server FROM _RSERV_SERVERS_ WHERE host='localhost' AND dbase='master' GetServerId(master,localhost) == 0 GetServerId: host localhost, database slave LOG: query: SELECT server FROM _RSERV_SERVERS_ WHERE host='localhost' AND dbase='slave' GetServerId(slave,localhost) == 1 Using snapshot file: .__Snapshot.15334 >>>>>>>>>>>>> Prepare Snapshot master id: 1 slave id: 0 PrepareSnapshot master: 1 slave: 0 Exec: SELECT tname FROM _RSERV_SLAVE_TABLES_ LOG: query: SELECT tname FROM _RSERV_SLAVE_TABLES_ Returned 1 tuples Prepare snapshot for tables: t1 Exec: BEGIN LOG: query: BEGIN Exec: set transaction isolation level serializable LOG: query: set transaction isolation level serializable Exec: select pgc.oid, pgc.relname, pga.attname, pgt.typname from _RSERV_TABLES_ rt, pg_class pgc, pg_attribute pga, pg_type pgt where pgc.oid = rt.reloid AND pga.attrelid = rt.reloid AND pga.attnum = rt.key AND pga.atttypid=pgt.oid LOG: query: select pgc.oid, pgc.relname, pga.attname, pgt.typname from _RSERV_TABLES_ rt, pg_class pgc, pg_attribute pga, pg_type pgt where pgc.oid = rt.reloid AND pga.attrelid = rt.reloid AND pga.attnum = rt.key AND pga.atttypid=pgt.oid Returned 1 tuples 270490, t1, uniq Master database table oids: 270490 Exec: select syncid, synctime, minid, maxid, active from _RSERV_SYNC_ where server = 0 AND syncid = (select max(syncid) from _RSERV_SYNC_ where server = 0 AND status > 0) LOG: query: select syncid, synctime, minid, maxid, active from _RSERV_SYNC_ where server = 0 AND syncid = (select max(syncid) from _RSERV_SYNC_ where server = 0 AND status > 0) Returned 0 tuples lastsync: DELETED: select l.reloid, l.key from _RSERV_LOG_ l where l.delete = 1 and l.server = 1 order by l.reloid LOG: query: select l.reloid, l.key from _RSERV_LOG_ l where l.delete = 1 and l.server = 1 order by l.reloid UPDATED: SELECT "_t1".* FROM "t1" "_t1", _RSERV_LOG_ l WHERE l.reloid = 270490 AND l.update = 1 AND "_t1"."uniq"=l.key::int4 and l.server = 1 LOG: query: SELECT "_t1".* FROM "t1" "_t1", _RSERV_LOG_ l WHERE l.reloid = 270490 AND l.update = 1 AND "_t1"."uniq"=l.key::int4 and l.server = 1 INSERTED: SELECT "_t1".* FROM "t1" "_t1", _RSERV_LOG_ l WHERE l.reloid = 270490 AND l.insert = 1 AND "_t1"."uniq"=l.key::int4 and l.server = 1 LOG: query: SELECT "_t1".* FROM "t1" "_t1", _RSERV_LOG_ l WHERE l.reloid = 270490 AND l.insert = 1 AND "_t1"."uniq"=l.key::int4 and l.server = 1 LOG: query: select nextval('_rserv_sync_seq_') -- SYNCID 1 -- INSERT t1 101 101 insert on slave 2003-11-03 23:57:13.599388 1 \. LOG: query: select _rserv_sync_(0) LOG: query: insert into _RSERV_SYNC_ (server, syncid, synctime, status, minid, maxid, active) values (0, currval('_rserv_sync_seq_'), now(), 0, 143677, 143678, '') LOG: query: SELECT 1 FROM ONLY "public"."_rserv_servers_" x WHERE "server" = $1 FOR UPDATE OF x LOG: query: COMMIT -- OK >>>>>>>>>>>>> Apply Snapshot LOG: query: BEGIN LOG: query: SET CONSTRAINTS ALL DEFERRED LOG: query: select pgc.oid, pgc.relname, pga.attname, rt.key from _RSERV_SLAVE_TABLES_ rt, pg_class pgc, pg_attribute pga where pgc.oid = rt.reloid AND pga.attrelid = rt.reloid AND pga.attnum = rt.key Snapshot tables oids: t1 Server ID 1 Sync ID 1 LOG: query: select syncid, synctime from _RSERV_SLAVE_SYNC_ where syncid = (select max(syncid) from _RSERV_SLAVE_SYNC_) Slave Sync ID null Exec: insert into _RSERV_SLAVE_SYNC_ (syncid, synctime) values (1, now()) LOG: query: insert into _RSERV_SLAVE_SYNC_ (syncid, synctime) values (1, now()) 101 101 insert on slave 2003-11-03 23:57:13.599388 1 LOG: query: COPY "t1" FROM STDIN LOG: query: update _RSERV_LOG_ set logid = 143678, logtime = now(), insert = 1, update = 0, delete = 0, server = 0 where reloid = 270481 and key = '1' Exec: select count(*) from _rserv_log_ LOG: query: select count(*) from _rserv_log_ Returned 1 tuples DATA: 2 Exec: select * from _rserv_log_ LOG: query: select * from _rserv_log_ Returned 2 tuples DATA: 270481,143666,2003-11-03 23:57:13.217939,1,0,0,2,0 DATA: 270481,143678,2003-11-03 23:57:15.126528,1,0,0,1,0 Exec: update _rserv_log_ set server=1 where logid = (select _rserv_xid_()) LOG: query: update _rserv_log_ set server=1 where logid = (select _rserv_xid_()) LOG: query: COMMIT Snapshot applied >>>>>>>>>>>>> Sync SyncID Get last SyncID from Slave DB LOG: query: select max(syncid) from _RSERV_SLAVE_SYNC_ GetSyncID: 1 Last SyncID applied: 1 Sync SyncID LOG: query: BEGIN LOG: query: select synctime, status from _RSERV_SYNC_ where server = 0 AND syncid = 1 for update LOG: query: update _RSERV_SYNC_ set synctime = now(), status = 1 where server = 0 AND syncid = 1 LOG: query: delete from _RSERV_SYNC_ where server = 0 AND syncid < 1 LOG: query: COMMIT Succeeded LOG: query: begin; select getdatabaseencoding(); commit LOG: query: select max(syncid) from _RSERV_SLAVE_SYNC_ GetSyncID: 1 LOG: query: begin; select getdatabaseencoding(); commit LOG: query: BEGIN LOG: query: select synctime, status from _RSERV_SYNC_ where server = 1 AND syncid = 1 for update No SyncID 1 found for server 1 LOG: query: ROLLBACK slave -> master over Master connection is dbname=master Slave connection is dbname=slave Connecting to dbname=master LOG: query: begin; select getdatabaseencoding(); commit Connecting to dbname=slave LOG: query: begin; select getdatabaseencoding(); commit GetServerId: host localhost, database slave LOG: query: SELECT server FROM _RSERV_SERVERS_ WHERE host='localhost' AND dbase='slave' GetServerId(slave,localhost) == 1 GetServerId: host localhost, database master LOG: query: SELECT server FROM _RSERV_SERVERS_ WHERE host='localhost' AND dbase='master' GetServerId(master,localhost) == 0 Using snapshot file: .__Snapshot.15342 >>>>>>>>>>>>> Prepare Snapshot master id: 0 slave id: 1 PrepareSnapshot master: 0 slave: 1 Exec: SELECT tname FROM _RSERV_SLAVE_TABLES_ LOG: query: SELECT tname FROM _RSERV_SLAVE_TABLES_ Returned 1 tuples Prepare snapshot for tables: t1 Exec: BEGIN LOG: query: BEGIN Exec: set transaction isolation level serializable LOG: query: set transaction isolation level serializable Exec: select pgc.oid, pgc.relname, pga.attname, pgt.typname from _RSERV_TABLES_ rt, pg_class pgc, pg_attribute pga, pg_type pgt where pgc.oid = rt.reloid AND pga.attrelid = rt.reloid AND pga.attnum = rt.key AND pga.atttypid=pgt.oid LOG: query: select pgc.oid, pgc.relname, pga.attname, pgt.typname from _RSERV_TABLES_ rt, pg_class pgc, pg_attribute pga, pg_type pgt where pgc.oid = rt.reloid AND pga.attrelid = rt.reloid AND pga.attnum = rt.key AND pga.atttypid=pgt.oid Returned 1 tuples 270481, t1, uniq Master database table oids: 270481 Exec: select syncid, synctime, minid, maxid, active from _RSERV_SYNC_ where server = 1 AND syncid = (select max(syncid) from _RSERV_SYNC_ where server = 1 AND status > 0) LOG: query: select syncid, synctime, minid, maxid, active from _RSERV_SYNC_ where server = 1 AND syncid = (select max(syncid) from _RSERV_SYNC_ where server = 1 AND status > 0) Returned 0 tuples lastsync: DELETED: select l.reloid, l.key from _RSERV_LOG_ l where l.delete = 1 and l.server = 0 order by l.reloid LOG: query: select l.reloid, l.key from _RSERV_LOG_ l where l.delete = 1 and l.server = 0 order by l.reloid UPDATED: SELECT "_t1".* FROM "t1" "_t1", _RSERV_LOG_ l WHERE l.reloid = 270481 AND l.update = 1 AND "_t1"."uniq"=l.key::int4 and l.server = 0 LOG: query: SELECT "_t1".* FROM "t1" "_t1", _RSERV_LOG_ l WHERE l.reloid = 270481 AND l.update = 1 AND "_t1"."uniq"=l.key::int4 and l.server = 0 INSERTED: SELECT "_t1".* FROM "t1" "_t1", _RSERV_LOG_ l WHERE l.reloid = 270481 AND l.insert = 1 AND "_t1"."uniq"=l.key::int4 and l.server = 0 LOG: query: SELECT "_t1".* FROM "t1" "_t1", _RSERV_LOG_ l WHERE l.reloid = 270481 AND l.insert = 1 AND "_t1"."uniq"=l.key::int4 and l.server = 0 LOG: query: select nextval('_rserv_sync_seq_') -- SYNCID 1 -- INSERT t1 2 two insert master 2003-11-03 23:57:13.217939 2 \. LOG: query: select _rserv_sync_(1) LOG: query: insert into _RSERV_SYNC_ (server, syncid, synctime, status, minid, maxid, active) values (1, currval('_rserv_sync_seq_'), now(), 0, 143694, 143695, '') LOG: query: SELECT 1 FROM ONLY "public"."_rserv_servers_" x WHERE "server" = $1 FOR UPDATE OF x LOG: query: COMMIT -- OK >>>>>>>>>>>>> Apply Snapshot LOG: query: BEGIN LOG: query: SET CONSTRAINTS ALL DEFERRED LOG: query: select pgc.oid, pgc.relname, pga.attname, rt.key from _RSERV_SLAVE_TABLES_ rt, pg_class pgc, pg_attribute pga where pgc.oid = rt.reloid AND pga.attrelid = rt.reloid AND pga.attnum = rt.key Snapshot tables oids: t1 Server ID 0 Sync ID 1 LOG: query: select syncid, synctime from _RSERV_SLAVE_SYNC_ where syncid = (select max(syncid) from _RSERV_SLAVE_SYNC_) Slave Sync ID null Exec: insert into _RSERV_SLAVE_SYNC_ (syncid, synctime) values (1, now()) LOG: query: insert into _RSERV_SLAVE_SYNC_ (syncid, synctime) values (1, now()) 2 two insert master 2003-11-03 23:57:13.217939 2 LOG: query: COPY "t1" FROM STDIN LOG: query: update _RSERV_LOG_ set logid = 143695, logtime = now(), insert = 1, update = 0, delete = 0, server = 1 where reloid = 270490 and key = '2' LOG: query: insert into _RSERV_LOG_ (reloid, logid, logtime, insert, update, delete, key, server) values (270490, 143695, now(), 1, 0, 0, '2', 1) LOG: query: SELECT 1 FROM ONLY "public"."_rserv_tables_" x WHERE "reloid" = $1 FOR UPDATE OF x Exec: select count(*) from _rserv_log_ LOG: query: select count(*) from _rserv_log_ Returned 1 tuples DATA: 2 Exec: select * from _rserv_log_ LOG: query: select * from _rserv_log_ Returned 2 tuples DATA: 270490,143669,2003-11-03 23:57:13.599388,1,0,0,1,1 DATA: 270490,143695,2003-11-03 23:57:18.026583,1,0,0,2,1 Exec: update _rserv_log_ set server=0 where logid = (select _rserv_xid_()) LOG: query: update _rserv_log_ set server=0 where logid = (select _rserv_xid_()) LOG: query: COMMIT Snapshot applied >>>>>>>>>>>>> Sync SyncID Get last SyncID from Slave DB LOG: query: select max(syncid) from _RSERV_SLAVE_SYNC_ GetSyncID: 1 Last SyncID applied: 1 Sync SyncID LOG: query: BEGIN LOG: query: select synctime, status from _RSERV_SYNC_ where server = 1 AND syncid = 1 for update LOG: query: update _RSERV_SYNC_ set synctime = now(), status = 1 where server = 1 AND syncid = 1 LOG: query: delete from _RSERV_SYNC_ where server = 1 AND syncid < 1 LOG: query: COMMIT Succeeded LOG: query: begin; select getdatabaseencoding(); commit LOG: query: select max(syncid) from _RSERV_SLAVE_SYNC_ GetSyncID: 1 LOG: query: begin; select getdatabaseencoding(); commit LOG: query: BEGIN LOG: query: select synctime, status from _RSERV_SYNC_ where server = 1 AND syncid = 1 for update SyncID 1 for server 1 already updated LOG: query: ROLLBACK master -> slave over Master connection is dbname=slave Slave connection is dbname=master Connecting to dbname=slave LOG: query: begin; select getdatabaseencoding(); commit Connecting to dbname=master LOG: query: begin; select getdatabaseencoding(); commit GetServerId: host localhost, database master LOG: query: SELECT server FROM _RSERV_SERVERS_ WHERE host='localhost' AND dbase='master' GetServerId(master,localhost) == 0 GetServerId: host localhost, database slave LOG: query: SELECT server FROM _RSERV_SERVERS_ WHERE host='localhost' AND dbase='slave' GetServerId(slave,localhost) == 1 Using snapshot file: .__Snapshot.15350 >>>>>>>>>>>>> Prepare Snapshot master id: 1 slave id: 0 PrepareSnapshot master: 1 slave: 0 Exec: SELECT tname FROM _RSERV_SLAVE_TABLES_ LOG: query: SELECT tname FROM _RSERV_SLAVE_TABLES_ Returned 1 tuples Prepare snapshot for tables: t1 Exec: BEGIN LOG: query: BEGIN Exec: set transaction isolation level serializable LOG: query: set transaction isolation level serializable Exec: select pgc.oid, pgc.relname, pga.attname, pgt.typname from _RSERV_TABLES_ rt, pg_class pgc, pg_attribute pga, pg_type pgt where pgc.oid = rt.reloid AND pga.attrelid = rt.reloid AND pga.attnum = rt.key AND pga.atttypid=pgt.oid LOG: query: select pgc.oid, pgc.relname, pga.attname, pgt.typname from _RSERV_TABLES_ rt, pg_class pgc, pg_attribute pga, pg_type pgt where pgc.oid = rt.reloid AND pga.attrelid = rt.reloid AND pga.attnum = rt.key AND pga.atttypid=pgt.oid Returned 1 tuples 270490, t1, uniq Master database table oids: 270490 Exec: select syncid, synctime, minid, maxid, active from _RSERV_SYNC_ where server = 0 AND syncid = (select max(syncid) from _RSERV_SYNC_ where server = 0 AND status > 0) LOG: query: select syncid, synctime, minid, maxid, active from _RSERV_SYNC_ where server = 0 AND syncid = (select max(syncid) from _RSERV_SYNC_ where server = 0 AND status > 0) Returned 1 tuples lastsync: 1,2003-11-03 23:57:15.415196,143677,143678, DELETED: select l.reloid, l.key from _RSERV_LOG_ l where l.delete = 1 and (l.logid >= 143678) and l.server = 1 order by l.reloid LOG: query: select l.reloid, l.key from _RSERV_LOG_ l where l.delete = 1 and (l.logid >= 143678) and l.server = 1 order by l.reloid UPDATED: SELECT "_t1".* FROM "t1" "_t1", _RSERV_LOG_ l WHERE l.reloid = 270490 AND l.update = 1 and (l.logid >= 143678) AND "_t1"."uniq"=l.key::int4 and l.server = 1 LOG: query: SELECT "_t1".* FROM "t1" "_t1", _RSERV_LOG_ l WHERE l.reloid = 270490 AND l.update = 1 and (l.logid >= 143678) AND "_t1"."uniq"=l.key::int4 and l.server = 1 INSERTED: SELECT "_t1".* FROM "t1" "_t1", _RSERV_LOG_ l WHERE l.reloid = 270490 AND l.insert = 1 and (l.logid >= 143678) AND "_t1"."uniq"=l.key::int4 and l.server = 1 LOG: query: SELECT "_t1".* FROM "t1" "_t1", _RSERV_LOG_ l WHERE l.reloid = 270490 AND l.insert = 1 and (l.logid >= 143678) AND "_t1"."uniq"=l.key::int4 and l.server = 1 hon't have deal, rollback... LOG: query: ROLLBACK >>>>>>>>>>>>> DBases are sync-ed LOG: query: begin; select getdatabaseencoding(); commit LOG: query: select max(syncid) from _RSERV_SLAVE_SYNC_ GetSyncID: 1 LOG: query: begin; select getdatabaseencoding(); commit LOG: query: BEGIN LOG: query: select synctime, status from _RSERV_SYNC_ where server = 1 AND syncid = 1 for update No SyncID 1 found for server 1 LOG: query: ROLLBACK slave -> master over LOG: query: begin; select getdatabaseencoding(); commit insert into t1 values (3, 'three insert on master'); LOG: query: insert into t1 values (3, 'three insert on master'); LOG: query: update _RSERV_LOG_ set logid = 143720, logtime = now(), insert = 1, update = 0, delete = 0, server = 0 where reloid = 270481 and key = '3' LOG: query: insert into _RSERV_LOG_ (reloid, logid, logtime, insert, update, delete, key, server) values (270481, 143720, now(), 1, 0, 0, '3', 0) LOG: query: SELECT 1 FROM ONLY "public"."_rserv_tables_" x WHERE "reloid" = $1 FOR UPDATE OF x INSERT 270516 1 LOG: query: begin; select getdatabaseencoding(); commit insert into t1 values (4, 'four insert on slave'); LOG: query: insert into t1 values (4, 'four insert on slave'); LOG: query: update _RSERV_LOG_ set logid = 143723, logtime = now(), insert = 1, update = 0, delete = 0, server = 0 where reloid = 270481 and key = '4' LOG: query: insert into _RSERV_LOG_ (reloid, logid, logtime, insert, update, delete, key, server) values (270481, 143723, now(), 1, 0, 0, '4', 0) LOG: query: SELECT 1 FROM ONLY "public"."_rserv_tables_" x WHERE "reloid" = $1 FOR UPDATE OF x INSERT 270518 1 LOG: query: begin; select getdatabaseencoding(); commit delete from t1 where i=1; LOG: query: delete from t1 where i=1; LOG: query: update _RSERV_LOG_ set logid = 143726, logtime = now(), insert = 0, update = 0, delete = 1, server = 0 where reloid = 270481 and key = '1' DELETE 1 LOG: query: begin; select getdatabaseencoding(); commit update t1 set t='two, updated on master' where i=2; LOG: query: update t1 set t='two, updated on master' where i=2; LOG: query: update _RSERV_LOG_ set logid = 143729, logtime = now(), insert = 0, update = 1, delete = 0, server = 0 where reloid = 270481 and key = '2' UPDATE 1 LOG: query: begin; select getdatabaseencoding(); commit delete from t1 where i=4; LOG: query: delete from t1 where i=4; DELETE 0 LOG: query: begin; select getdatabaseencoding(); commit update t1 set t='two, updated on slave (conflict)' where i=2; LOG: query: update t1 set t='two, updated on slave (conflict)' where i=2; LOG: query: update _RSERV_LOG_ set logid = 143735, logtime = now(), insert = 0, update = 1, delete = 0, server = 1 where reloid = 270490 and key = '2' UPDATE 1 Master connection is dbname=master Slave connection is dbname=slave Connecting to dbname=master LOG: query: begin; select getdatabaseencoding(); commit Connecting to dbname=slave LOG: query: begin; select getdatabaseencoding(); commit GetServerId: host localhost, database slave LOG: query: SELECT server FROM _RSERV_SERVERS_ WHERE host='localhost' AND dbase='slave' GetServerId(slave,localhost) == 1 GetServerId: host localhost, database master LOG: query: SELECT server FROM _RSERV_SERVERS_ WHERE host='localhost' AND dbase='master' GetServerId(master,localhost) == 0 Using snapshot file: .__Snapshot.15406 >>>>>>>>>>>>> Prepare Snapshot master id: 0 slave id: 1 PrepareSnapshot master: 0 slave: 1 Exec: SELECT tname FROM _RSERV_SLAVE_TABLES_ LOG: query: SELECT tname FROM _RSERV_SLAVE_TABLES_ Returned 1 tuples Prepare snapshot for tables: t1 Exec: BEGIN LOG: query: BEGIN Exec: set transaction isolation level serializable LOG: query: set transaction isolation level serializable Exec: select pgc.oid, pgc.relname, pga.attname, pgt.typname from _RSERV_TABLES_ rt, pg_class pgc, pg_attribute pga, pg_type pgt where pgc.oid = rt.reloid AND pga.attrelid = rt.reloid AND pga.attnum = rt.key AND pga.atttypid=pgt.oid LOG: query: select pgc.oid, pgc.relname, pga.attname, pgt.typname from _RSERV_TABLES_ rt, pg_class pgc, pg_attribute pga, pg_type pgt where pgc.oid = rt.reloid AND pga.attrelid = rt.reloid AND pga.attnum = rt.key AND pga.atttypid=pgt.oid Returned 1 tuples 270481, t1, uniq Master database table oids: 270481 Exec: select syncid, synctime, minid, maxid, active from _RSERV_SYNC_ where server = 1 AND syncid = (select max(syncid) from _RSERV_SYNC_ where server = 1 AND status > 0) LOG: query: select syncid, synctime, minid, maxid, active from _RSERV_SYNC_ where server = 1 AND syncid = (select max(syncid) from _RSERV_SYNC_ where server = 1 AND status > 0) Returned 1 tuples lastsync: 1,2003-11-03 23:57:18.375849,143694,143695, DELETED: select l.reloid, l.key from _RSERV_LOG_ l where l.delete = 1 and (l.logid >= 143695) and l.server = 0 order by l.reloid LOG: query: select l.reloid, l.key from _RSERV_LOG_ l where l.delete = 1 and (l.logid >= 143695) and l.server = 0 order by l.reloid LOG: query: select nextval('_rserv_sync_seq_') -- SYNCID 2 UPDATED: SELECT "_t1".* FROM "t1" "_t1", _RSERV_LOG_ l WHERE l.reloid = 270481 AND l.update = 1 and (l.logid >= 143695) AND "_t1"."uniq"=l.key::int4 and l.server = 0 LOG: query: SELECT "_t1".* FROM "t1" "_t1", _RSERV_LOG_ l WHERE l.reloid = 270481 AND l.update = 1 and (l.logid >= 143695) AND "_t1"."uniq"=l.key::int4 and l.server = 0 -- UPDATE t1 2 two, updated on master 2003-11-03 23:57:13.217939 2 \. INSERTED: SELECT "_t1".* FROM "t1" "_t1", _RSERV_LOG_ l WHERE l.reloid = 270481 AND l.insert = 1 and (l.logid >= 143695) AND "_t1"."uniq"=l.key::int4 and l.server = 0 LOG: query: SELECT "_t1".* FROM "t1" "_t1", _RSERV_LOG_ l WHERE l.reloid = 270481 AND l.insert = 1 and (l.logid >= 143695) AND "_t1"."uniq"=l.key::int4 and l.server = 0 -- INSERT t1 3 three insert on master 2003-11-03 23:57:22.52413 3 4 four insert on slave 2003-11-03 23:57:22.887708 4 \. LOG: query: select _rserv_sync_(1) LOG: query: insert into _RSERV_SYNC_ (server, syncid, synctime, status, minid, maxid, active) values (1, currval('_rserv_sync_seq_'), now(), 0, 143743, 143744, '') LOG: query: SELECT 1 FROM ONLY "public"."_rserv_servers_" x WHERE "server" = $1 FOR UPDATE OF x LOG: query: COMMIT -- OK >>>>>>>>>>>>> Apply Snapshot LOG: query: BEGIN LOG: query: SET CONSTRAINTS ALL DEFERRED LOG: query: select pgc.oid, pgc.relname, pga.attname, rt.key from _RSERV_SLAVE_TABLES_ rt, pg_class pgc, pg_attribute pga where pgc.oid = rt.reloid AND pga.attrelid = rt.reloid AND pga.attnum = rt.key Snapshot tables oids: t1 Server ID 0 Sync ID 2 LOG: query: select syncid, synctime from _RSERV_SLAVE_SYNC_ where syncid = (select max(syncid) from _RSERV_SLAVE_SYNC_) Slave Sync ID 1 Exec: update _RSERV_SLAVE_SYNC_ set syncid = 2, synctime = now() LOG: query: update _RSERV_SLAVE_SYNC_ set syncid = 2, synctime = now() delete from "t1" where "uniq" = '1' LOG: query: delete from "t1" where "uniq" = '1' LOG: query: update _RSERV_LOG_ set logid = 143744, logtime = now(), insert = 0, update = 0, delete = 1, server = 1 where reloid = 270490 and key = '1' LOG: query: select attnum, attname from pg_attribute where attrelid = 270490 AND attnum > 0 update "t1" set "i" = '2', "t" = 'two, updated on master', "d" = '2003-11-03 23:57:13.217939' where "uniq" = '2' LOG: query: update "t1" set "i" = '2', "t" = 'two, updated on master', "d" = '2003-11-03 23:57:13.217939' where "uniq" = '2' LOG: query: update _RSERV_LOG_ set logid = 143744, logtime = now(), insert = 0, update = 1, delete = 0, server = 1 where reloid = 270490 and key = '2' 3 three insert on master 2003-11-03 23:57:22.52413 3 4 four insert on slave 2003-11-03 23:57:22.887708 4 LOG: query: COPY "t1" FROM STDIN LOG: query: update _RSERV_LOG_ set logid = 143744, logtime = now(), insert = 1, update = 0, delete = 0, server = 1 where reloid = 270490 and key = '3' LOG: query: insert into _RSERV_LOG_ (reloid, logid, logtime, insert, update, delete, key, server) values (270490, 143744, now(), 1, 0, 0, '3', 1) LOG: query: update _RSERV_LOG_ set logid = 143744, logtime = now(), insert = 1, update = 0, delete = 0, server = 1 where reloid = 270490 and key = '4' LOG: query: insert into _RSERV_LOG_ (reloid, logid, logtime, insert, update, delete, key, server) values (270490, 143744, now(), 1, 0, 0, '4', 1) LOG: query: SELECT 1 FROM ONLY "public"."_rserv_tables_" x WHERE "reloid" = $1 FOR UPDATE OF x Exec: select count(*) from _rserv_log_ LOG: query: select count(*) from _rserv_log_ Returned 1 tuples DATA: 4 Exec: select * from _rserv_log_ LOG: query: select * from _rserv_log_ Returned 4 tuples DATA: 270490,143744,2003-11-03 23:57:25.4952,0,0,1,1,1 DATA: 270490,143744,2003-11-03 23:57:25.4952,0,1,0,2,1 DATA: 270490,143744,2003-11-03 23:57:25.4952,1,0,0,3,1 DATA: 270490,143744,2003-11-03 23:57:25.4952,1,0,0,4,1 Exec: update _rserv_log_ set server=0 where logid = (select _rserv_xid_()) LOG: query: update _rserv_log_ set server=0 where logid = (select _rserv_xid_()) LOG: query: COMMIT Snapshot applied >>>>>>>>>>>>> Sync SyncID Get last SyncID from Slave DB LOG: query: select max(syncid) from _RSERV_SLAVE_SYNC_ GetSyncID: 2 Last SyncID applied: 2 Sync SyncID LOG: query: BEGIN LOG: query: select synctime, status from _RSERV_SYNC_ where server = 1 AND syncid = 2 for update LOG: query: update _RSERV_SYNC_ set synctime = now(), status = 1 where server = 1 AND syncid = 2 LOG: query: delete from _RSERV_SYNC_ where server = 1 AND syncid < 2 LOG: query: COMMIT Succeeded LOG: query: begin; select getdatabaseencoding(); commit LOG: query: select max(syncid) from _RSERV_SLAVE_SYNC_ GetSyncID: 2 LOG: query: begin; select getdatabaseencoding(); commit LOG: query: BEGIN LOG: query: select synctime, status from _RSERV_SYNC_ where server = 1 AND syncid = 2 for update SyncID 2 for server 1 already updated LOG: query: ROLLBACK master -> slave over Master connection is dbname=slave Slave connection is dbname=master Connecting to dbname=slave LOG: query: begin; select getdatabaseencoding(); commit Connecting to dbname=master LOG: query: begin; select getdatabaseencoding(); commit GetServerId: host localhost, database master LOG: query: SELECT server FROM _RSERV_SERVERS_ WHERE host='localhost' AND dbase='master' GetServerId(master,localhost) == 0 GetServerId: host localhost, database slave LOG: query: SELECT server FROM _RSERV_SERVERS_ WHERE host='localhost' AND dbase='slave' GetServerId(slave,localhost) == 1 Using snapshot file: .__Snapshot.15414 >>>>>>>>>>>>> Prepare Snapshot master id: 1 slave id: 0 PrepareSnapshot master: 1 slave: 0 Exec: SELECT tname FROM _RSERV_SLAVE_TABLES_ LOG: query: SELECT tname FROM _RSERV_SLAVE_TABLES_ Returned 1 tuples Prepare snapshot for tables: t1 Exec: BEGIN LOG: query: BEGIN Exec: set transaction isolation level serializable LOG: query: set transaction isolation level serializable Exec: select pgc.oid, pgc.relname, pga.attname, pgt.typname from _RSERV_TABLES_ rt, pg_class pgc, pg_attribute pga, pg_type pgt where pgc.oid = rt.reloid AND pga.attrelid = rt.reloid AND pga.attnum = rt.key AND pga.atttypid=pgt.oid LOG: query: select pgc.oid, pgc.relname, pga.attname, pgt.typname from _RSERV_TABLES_ rt, pg_class pgc, pg_attribute pga, pg_type pgt where pgc.oid = rt.reloid AND pga.attrelid = rt.reloid AND pga.attnum = rt.key AND pga.atttypid=pgt.oid Returned 1 tuples 270490, t1, uniq Master database table oids: 270490 Exec: select syncid, synctime, minid, maxid, active from _RSERV_SYNC_ where server = 0 AND syncid = (select max(syncid) from _RSERV_SYNC_ where server = 0 AND status > 0) LOG: query: select syncid, synctime, minid, maxid, active from _RSERV_SYNC_ where server = 0 AND syncid = (select max(syncid) from _RSERV_SYNC_ where server = 0 AND status > 0) Returned 1 tuples lastsync: 1,2003-11-03 23:57:15.415196,143677,143678, DELETED: select l.reloid, l.key from _RSERV_LOG_ l where l.delete = 1 and (l.logid >= 143678) and l.server = 1 order by l.reloid LOG: query: select l.reloid, l.key from _RSERV_LOG_ l where l.delete = 1 and (l.logid >= 143678) and l.server = 1 order by l.reloid UPDATED: SELECT "_t1".* FROM "t1" "_t1", _RSERV_LOG_ l WHERE l.reloid = 270490 AND l.update = 1 and (l.logid >= 143678) AND "_t1"."uniq"=l.key::int4 and l.server = 1 LOG: query: SELECT "_t1".* FROM "t1" "_t1", _RSERV_LOG_ l WHERE l.reloid = 270490 AND l.update = 1 and (l.logid >= 143678) AND "_t1"."uniq"=l.key::int4 and l.server = 1 INSERTED: SELECT "_t1".* FROM "t1" "_t1", _RSERV_LOG_ l WHERE l.reloid = 270490 AND l.insert = 1 and (l.logid >= 143678) AND "_t1"."uniq"=l.key::int4 and l.server = 1 LOG: query: SELECT "_t1".* FROM "t1" "_t1", _RSERV_LOG_ l WHERE l.reloid = 270490 AND l.insert = 1 and (l.logid >= 143678) AND "_t1"."uniq"=l.key::int4 and l.server = 1 hon't have deal, rollback... LOG: query: ROLLBACK >>>>>>>>>>>>> DBases are sync-ed LOG: query: begin; select getdatabaseencoding(); commit LOG: query: select max(syncid) from _RSERV_SLAVE_SYNC_ GetSyncID: 1 LOG: query: begin; select getdatabaseencoding(); commit LOG: query: BEGIN LOG: query: select synctime, status from _RSERV_SYNC_ where server = 1 AND syncid = 1 for update No SyncID 1 found for server 1 LOG: query: ROLLBACK slave -> master over Master connection is dbname=master Slave connection is dbname=slave Connecting to dbname=master LOG: query: begin; select getdatabaseencoding(); commit Connecting to dbname=slave LOG: query: begin; select getdatabaseencoding(); commit GetServerId: host localhost, database slave LOG: query: SELECT server FROM _RSERV_SERVERS_ WHERE host='localhost' AND dbase='slave' GetServerId(slave,localhost) == 1 GetServerId: host localhost, database master LOG: query: SELECT server FROM _RSERV_SERVERS_ WHERE host='localhost' AND dbase='master' GetServerId(master,localhost) == 0 Using snapshot file: .__Snapshot.15422 >>>>>>>>>>>>> Prepare Snapshot master id: 0 slave id: 1 PrepareSnapshot master: 0 slave: 1 Exec: SELECT tname FROM _RSERV_SLAVE_TABLES_ LOG: query: SELECT tname FROM _RSERV_SLAVE_TABLES_ Returned 1 tuples Prepare snapshot for tables: t1 Exec: BEGIN LOG: query: BEGIN Exec: set transaction isolation level serializable LOG: query: set transaction isolation level serializable Exec: select pgc.oid, pgc.relname, pga.attname, pgt.typname from _RSERV_TABLES_ rt, pg_class pgc, pg_attribute pga, pg_type pgt where pgc.oid = rt.reloid AND pga.attrelid = rt.reloid AND pga.attnum = rt.key AND pga.atttypid=pgt.oid LOG: query: select pgc.oid, pgc.relname, pga.attname, pgt.typname from _RSERV_TABLES_ rt, pg_class pgc, pg_attribute pga, pg_type pgt where pgc.oid = rt.reloid AND pga.attrelid = rt.reloid AND pga.attnum = rt.key AND pga.atttypid=pgt.oid Returned 1 tuples 270481, t1, uniq Master database table oids: 270481 Exec: select syncid, synctime, minid, maxid, active from _RSERV_SYNC_ where server = 1 AND syncid = (select max(syncid) from _RSERV_SYNC_ where server = 1 AND status > 0) LOG: query: select syncid, synctime, minid, maxid, active from _RSERV_SYNC_ where server = 1 AND syncid = (select max(syncid) from _RSERV_SYNC_ where server = 1 AND status > 0) Returned 1 tuples lastsync: 2,2003-11-03 23:57:25.946997,143743,143744, DELETED: select l.reloid, l.key from _RSERV_LOG_ l where l.delete = 1 and (l.logid >= 143744) and l.server = 0 order by l.reloid LOG: query: select l.reloid, l.key from _RSERV_LOG_ l where l.delete = 1 and (l.logid >= 143744) and l.server = 0 order by l.reloid UPDATED: SELECT "_t1".* FROM "t1" "_t1", _RSERV_LOG_ l WHERE l.reloid = 270481 AND l.update = 1 and (l.logid >= 143744) AND "_t1"."uniq"=l.key::int4 and l.server = 0 LOG: query: SELECT "_t1".* FROM "t1" "_t1", _RSERV_LOG_ l WHERE l.reloid = 270481 AND l.update = 1 and (l.logid >= 143744) AND "_t1"."uniq"=l.key::int4 and l.server = 0 INSERTED: SELECT "_t1".* FROM "t1" "_t1", _RSERV_LOG_ l WHERE l.reloid = 270481 AND l.insert = 1 and (l.logid >= 143744) AND "_t1"."uniq"=l.key::int4 and l.server = 0 LOG: query: SELECT "_t1".* FROM "t1" "_t1", _RSERV_LOG_ l WHERE l.reloid = 270481 AND l.insert = 1 and (l.logid >= 143744) AND "_t1"."uniq"=l.key::int4 and l.server = 0 hon't have deal, rollback... LOG: query: ROLLBACK >>>>>>>>>>>>> DBases are sync-ed Master connection is dbname=slave Slave connection is dbname=master Connecting to dbname=slave LOG: query: begin; select getdatabaseencoding(); commit Connecting to dbname=master LOG: query: begin; select getdatabaseencoding(); commit GetServerId: host localhost, database master LOG: query: SELECT server FROM _RSERV_SERVERS_ WHERE host='localhost' AND dbase='master' GetServerId(master,localhost) == 0 GetServerId: host localhost, database slave LOG: query: SELECT server FROM _RSERV_SERVERS_ WHERE host='localhost' AND dbase='slave' GetServerId(slave,localhost) == 1 Using snapshot file: .__Snapshot.15425 >>>>>>>>>>>>> Prepare Snapshot master id: 1 slave id: 0 PrepareSnapshot master: 1 slave: 0 Exec: SELECT tname FROM _RSERV_SLAVE_TABLES_ LOG: query: SELECT tname FROM _RSERV_SLAVE_TABLES_ Returned 1 tuples Prepare snapshot for tables: t1 Exec: BEGIN LOG: query: BEGIN Exec: set transaction isolation level serializable LOG: query: set transaction isolation level serializable Exec: select pgc.oid, pgc.relname, pga.attname, pgt.typname from _RSERV_TABLES_ rt, pg_class pgc, pg_attribute pga, pg_type pgt where pgc.oid = rt.reloid AND pga.attrelid = rt.reloid AND pga.attnum = rt.key AND pga.atttypid=pgt.oid LOG: query: select pgc.oid, pgc.relname, pga.attname, pgt.typname from _RSERV_TABLES_ rt, pg_class pgc, pg_attribute pga, pg_type pgt where pgc.oid = rt.reloid AND pga.attrelid = rt.reloid AND pga.attnum = rt.key AND pga.atttypid=pgt.oid Returned 1 tuples 270490, t1, uniq Master database table oids: 270490 Exec: select syncid, synctime, minid, maxid, active from _RSERV_SYNC_ where server = 0 AND syncid = (select max(syncid) from _RSERV_SYNC_ where server = 0 AND status > 0) LOG: query: select syncid, synctime, minid, maxid, active from _RSERV_SYNC_ where server = 0 AND syncid = (select max(syncid) from _RSERV_SYNC_ where server = 0 AND status > 0) Returned 1 tuples lastsync: 1,2003-11-03 23:57:15.415196,143677,143678, DELETED: select l.reloid, l.key from _RSERV_LOG_ l where l.delete = 1 and (l.logid >= 143678) and l.server = 1 order by l.reloid LOG: query: select l.reloid, l.key from _RSERV_LOG_ l where l.delete = 1 and (l.logid >= 143678) and l.server = 1 order by l.reloid UPDATED: SELECT "_t1".* FROM "t1" "_t1", _RSERV_LOG_ l WHERE l.reloid = 270490 AND l.update = 1 and (l.logid >= 143678) AND "_t1"."uniq"=l.key::int4 and l.server = 1 LOG: query: SELECT "_t1".* FROM "t1" "_t1", _RSERV_LOG_ l WHERE l.reloid = 270490 AND l.update = 1 and (l.logid >= 143678) AND "_t1"."uniq"=l.key::int4 and l.server = 1 INSERTED: SELECT "_t1".* FROM "t1" "_t1", _RSERV_LOG_ l WHERE l.reloid = 270490 AND l.insert = 1 and (l.logid >= 143678) AND "_t1"."uniq"=l.key::int4 and l.server = 1 LOG: query: SELECT "_t1".* FROM "t1" "_t1", _RSERV_LOG_ l WHERE l.reloid = 270490 AND l.insert = 1 and (l.logid >= 143678) AND "_t1"."uniq"=l.key::int4 and l.server = 1 hon't have deal, rollback... LOG: query: ROLLBACK >>>>>>>>>>>>> DBases are sync-ed LOG: query: begin; select getdatabaseencoding(); commit LOG: query: begin; select getdatabaseencoding(); commit LOG: query: SELECT c.relname as table FROM pg_catalog.pg_class c LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace WHERE c.relkind = 'r' AND n.nspname NOT IN ('pg_catalog', 'pg_toast') AND pg_catalog.pg_table_is_visible(c.oid) and c.relname not like '_rserv_%' begin work; LOG: query: SELECT tgname FROM pg_trigger WHERE tgname not like 'pg_%' and tgenabled IS TRUE update pg_trigger set tgenabled = false where tgname='RI_ConstraintTrigger_270412'; update pg_trigger set tgenabled = false where tgname='RI_ConstraintTrigger_270413'; update pg_trigger set tgenabled = false where tgname='RI_ConstraintTrigger_270414'; update pg_trigger set tgenabled = false where tgname='RI_ConstraintTrigger_270452'; update pg_trigger set tgenabled = false where tgname='RI_ConstraintTrigger_270453'; update pg_trigger set tgenabled = false where tgname='RI_ConstraintTrigger_270454'; update pg_trigger set tgenabled = false where tgname='_rserv_trigger_t_'; -- schema... LOG: query: SELECT c.oid, n.nspname, c.relname FROM pg_catalog.pg_class c LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace WHERE pg_catalog.pg_table_is_visible(c.oid) AND c.relname = 't1' ORDER BY 2, 3 LOG: query: SELECT a.attname, pg_catalog.format_type(a.atttypid, a.atttypmod) as format_type, a.attnotnull, a.atthasdef, a.attnum FROM pg_catalog.pg_attribute a WHERE a.attrelid = '270481' AND a.attnum > 0 AND NOT a.attisdropped ORDER BY a.attnum LOG: query: SELECT adsrc as def FROM pg_catalog.pg_attrdef WHERE adrelid = '270481' and adnum='3' LOG: query: SELECT adsrc as def FROM pg_catalog.pg_attrdef WHERE adrelid = '270481' and adnum='4' LOG: query: SELECT i.indexrelid as indexrelid, i.indrelid as indrelid, count(a.attname) as cols_in_pk FROM pg_catalog.pg_class c, pg_catalog.pg_index i, pg_catalog.pg_attribute a WHERE c.oid = i.indrelid and i.indisunique and c.relname = 't1' and a.attrelid = i.indexrelid GROUP BY i.indexrelid, i.indrelid, c.relname, i.indisprimary, i.indisunique ORDER BY cols_in_pk ASC, i.indisprimary DESC, i.indisunique DESC, c.relname DESC LOG: query: SELECT t.tgname FROM pg_catalog.pg_trigger t WHERE t.tgrelid = '270481' and (not tgisconstraint OR NOT EXISTS (SELECT 1 FROM pg_catalog.pg_depend d JOIN pg_catalog.pg_constraint c ON (d.refclassid = c.tableoid AND d.refobjid = c.oid) WHERE d.classid = t.tableoid AND d.objid = t.oid AND d.deptype = 'i' AND c.contype = 'f')) -- constraints... -- triggers... can't find PK rows for table 't1' using all table 't1' using for key: (i, t, d, uniq) to compare cols: (i, t, d, uniq) LOG: query: select i,t,d,uniq from t1 order by i asc, t asc, d asc, uniq asc LOG: query: select i,t,d,uniq from t1 order by i asc, t asc, d asc, uniq asc MISSING row in table 't1' pk: [i,t,d,uniq] value (101) insert into t1 (i,t,d,uniq) values ('101','101 insert on slave','2003-11-03 23:57:13.599388','1'); 1 differences in table t1 1 differences in all tables update pg_trigger set tgenabled = true where tgname='RI_ConstraintTrigger_270412'; update pg_trigger set tgenabled = true where tgname='RI_ConstraintTrigger_270413'; update pg_trigger set tgenabled = true where tgname='RI_ConstraintTrigger_270414'; update pg_trigger set tgenabled = true where tgname='RI_ConstraintTrigger_270452'; update pg_trigger set tgenabled = true where tgname='RI_ConstraintTrigger_270453'; update pg_trigger set tgenabled = true where tgname='RI_ConstraintTrigger_270454'; update pg_trigger set tgenabled = true where tgname='_rserv_trigger_t_'; commit;