~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to database/replication/new-slave.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2010-01-28 23:26:44 UTC
  • mfrom: (7675.442.134 launchpad)
  • Revision ID: launchpad@pqm.canonical.com-20100128232644-350rlfnvjey5e344
Merging db-stable

Show diffs side-by-side

added added

removed removed

Lines of Context:
162
162
    target_con.commit()
163
163
    del target_con
164
164
 
165
 
    # Get a list of existing set ids.
 
165
    # Get a list of existing set ids that can be subscribed too. This
 
166
    # is all sets where the origin is the master_node, and set 2 if
 
167
    # the master happens to be configured as a forwarding slave. We
 
168
    # don't allow other sets where the master is configured as a
 
169
    # forwarding slave as we have to special case rebuilding the database
 
170
    # schema (such as we do for the authdb replication set 2).
166
171
    source_connection.rollback()
167
172
    master_node = replication.helpers.get_master_node(source_connection)
168
173
    cur = source_connection.cursor()
169
 
    cur.execute(
170
 
        "SELECT set_id FROM _sl.sl_set WHERE set_origin=%d"
171
 
        % master_node.node_id)
 
174
    cur.execute("""
 
175
        SELECT set_id FROM _sl.sl_set WHERE set_origin=%d
 
176
        UNION
 
177
        SELECT sub_set AS set_id FROM _sl.sl_subscribe
 
178
        WHERE sub_receiver=%d AND sub_forward IS TRUE AND sub_active IS TRUE
 
179
            AND sub_set=2
 
180
        """ % (master_node.node_id, master_node.node_id))
172
181
    set_ids = [set_id for set_id, in cur.fetchall()]
173
182
    log.debug("Discovered set ids %s" % repr(list(set_ids)))
174
183