← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~stub/launchpad/bug-778338-blacklist-temp-tables into lp:launchpad

 

Stuart Bishop has proposed merging lp:~stub/launchpad/bug-778338-blacklist-temp-tables into lp:launchpad with lp:~stub/launchpad/bug-179821-lowercase-tablenames as a prerequisite.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #778338 in Launchpad itself: "restartable multitablecopier interacts badly with replication and upgrade operations"
  https://bugs.launchpad.net/launchpad/+bug/778338

For more details, see:
https://code.launchpad.net/~stub/launchpad/bug-778338-blacklist-temp-tables/+merge/60737

= Summary =

Transient tables confuse replication code.

== Proposed fix ==

Make the replication code ignore tables and sequences named temp_.

Ideally, these tables would be created in a separate schema and ignored automatically, but that creates a lot of fallout. We can revisit after upgrading from Slony 1.2
-- 
https://code.launchpad.net/~stub/launchpad/bug-778338-blacklist-temp-tables/+merge/60737
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stub/launchpad/bug-778338-blacklist-temp-tables into lp:launchpad.
=== modified file 'database/replication/helpers.py'
--- database/replication/helpers.py	2011-02-09 11:47:33 +0000
+++ database/replication/helpers.py	2011-05-12 08:14:34 +0000
@@ -473,6 +473,15 @@
     all_tables = all_tables_in_schema(cur, 'public')
     all_sequences = all_sequences_in_schema(cur, 'public')
 
+    # Ignore any tables and sequences starting with temp_. These are
+    # transient and not to be replicated per Bug #778338.
+    all_tables = set(
+        table for table in all_tables
+            if not table.startswith('public.temp_'))
+    all_sequences = set(
+        sequence for sequence in all_sequences
+            if not sequence.startswith('public.temp_'))
+
     cur.execute("""
         SELECT tab_nspname, tab_relname FROM %s
         WHERE tab_nspname = 'public'