Merge lp:~james-w/canonical-identity-provider/faster-user-admin-queries into lp:canonical-identity-provider/release

Proposed by James Westby
Status: Merged
Approved by: James Westby
Approved revision: no longer in the source branch.
Merged at revision: 1035
Proposed branch: lp:~james-w/canonical-identity-provider/faster-user-admin-queries
Merge into: lp:canonical-identity-provider/release
Diff against target: 29 lines (+6/-5)
1 file modified
src/identityprovider/migrations/0014_User_username_id_index.py (+6/-5)
To merge this branch: bzr merge lp:~james-w/canonical-identity-provider/faster-user-admin-queries
Reviewer Review Type Date Requested Status
James Westby (community) Approve
Review via email: mp+182476@code.launchpad.net

Commit message

Switch to using CREATE INDEX CONCURRENTLY.

Description of the change

Hi,

This moves to using CREATE INDEX CONCURRENTLY to avoid taking a lock
while making the index.

Thanks,

James

To post a comment you must log in.
Revision history for this message
James Westby (james-w) wrote :

Trivial.

review: Approve
Revision history for this message
Ubuntu One Auto Pilot (otto-pilot) wrote :
Download full text (43.8 KiB)

The attempt to merge lp:~james-w/canonical-identity-provider/faster-user-admin-queries into lp:canonical-identity-provider failed. Below is the output from the failed tests.

Updating download cache at dir /mnt/tarmac/cache/canonical-identity-provider/isd-download-cache
Using saved parent location: bzr+ssh://bazaar.launchpad.net/~canonical-isd-hackers/+junk/download-cache/
No revisions or tags to pull.
[localhost] local: which virtualenv
[localhost] local: /usr/bin/python /usr/bin/virtualenv --distribute --clear --system-site-packages .env
Not deleting .env/bin
New python executable in .env/bin/python
Installing distribute.............................................................................................................................................................................................done.
Installing pip...............done.
[localhost] local: dpkg -l libpq-dev 2> /dev/null | grep '^ii' | wc -l
[localhost] local: dpkg -l libxml2-dev 2> /dev/null | grep '^ii' | wc -l
[localhost] local: dpkg -l libxslt1-dev 2> /dev/null | grep '^ii' | wc -l
[localhost] local: dpkg -l memcached 2> /dev/null | grep '^ii' | wc -l
[localhost] local: dpkg -l postgresql-plpython-9.1 2> /dev/null | grep '^ii' | wc -l
[localhost] local: dpkg -l python-dev 2> /dev/null | grep '^ii' | wc -l
[localhost] local: dpkg -l python-m2crypto 2> /dev/null | grep '^ii' | wc -l
[localhost] local: dpkg -l swig 2> /dev/null | grep '^ii' | wc -l
[localhost] local: dpkg -l config-manager 2> /dev/null | grep '^ii' | wc -l
[localhost] local: dpkg -l python-egenix-mx-base-dev 2> /dev/null | grep '^ii' | wc -l
[localhost] local: /usr/lib/config-manager/cm.py update /tmp/tmpayW6Sg
[localhost] local: . /mnt/tarmac/cache/canonical-identity-provider/merges/trunk/.env/bin/activate && make install PACKAGES="-r /mnt/tarmac/cache/canonical-identity-provider/merges/trunk/requirements.txt"
pip install --find-links=file:///mnt/tarmac/cache/canonical-identity-provider/isd-download-cache --no-index pip==dev
Ignoring indexes: http://pypi.python.org/simple/
Downloading/unpacking pip==dev
  Running setup.py egg_info for package pip

    warning: no files found matching '*.html' under directory 'docs'
    warning: no previously-included files matching '*.txt' found under directory 'docs/_build'
    no previously-included directories found matching 'docs/_build/_sources'
Installing collected packages: pip
  Found existing installation: pip 1.1
    Uninstalling pip:
      Successfully uninstalled pip
  Running setup.py install for pip

    warning: no files found matching '*.html' under directory 'docs'
    warning: no previously-included files matching '*.txt' found under directory 'docs/_build'
    no previously-included directories found matching 'docs/_build/_sources'
    Installing pip script to /mnt/tarmac/cache/canonical-identity-provider/merges/trunk/.env/bin
    Installing pip-2.7 script to /mnt/tarmac/cache/canonical-identity-provider/merges/trunk/.env/bin
Successfully installed pip
Cleaning up...
pip install --find-links=. --no-index -r /mnt/tarmac/cache/canonical-identity-provider/merges/trunk/requirements.txt
Ignoring indexes: http://pypi.python.org/simple/
Download...

Revision history for this message
James Westby (james-w) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/identityprovider/migrations/0014_User_username_id_index.py'
2--- src/identityprovider/migrations/0014_User_username_id_index.py 2013-08-27 18:56:21 +0000
3+++ src/identityprovider/migrations/0014_User_username_id_index.py 2013-08-27 22:52:09 +0000
4@@ -1,19 +1,20 @@
5 # -*- coding: utf-8 -*-
6-import datetime
7+import psycopg2
8 from south.db import db
9 from south.v2 import SchemaMigration
10-from django.db import models
11
12
13 class Migration(SchemaMigration):
14
15 def forwards(self, orm):
16- db.commit_transaction()
17- db.execute('''CREATE INDEX auth_user_username_id_desc
18+ connection = db._get_connection()
19+ connection.connection.set_isolation_level(
20+ psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT)
21+ db.execute('''CREATE INDEX CONCURRENTLY auth_user_username_id_desc
22 ON auth_user
23 USING btree
24 (username, id DESC);''')
25- db.start_transaction()
26+ connection.connection.set_isolation_level(connection.isolation_level)
27
28
29 def backwards(self, orm):