diff --git a/django/db/backends/util.py b/django/db/backends/util.py
index b0463b7..56e350f 100644
--- a/django/db/backends/util.py
+++ b/django/db/backends/util.py
@@ -16,9 +16,12 @@ class CursorWrapper(object):
         self.cursor = cursor
         self.db = db
 
-    def __getattr__(self, attr):
+    def _set_dirty(self):
         if self.db.is_managed():
             self.db.set_dirty()
+
+    def __getattr__(self, attr):
+        self._set_dirty()
         if attr in self.__dict__:
             return self.__dict__[attr]
         else:
@@ -31,6 +34,7 @@ class CursorWrapper(object):
 class CursorDebugWrapper(CursorWrapper):
 
     def execute(self, sql, params=()):
+        self._set_dirty()
         start = time()
         try:
             return self.cursor.execute(sql, params)
@@ -47,6 +51,7 @@ class CursorDebugWrapper(CursorWrapper):
             )
 
     def executemany(self, sql, param_list):
+        self._set_dirty()
         start = time()
         try:
             return self.cursor.executemany(sql, param_list)
diff --git a/tests/regressiontests/transactions_regress/tests.py b/tests/regressiontests/transactions_regress/tests.py
index 22f1b0f..5907c3a 100644
--- a/tests/regressiontests/transactions_regress/tests.py
+++ b/tests/regressiontests/transactions_regress/tests.py
@@ -1,9 +1,11 @@
-from __future__ import absolute_import
+from __future__ import absolute_import, with_statement
 
 from django.core.exceptions import ImproperlyConfigured
 from django.db import connection, transaction
 from django.db.transaction import commit_on_success, commit_manually, TransactionManagementError
+from django.db.utils import DatabaseError
 from django.test import TransactionTestCase, skipUnlessDBFeature
+from django.test.utils import override_settings
 from django.utils.unittest import skipIf
 
 from .models import Mod, M2mA, M2mB
@@ -166,6 +168,14 @@ class TestTransactionClosing(TransactionTestCase):
         except:
             self.fail("A transaction consisting of a failed operation was not closed.")
 
+        # Same test with DebugCursor
+        with override_settings(DEBUG=True):
+            self.assertRaises(Exception, create_system_user)
+            try:
+                self.assertEqual(User.objects.count(), 1)
+            except DatabaseError:
+                self.fail("A transaction consisting of a failed operation was not closed.")
+
 
 class TestManyToManyAddTransaction(TransactionTestCase):
     def test_manyrelated_add_commit(self):
