diff options
| -rw-r--r-- | python/londiste/playback.py | 9 | ||||
| -rw-r--r-- | python/londiste/table_copy.py | 2 | ||||
| -rw-r--r-- | sql/londiste/functions/londiste.get_table_list.sql | 8 | ||||
| -rw-r--r-- | sql/londiste/functions/londiste.local_remove_table.sql | 1 | ||||
| -rw-r--r-- | sql/londiste/functions/londiste.local_set_table_attrs.sql | 35 | ||||
| -rw-r--r-- | sql/londiste/functions/londiste.local_set_table_state.sql | 7 | ||||
| -rw-r--r-- | sql/londiste/structure/functions.sql | 2 | ||||
| -rw-r--r-- | sql/londiste/structure/tables.sql | 4 |
8 files changed, 51 insertions, 17 deletions
diff --git a/python/londiste/playback.py b/python/londiste/playback.py index d9db6fd1..ea55975a 100644 --- a/python/londiste/playback.py +++ b/python/londiste/playback.py @@ -66,7 +66,7 @@ class TableState(object): self.sync_tick_id = None self.ok_batch_count = 0 self.last_tick = 0 - self.skip_truncate = False + self.table_attrs = {} self.copy_role = None self.dropped_ddl = None # except this @@ -81,7 +81,7 @@ class TableState(object): self.sync_tick_id = None self.ok_batch_count = 0 self.last_tick = 0 - self.skip_truncate = False + self.table_attrs = {} self.changed = 1 def change_snapshot(self, str_snapshot, tag_changed = 1): @@ -162,7 +162,10 @@ class TableState(object): self.change_snapshot(row['custom_snapshot'], 0) self.state = self.parse_state(row['merge_state']) self.changed = 0 - self.skip_truncate = row['skip_truncate'] + if row['table_attrs']: + self.table_attrs = skytools.db_urldecode(row['table_attrs']) + else: + self.table_attrs = {} self.copy_role = row['copy_role'] self.dropped_ddl = row['dropped_ddl'] if row['merge_state'] == "?": diff --git a/python/londiste/table_copy.py b/python/londiste/table_copy.py index d90e00ae..75d92f56 100644 --- a/python/londiste/table_copy.py +++ b/python/londiste/table_copy.py @@ -121,7 +121,7 @@ class CopyTable(Replicator): dst_struct.drop(dst_curs, objs, log = self.log) # drop data - if tbl_stat.skip_truncate: + if tbl_stat.table_attrs.get('skip_truncate'): self.log.info("%s: skipping truncate" % tbl_stat.name) else: self.log.info("%s: truncating" % tbl_stat.name) diff --git a/sql/londiste/functions/londiste.get_table_list.sql b/sql/londiste/functions/londiste.get_table_list.sql index 0f77e1c4..813ce566 100644 --- a/sql/londiste/functions/londiste.get_table_list.sql +++ b/sql/londiste/functions/londiste.get_table_list.sql @@ -5,7 +5,7 @@ create or replace function londiste.get_table_list( out local boolean, out merge_state text, out custom_snapshot text, - out skip_truncate bool, + out table_attrs text, out dropped_ddl text, out copy_role text) returns setof record as $$ @@ -22,7 +22,7 @@ returns setof record as $$ -- local - does events needs to be applied to local table -- merge_state - show phase of initial copy -- custom_snapshot - remote snapshot of COPY transaction --- skip_truncate - don't truncate table on copy +-- table_attrs - urlencoded dict of table attributes -- dropped_ddl - partition combining: temp place to put DDL -- copy_role - partition combining: how to handle copy -- @@ -58,8 +58,8 @@ begin where n.combined_queue = q_target; end if; - for table_name, local, merge_state, custom_snapshot, skip_truncate, dropped_ddl in - select t.table_name, t.local, t.merge_state, t.custom_snapshot, t.skip_truncate, t.dropped_ddl + for table_name, local, merge_state, custom_snapshot, table_attrs, dropped_ddl in + select t.table_name, t.local, t.merge_state, t.custom_snapshot, t.table_attrs, t.dropped_ddl from londiste.table_info t where t.queue_name = i_queue_name order by t.nr, t.table_name diff --git a/sql/londiste/functions/londiste.local_remove_table.sql b/sql/londiste/functions/londiste.local_remove_table.sql index 6ba99938..d4f4aea2 100644 --- a/sql/londiste/functions/londiste.local_remove_table.sql +++ b/sql/londiste/functions/londiste.local_remove_table.sql @@ -44,6 +44,7 @@ begin ---- should we keep those? -- skip_truncate = null, + -- table_attrs = null, -- dropped_ddl = null, merge_state = null where queue_name = i_queue_name diff --git a/sql/londiste/functions/londiste.local_set_table_attrs.sql b/sql/londiste/functions/londiste.local_set_table_attrs.sql new file mode 100644 index 00000000..a82f8c47 --- /dev/null +++ b/sql/londiste/functions/londiste.local_set_table_attrs.sql @@ -0,0 +1,35 @@ + +create or replace function londiste.local_set_table_attrs( + in i_queue_name text, + in i_table_name text, + in i_table_attrs text, + out ret_code int4, + out ret_note text) +as $$ +-- ---------------------------------------------------------------------- +-- Function: londiste.local_set_table_attrs(3) +-- +-- Store urlencoded table attributes. +-- +-- Parameters: +-- i_queue_name - cascaded queue name +-- i_table - table name +-- i_table_attrs - urlencoded attributes +-- ---------------------------------------------------------------------- +begin + update londiste.table_info + set table_attrs = i_table_attrs + where queue_name = i_queue_name + and table_name = i_table_name + and local; + if found then + select 200, i_table_name || ': Table attributes stored' + into ret_code, ret_note; + else + select 404, 'no such local table: ' || i_table_name + into ret_code, ret_note; + end if; + return; +end; +$$ language plpgsql; + diff --git a/sql/londiste/functions/londiste.local_set_table_state.sql b/sql/londiste/functions/londiste.local_set_table_state.sql index 6b64d9b1..275a4d42 100644 --- a/sql/londiste/functions/londiste.local_set_table_state.sql +++ b/sql/londiste/functions/londiste.local_set_table_state.sql @@ -25,12 +25,7 @@ begin update londiste.table_info set custom_snapshot = i_snapshot, - merge_state = i_merge_state, - -- reset skip_snapshot when table is copied over - skip_truncate = case when i_merge_state = 'ok' - then null - else skip_truncate - end + merge_state = i_merge_state where queue_name = i_queue_name and table_name = _tbl and local; diff --git a/sql/londiste/structure/functions.sql b/sql/londiste/structure/functions.sql index c38126f7..ebf5c5ad 100644 --- a/sql/londiste/structure/functions.sql +++ b/sql/londiste/structure/functions.sql @@ -28,7 +28,7 @@ \i functions/londiste.root_check_seqs.sql \i functions/londiste.root_notify_change.sql \i functions/londiste.local_set_table_state.sql -\i functions/londiste.local_set_skip_truncate.sql +\i functions/londiste.local_set_table_attrs.sql \i functions/londiste.local_set_table_struct.sql -- Group: Utility functions diff --git a/sql/londiste/structure/tables.sql b/sql/londiste/structure/tables.sql index 79dd90df..d5e5142e 100644 --- a/sql/londiste/structure/tables.sql +++ b/sql/londiste/structure/tables.sql @@ -74,8 +74,8 @@ set default_with_oids = 'off'; -- local - Is used locally -- merge_state - State for tables -- custom_snapshot - remote snapshot for COPY command --- skip_truncate - if 'in-copy' should not do TRUNCATE -- dropped_ddl - temp place to store ddl +-- table_attrs - urlencoded dict of extra attributes -- -- Tables merge states: -- NULL - copy has not yet happened @@ -92,8 +92,8 @@ create table londiste.table_info ( local boolean not null default false, merge_state text, custom_snapshot text, - skip_truncate bool, dropped_ddl text, + table_attrs text, primary key (queue_name, table_name), foreign key (queue_name) references pgq_node.node_info (queue_name), |
