"python manage.py migrate CaseReport" gives "Transaction managed block ended with pending COMMIT/ROLLBACK"

528 views
Skip to first unread message

Dan Stromberg

unread,
May 28, 2014, 12:41:22 PM5/28/14
to south...@googlegroups.com

I'm attempting to add South management to a preexisting app.

What I've done:
pip install south
Add 'south' to INSTALLED_APPS
Test that South is now there:
$ python manage.py shell
Python 2.7.5+ (default, Feb 27 2014, 19:37:08)
[GCC 4.8.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> import south
>>>


Also, check that South shows  up in manage.py help:

python manage.py help



python manage.py syncdb



Make south manage your models:

python manage.py convert_to_south CaseReport

On other instances:
manage.py migrate app_name 0001 --fake


Make your model changes in models.py



Check what -would- happen (dry run):

python manage.py schemamigration CaseReport --auto --stdout

Run it for real:
python manage.py schemamigration CaseReport --auto

Finally:
python manage.py migrate CaseReport
...but this is tracebacking for me.  :(


The traceback looks like:
Running migrations for CaseReport:
 - Migrating forwards to 0002_auto__add_field_casereport_date_time_of_last_update.
 > CaseReport:0002_auto__add_field_casereport_date_time_of_last_update
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/dstromberg/miniconda/envs/CaseReport/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
    utility.execute()
  File "/home/dstromberg/miniconda/envs/CaseReport/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/dstromberg/miniconda/envs/CaseReport/local/lib/python2.7/site-packages/django/core/management/base.py", line 242, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/home/dstromberg/miniconda/envs/CaseReport/local/lib/python2.7/site-packages/django/core/management/base.py", line 285, in execute
    output = self.handle(*args, **options)
  File "/home/dstromberg/miniconda/envs/CaseReport/local/lib/python2.7/site-packages/south/management/commands/migrate.py", line 111, in handle
    ignore_ghosts = ignore_ghosts,
  File "/home/dstromberg/miniconda/envs/CaseReport/local/lib/python2.7/site-packages/south/migration/__init__.py", line 220, in migrate_app
    success = migrator.migrate_many(target, workplan, database)
  File "/home/dstromberg/miniconda/envs/CaseReport/local/lib/python2.7/site-packages/south/migration/migrators.py", line 254, in migrate_many
    result = migrator.__class__.migrate_many(migrator, target, migrations, database)
  File "/home/dstromberg/miniconda/envs/CaseReport/local/lib/python2.7/site-packages/south/migration/migrators.py", line 329, in migrate_many
    result = self.migrate(migration, database)
  File "/home/dstromberg/miniconda/envs/CaseReport/local/lib/python2.7/site-packages/south/migration/migrators.py", line 133, in migrate
    result = self.run(migration, database)
  File "/home/dstromberg/miniconda/envs/CaseReport/local/lib/python2.7/site-packages/south/migration/migrators.py", line 111, in run
    if not south.db.db.has_ddl_transactions:
  File "/home/dstromberg/miniconda/envs/CaseReport/local/lib/python2.7/site-packages/django/utils/functional.py", line 49, in __get__
    res = instance.__dict__[self.func.__name__] = self.func(instance)
  File "/home/dstromberg/miniconda/envs/CaseReport/local/lib/python2.7/site-packages/south/db/generic.py", line 124, in has_ddl_transactions
    if getattr(connection.features, 'supports_transactions', True):
  File "/home/dstromberg/miniconda/envs/CaseReport/local/lib/python2.7/site-packages/django/utils/functional.py", line 49, in __get__
    res = instance.__dict__[self.func.__name__] = self.func(instance)
  File "/home/dstromberg/miniconda/envs/CaseReport/local/lib/python2.7/site-packages/django/db/backends/__init__.py", line 676, in supports_transactions
    self.connection.leave_transaction_management()
  File "/home/dstromberg/miniconda/envs/CaseReport/local/lib/python2.7/site-packages/django/db/backends/__init__.py", line 322, in leave_transaction_management
    "Transaction managed block ended with pending COMMIT/ROLLBACK")
django.db.transaction.TransactionManagementError: Transaction managed block ended with pending COMMIT/ROLLBACK


What am I doing wrong?

Thanks.

Shai Berger

unread,
May 28, 2014, 1:30:43 PM5/28/14
to south...@googlegroups.com
Hi Dan,

There's a few details which could allow us to help you better:

What version of Django are you using?

What database backend?

Do you have specific transaction-related settings?

Finally, it would probably be helpful if you could attach the migration file.

Thanks,
Shai.

Dan Stromberg

unread,
May 28, 2014, 2:34:42 PM5/28/14
to south...@googlegroups.com

Hi.

I'm using Django 1.6 with Miniconda CPython 2.7.5, South 0.8.4, MySQL 5.5.37-0ubuntu0.13.10.1, and Linux Mint 16. 

I have not customized the transaction settings.


Thanks for your response.

Dan Stromberg

unread,
May 28, 2014, 3:44:05 PM5/28/14
to south...@googlegroups.com

Andrew Godwin

unread,
May 28, 2014, 3:52:31 PM5/28/14
to south...@googlegroups.com
Hi Dan,

Can you run the migrations in verbose mode and paste the output? (-vvv) That will help debug.

I don't use StackOverflow, and the answers on there for South can be wrong sometimes, but someone might know the answer.

Andrew


On Wed, May 28, 2014 at 12:44 PM, Dan Stromberg <drss...@gmail.com> wrote:

--
You received this message because you are subscribed to the Google Groups "South Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to south-users...@googlegroups.com.
To post to this group, send email to south...@googlegroups.com.
Visit this group at http://groups.google.com/group/south-users.
For more options, visit https://groups.google.com/d/optout.

Dan Stromberg

unread,
May 28, 2014, 6:08:47 PM5/28/14
to south...@googlegroups.com

Forgive me,  but what sort of verbose output are you looking for?

I tried:
  579  python -vvv manage.py migrate CaseReport
  580  python manage.py -vvv migrate CaseReport
  581  python manage.py migrate -vvv CaseReport
  582  python manage.py migrate CaseReport -vvv
  583  python manage.py migrate CaseReport -v 3

The first (579) output a lot of stuff, is that what you mean?  It's so verbose that I'm a little concerned it'll include one or more passwords.  The 2nd, 3rd and 4th (580, 581, 582) gave errors.  The 5th (583) ran without an error, but didn't appear to produce any additional output, and I don't see any recent logfiles it might've created.

I have a feeling this might make a good FAQ question, but I didn't see it in the FAQ.  I also google'd quite a bit about how to do this, but I didn't find anything relevant-looking that way either.

Thanks.

Andrew Godwin

unread,
May 28, 2014, 6:49:57 PM5/28/14
to south...@googlegroups.com
My apologies, I meant -v 3, like this:

python manage.py -v 3 migrate CaseReport

Andrew

Dan Stromberg

unread,
May 28, 2014, 7:34:53 PM5/28/14
to south...@googlegroups.com

$ python manage.py -v 3 migrate CaseReport
Unknown command: '-v'
Type 'manage.py help' for usage.

--
You received this message because you are subscribed to a topic in the Google Groups "South Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/south-users/cpjinq1hjp4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to south-users...@googlegroups.com.

Martin Maney

unread,
May 28, 2014, 10:40:32 PM5/28/14
to south...@googlegroups.com
On Wed, May 28, 2014 at 04:34:51PM -0700, Dan Stromberg wrote:
> $ python manage.py -v 3 migrate CaseReport
> Unknown command: '-v'
> Type 'manage.py help' for usage.

$ ./manage.py help migrate
Usage: manage.py migrate [options] [appname] ...

The options follow the command name. Even Andrew can make an oops. :-)

