Hello,

I started assessing multi-db support in Django 1.5.1, I'm interested in 
having read replicas and a write master.

I've figured out all the easy stuff: using TEST_MIRROR in the DATABASES 
setting, writing a simple router that splits read and write traffic, all 
according to the documentation. I can run a test server and issue some 
calls manually, but I have not been able to run simple unit tests.

The most simple test I can build fails during _pre_setup() with a 
"TransactionManagementError: Transaction managed block ended with pending 
COMMIT/ROLLBACK"

My databases are MySQL EC2 RDS instances, the replication is working fine, 
the tables are InnoDB etc.

I know there is active development around transaction management code in 
Django lately, so maybe I've stumbled on a bug? I'm attaching a simple test 
setup that should make it easy to reproduce.

Any advice would be greatly appreciated.

Cheers,
TTimo

./manage.py test readreplica
Creating test database for alias 'default'...
E
======================================================================
ERROR: testTest (readreplica.tests.Test)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/django/test/testcases.py", 
line 240, in __call__
    self._pre_setup()
  File "/usr/local/lib/python2.7/dist-packages/django/test/testcases.py", 
line 462, in _pre_setup
    self._fixture_setup()
  File "/usr/local/lib/python2.7/dist-packages/django/test/testcases.py", 
line 822, in _fixture_setup
    if not connections_support_transactions():
  File "/usr/local/lib/python2.7/dist-packages/django/test/testcases.py", 
line 809, in connections_support_transactions
    for conn in connections.all())
  File "/usr/local/lib/python2.7/dist-packages/django/test/testcases.py", 
line 809, in <genexpr>
    for conn in connections.all())
  File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py", 
line 48, in __get__
    res = instance.__dict__[self.func.__name__] = self.func(instance)
  File 
"/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py", 
line 627, in supports_transactions
    self.connection.leave_transaction_management()
  File 
"/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py", 
line 319, in leave_transaction_management
    "Transaction managed block ended with pending COMMIT/ROLLBACK")
TransactionManagementError: Transaction managed block ended with pending 
COMMIT/ROLLBACK

----------------------------------------------------------------------
Ran 0 tests in 0.084s

FAILED (errors=1)
Destroying test database for alias 'default'...

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Attachment: readreplica-unittest-transactionerror.tgz
Description: GNU Unix tar archive

Reply via email to