(and yeah, I tried it to be sure I wasn't compounding the oopses)

--
Show me your flowcharts and conceal your tables, and I shall continue
to be mystified. Show me your tables, and I won't usually need your
flowcharts; they'll be obvious. -- Brooks

Does that work even if the tables are denormalized? -- anon wiseass

Andrew Godwin

unread,
May 29, 2014, 1:13:52 AM5/29/14
to south...@googlegroups.com
Yeah, it comes after migrate: ./manage.py migrate -v 3

Andrew


Dan Stromberg

unread,
May 29, 2014, 12:14:32 PM5/29/14
to south...@googlegroups.com

I'm not sure it's giving any additional output.  Thanks for your assistance with this!

$ python manage.py migrate -v 3 CaseReport

--
You received this message because you are subscribed to a topic in the Google Groups "South Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/south-users/cpjinq1hjp4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to south-users...@googlegroups.com.

Shai Berger

unread,
May 29, 2014, 7:10:51 PM5/29/14
to south...@googlegroups.com
Are you using Django's mysql backend, or the Django-mysql-backend provided by
MySql (this is just a shot in the dark)?

A shot less-in-the-dark: Could you have changed the credentials that you
access the database with, so that now you are using a user which has no
permissions to create tables?

I'm asking because, looking at the code that triggers the exception [1], it
looks like in order to fail this way, the "CREATE TABLE" statement needs to
fail.

HTH,
Shai.

[1]
https://github.com/django/django/blob/stable/1.6.x/django/db/backends/__init__.py#L659
Reply all
Reply to author
Forward
0 new messages