[Django] #30413: tests: admin_views.test_multidb fails with persistent sqlite: OperationalError: database is locked

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

[Django] #30413: tests: admin_views.test_multidb fails with persistent sqlite: OperationalError: database is locked

Django
#30413: tests: admin_views.test_multidb fails with persistent sqlite:
OperationalError: database is locked
---------------------------------------------+------------------------
               Reporter:  Daniel Hahler      |          Owner:  nobody
                   Type:  Bug                |         Status:  new
              Component:  Testing framework  |        Version:  2.2
               Severity:  Normal             |       Keywords:
           Triage Stage:  Unreviewed         |      Has patch:  0
    Needs documentation:  0                  |    Needs tests:  0
Patch needs improvement:  0                  |  Easy pickings:  0
                  UI/UX:  0                  |
---------------------------------------------+------------------------
 I've tried using persistent SQLite databases for the tests (to make use of
 `--keepdb`), but at least some test fails with:

 > sqlite3.OperationalError: database is locked

 This is not an issue when only using `TEST["NAME"]` with "default" (which
 is good enough in terms of performance).

 {{{
 diff --git i/tests/test_sqlite.py w/tests/test_sqlite.py
 index f1b65f7d01..9ce4e32e14 100644
 --- i/tests/test_sqlite.py
 +++ w/tests/test_sqlite.py
 @@ -15,9 +15,15 @@
  DATABASES = {
      'default': {
          'ENGINE': 'django.db.backends.sqlite3',
 +        'TEST': {
 +            'NAME': 'test_default.sqlite3'
 +        },
      },
      'other': {
          'ENGINE': 'django.db.backends.sqlite3',
 +        'TEST': {
 +            'NAME': 'test_other.sqlite3'
 +        },
      }
  }
 }}}

 {{{
 % tests/runtests.py admin_views.test_multidb -v 3 --keepdb --parallel 1
 …
 Operations to perform:
   Synchronize unmigrated apps: admin_views, auth, contenttypes, messages,
 sessions, staticfiles
   Apply all migrations: admin, sites
 Running pre-migrate handlers for application contenttypes
 Running pre-migrate handlers for application auth
 Running pre-migrate handlers for application sites
 Running pre-migrate handlers for application sessions
 Running pre-migrate handlers for application admin
 Running pre-migrate handlers for application admin_views
 Synchronizing apps without migrations:
   Creating tables...
     Running deferred SQL...
 Running migrations:
   No migrations to apply.
 Running post-migrate handlers for application contenttypes
 Running post-migrate handlers for application auth
 Running post-migrate handlers for application sites
 Running post-migrate handlers for application sessions
 Running post-migrate handlers for application admin
 Running post-migrate handlers for application admin_views
 System check identified no issues (0 silenced).
 ERROR

 ======================================================================
 ERROR: setUpClass (admin_views.test_multidb.MultiDatabaseTests)
 ----------------------------------------------------------------------
 Traceback (most recent call last):
   File "…/Vcs/django/django/db/backends/utils.py", line 84, in _execute
     return self.cursor.execute(sql, params)
   File "…/Vcs/django/django/db/backends/sqlite3/base.py", line 391, in
 execute
     return Database.Cursor.execute(self, query, params)
 sqlite3.OperationalError: database is locked

 The above exception was the direct cause of the following exception:

 Traceback (most recent call last):
   File "…/Vcs/django/django/test/testcases.py", line 1137, in setUpClass
     cls.setUpTestData()
   File "…/Vcs/django/tests/admin_views/test_multidb.py", line 40, in
 setUpTestData
     username='admin', password='something', email='[hidden email]',
   File "…/Vcs/django/django/contrib/auth/models.py", line 158, in
 create_superuser
     return self._create_user(username, email, password, **extra_fields)
   File "…/Vcs/django/django/contrib/auth/models.py", line 141, in
 _create_user
     user.save(using=self._db)
   File "…/Vcs/django/django/contrib/auth/base_user.py", line 66, in save
     super().save(*args, **kwargs)
   File "…/Vcs/django/django/db/models/base.py", line 741, in save
     force_update=force_update, update_fields=update_fields)
   File "…/Vcs/django/django/db/models/base.py", line 779, in save_base
     force_update, using, update_fields,
   File "…/Vcs/django/django/db/models/base.py", line 870, in _save_table
     result = self._do_insert(cls._base_manager, using, fields, update_pk,
 raw)
   File "…/Vcs/django/django/db/models/base.py", line 908, in _do_insert
     using=using, raw=raw)
   File "…/Vcs/django/django/db/models/manager.py", line 82, in
 manager_method
     return getattr(self.get_queryset(), name)(*args, **kwargs)
   File "…/Vcs/django/django/db/models/query.py", line 1175, in _insert
     return query.get_compiler(using=using).execute_sql(return_id)
   File "…/Vcs/django/django/db/models/sql/compiler.py", line 1321, in
 execute_sql
     cursor.execute(sql, params)
   File "…/Vcs/django/django/db/backends/utils.py", line 67, in execute
     return self._execute_with_wrappers(sql, params, many=False,
 executor=self._execute)
   File "…/Vcs/django/django/db/backends/utils.py", line 76, in
 _execute_with_wrappers
     return executor(sql, params, many, context)
   File "…/Vcs/django/django/db/backends/utils.py", line 84, in _execute
     return self.cursor.execute(sql, params)
   File "…/Vcs/django/django/db/utils.py", line 89, in __exit__
     raise dj_exc_value.with_traceback(traceback) from exc_value
   File "…/Vcs/django/django/db/backends/utils.py", line 84, in _execute
     return self.cursor.execute(sql, params)
   File "…/Vcs/django/django/db/backends/sqlite3/base.py", line 391, in
 execute
     return Database.Cursor.execute(self, query, params)
 django.db.utils.OperationalError: database is locked
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30413>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/050.66a90b45baf90b85726d01d8548d40d7%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #30413: tests: admin_views.test_multidb fails with persistent sqlite: OperationalError: database is locked

Django
#30413: tests: admin_views.test_multidb fails with persistent sqlite:
OperationalError: database is locked
-----------------------------------+--------------------------------------
     Reporter:  Daniel Hahler      |                    Owner:  nobody
         Type:  Bug                |                   Status:  new
    Component:  Testing framework  |                  Version:  2.2
     Severity:  Normal             |               Resolution:
     Keywords:                     |             Triage Stage:  Unreviewed
    Has patch:  0                  |      Needs documentation:  0
  Needs tests:  0                  |  Patch needs improvement:  0
Easy pickings:  0                  |                    UI/UX:  0
-----------------------------------+--------------------------------------

Comment (by Daniel Hahler):

 This is only an issue when setting `TEST["NAME"]`, but not `NAME`.

 The following works:
 {{{
 DATABASES = {
     'default': {
         'ENGINE': 'django.db.backends.sqlite3',
         'NAME': 'django_tests_default.sqlite3',
     },
     'other': {
         'ENGINE': 'django.db.backends.sqlite3',
         'NAME': 'django_tests_other.sqlite3',
     }
 }
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30413#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/065.4684cbc028a6023733799e705b314883%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #30413: admin_views.test_multidb fails with persistent test SQLite database. (was: tests: admin_views.test_multidb fails with persistent sqlite: OperationalError: database is locked)

Django
In reply to this post by Django
#30413: admin_views.test_multidb fails with persistent test SQLite database.
-----------------------------------+------------------------------------
     Reporter:  Daniel Hahler      |                    Owner:  nobody
         Type:  Bug                |                   Status:  new
    Component:  Testing framework  |                  Version:  master
     Severity:  Normal             |               Resolution:
     Keywords:                     |             Triage Stage:  Accepted
    Has patch:  0                  |      Needs documentation:  0
  Needs tests:  0                  |  Patch needs improvement:  0
Easy pickings:  0                  |                    UI/UX:  0
-----------------------------------+------------------------------------
Changes (by felixxm):

 * version:  2.2 => master
 * stage:  Unreviewed => Accepted


Comment:

 Reproduced at 0dd2308cf6f559a4f4b50edd7c005c7cf025d1aa.

--
Ticket URL: <https://code.djangoproject.com/ticket/30413#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/065.6669d3af84790bb163cc80b08b47fd1d%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #30413: admin_views.test_multidb fails with persistent test SQLite database.

Django
In reply to this post by Django
#30413: admin_views.test_multidb fails with persistent test SQLite database.
-------------------------------------+-------------------------------------
     Reporter:  Daniel Hahler        |                    Owner:  Ngalim
                                     |  Siregar
         Type:  Bug                  |                   Status:  assigned
    Component:  Testing framework    |                  Version:  master
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Ngalim Siregar):

 * owner:  nobody => Ngalim Siregar
 * status:  new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/30413#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/065.f0a3ce3c2a64557ebb3c69cd796355f1%40djangoproject.com.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #30413: admin_views.test_multidb fails with persistent test SQLite database.

Django
In reply to this post by Django
#30413: admin_views.test_multidb fails with persistent test SQLite database.
-------------------------------------+-------------------------------------
     Reporter:  Daniel Hahler        |                    Owner:  Ngalim
                                     |  Siregar
         Type:  Bug                  |                   Status:  assigned
    Component:  Testing framework    |                  Version:  master
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Ngalim Siregar):

 * has_patch:  0 => 1


Old description:

> I've tried using persistent SQLite databases for the tests (to make use
> of
> `--keepdb`), but at least some test fails with:
>
> > sqlite3.OperationalError: database is locked
>
> This is not an issue when only using `TEST["NAME"]` with "default" (which
> is good enough in terms of performance).
>
> {{{
> diff --git i/tests/test_sqlite.py w/tests/test_sqlite.py
> index f1b65f7d01..9ce4e32e14 100644
> --- i/tests/test_sqlite.py
> +++ w/tests/test_sqlite.py
> @@ -15,9 +15,15 @@
>  DATABASES = {
>      'default': {
>          'ENGINE': 'django.db.backends.sqlite3',
> +        'TEST': {
> +            'NAME': 'test_default.sqlite3'
> +        },
>      },
>      'other': {
>          'ENGINE': 'django.db.backends.sqlite3',
> +        'TEST': {
> +            'NAME': 'test_other.sqlite3'
> +        },
>      }
>  }
> }}}
>
> {{{
> % tests/runtests.py admin_views.test_multidb -v 3 --keepdb --parallel 1
> …
> Operations to perform:
>   Synchronize unmigrated apps: admin_views, auth, contenttypes, messages,
> sessions, staticfiles
>   Apply all migrations: admin, sites
> Running pre-migrate handlers for application contenttypes
> Running pre-migrate handlers for application auth
> Running pre-migrate handlers for application sites
> Running pre-migrate handlers for application sessions
> Running pre-migrate handlers for application admin
> Running pre-migrate handlers for application admin_views
> Synchronizing apps without migrations:
>   Creating tables...
>     Running deferred SQL...
> Running migrations:
>   No migrations to apply.
> Running post-migrate handlers for application contenttypes
> Running post-migrate handlers for application auth
> Running post-migrate handlers for application sites
> Running post-migrate handlers for application sessions
> Running post-migrate handlers for application admin
> Running post-migrate handlers for application admin_views
> System check identified no issues (0 silenced).
> ERROR
>
> ======================================================================
> ERROR: setUpClass (admin_views.test_multidb.MultiDatabaseTests)
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>   File "…/Vcs/django/django/db/backends/utils.py", line 84, in _execute
>     return self.cursor.execute(sql, params)
>   File "…/Vcs/django/django/db/backends/sqlite3/base.py", line 391, in
> execute
>     return Database.Cursor.execute(self, query, params)
> sqlite3.OperationalError: database is locked
>
> The above exception was the direct cause of the following exception:
>
> Traceback (most recent call last):
>   File "…/Vcs/django/django/test/testcases.py", line 1137, in setUpClass
>     cls.setUpTestData()
>   File "…/Vcs/django/tests/admin_views/test_multidb.py", line 40, in
> setUpTestData
>     username='admin', password='something', email='[hidden email]',
>   File "…/Vcs/django/django/contrib/auth/models.py", line 158, in
> create_superuser
>     return self._create_user(username, email, password, **extra_fields)
>   File "…/Vcs/django/django/contrib/auth/models.py", line 141, in
> _create_user
>     user.save(using=self._db)
>   File "…/Vcs/django/django/contrib/auth/base_user.py", line 66, in save
>     super().save(*args, **kwargs)
>   File "…/Vcs/django/django/db/models/base.py", line 741, in save
>     force_update=force_update, update_fields=update_fields)
>   File "…/Vcs/django/django/db/models/base.py", line 779, in save_base
>     force_update, using, update_fields,
>   File "…/Vcs/django/django/db/models/base.py", line 870, in _save_table
>     result = self._do_insert(cls._base_manager, using, fields, update_pk,
> raw)
>   File "…/Vcs/django/django/db/models/base.py", line 908, in _do_insert
>     using=using, raw=raw)
>   File "…/Vcs/django/django/db/models/manager.py", line 82, in
> manager_method
>     return getattr(self.get_queryset(), name)(*args, **kwargs)
>   File "…/Vcs/django/django/db/models/query.py", line 1175, in _insert
>     return query.get_compiler(using=using).execute_sql(return_id)
>   File "…/Vcs/django/django/db/models/sql/compiler.py", line 1321, in
> execute_sql
>     cursor.execute(sql, params)
>   File "…/Vcs/django/django/db/backends/utils.py", line 67, in execute
>     return self._execute_with_wrappers(sql, params, many=False,
> executor=self._execute)
>   File "…/Vcs/django/django/db/backends/utils.py", line 76, in
> _execute_with_wrappers
>     return executor(sql, params, many, context)
>   File "…/Vcs/django/django/db/backends/utils.py", line 84, in _execute
>     return self.cursor.execute(sql, params)
>   File "…/Vcs/django/django/db/utils.py", line 89, in __exit__
>     raise dj_exc_value.with_traceback(traceback) from exc_value
>   File "…/Vcs/django/django/db/backends/utils.py", line 84, in _execute
>     return self.cursor.execute(sql, params)
>   File "…/Vcs/django/django/db/backends/sqlite3/base.py", line 391, in
> execute
>     return Database.Cursor.execute(self, query, params)
> django.db.utils.OperationalError: database is locked
> }}}
New description:

 I've tried using persistent SQLite databases for the tests (to make use of
 `--keepdb`), but at least some
 tsbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
 + export PATHest fails with:

 > sqlite3.OperationalError: database is locked

 This is not an issue when only using `TEST["NAME"]` with "default" (which
 is good enough in terms of performance).

 {{{
 diff --git i/tests/test_sqlite.py w/tests/test_sqlite.py
 index f1b65f7d01..9ce4e32e14 100644
 --- i/tests/test_sqlite.py
 +++ w/tests/test_sqlite.py
 @@ -15,9 +15,15 @@
  DATABASES = {
      'default': {
          'ENGINE': 'django.db.backends.sqlite3',
 +        'TEST': {
 +            'NAME': 'test_default.sqlite3'
 +        },
      },
      'other': {
          'ENGINE': 'django.db.backends.sqlite3',
 +        'TEST': {
 +            'NAME': 'test_other.sqlite3'
 +        },
      }
  }
 }}}

 {{{
 % tests/runtests.py admin_views.test_multidb -v 3 --keepdb --parallel 1
 …
 Operations to perform:
   Synchronize unmigrated apps: admin_views, auth, contenttypes, messages,
 sessions, staticfiles
   Apply all migrations: admin, sites
 Running pre-migrate handlers for application contenttypes
 Running pre-migrate handlers for application auth
 Running pre-migrate handlers for application sites
 Running pre-migrate handlers for application sessions
 Running pre-migrate handlers for application admin
 Running pre-migrate handlers for application admin_views
 Synchronizing apps without migrations:
   Creating tables...
     Running deferred SQL...
 Running migrations:
   No migrations to apply.
 Running post-migrate handlers for application contenttypes
 Running post-migrate handlers for application auth
 Running post-migrate handlers for application sites
 Running post-migrate handlers for application sessions
 Running post-migrate handlers for application admin
 Running post-migrate handlers for application admin_views
 System check identified no issues (0 silenced).
 ERROR

 ======================================================================
 ERROR: setUpClass (admin_views.test_multidb.MultiDatabaseTests)
 ----------------------------------------------------------------------
 Traceback (most recent call last):
   File "…/Vcs/django/django/db/backends/utils.py", line 84, in _execute
     return self.cursor.execute(sql, params)
   File "…/Vcs/django/django/db/backends/sqlite3/base.py", line 391, in
 execute
     return Database.Cursor.execute(self, query, params)
 sqlite3.OperationalError: database is locked

 The above exception was the direct cause of the following exception:

 Traceback (most recent call last):
   File "…/Vcs/django/django/test/testcases.py", line 1137, in setUpClass
     cls.setUpTestData()
   File "…/Vcs/django/tests/admin_views/test_multidb.py", line 40, in
 setUpTestData
     username='admin', password='something', email='[hidden email]',
   File "…/Vcs/django/django/contrib/auth/models.py", line 158, in
 create_superuser
     return self._create_user(username, email, password, **extra_fields)
   File "…/Vcs/django/django/contrib/auth/models.py", line 141, in
 _create_user
     user.save(using=self._db)
   File "…/Vcs/django/django/contrib/auth/base_user.py", line 66, in save
     super().save(*args, **kwargs)
   File "…/Vcs/django/django/db/models/base.py", line 741, in save
     force_update=force_update, update_fields=update_fields)
   File "…/Vcs/django/django/db/models/base.py", line 779, in save_base
     force_update, using, update_fields,
   File "…/Vcs/django/django/db/models/base.py", line 870, in _save_table
     result = self._do_insert(cls._base_manager, using, fields, update_pk,
 raw)
   File "…/Vcs/django/django/db/models/base.py", line 908, in _do_insert
     using=using, raw=raw)
   File "…/Vcs/django/django/db/models/manager.py", line 82, in
 manager_method
     return getattr(self.get_queryset(), name)(*args, **kwargs)
   File "…/Vcs/django/django/db/models/query.py", line 1175, in _insert
     return query.get_compiler(using=using).execute_sql(return_id)
   File "…/Vcs/django/django/db/models/sql/compiler.py", line 1321, in
 execute_sql
     cursor.execute(sql, params)
   File "…/Vcs/django/django/db/backends/utils.py", line 67, in execute
     return self._execute_with_wrappers(sql, params, many=False,
 executor=self._execute)
   File "…/Vcs/django/django/db/backends/utils.py", line 76, in
 _execute_with_wrappers
     return executor(sql, params, many, context)
   File "…/Vcs/django/django/db/backends/utils.py", line 84, in _execute
     return self.cursor.execute(sql, params)
   File "…/Vcs/django/django/db/utils.py", line 89, in __exit__
     raise dj_exc_value.with_traceback(traceback) from exc_value
   File "…/Vcs/django/django/db/backends/utils.py", line 84, in _execute
     return self.cursor.execute(sql, params)
   File "…/Vcs/django/django/db/backends/sqlite3/base.py", line 391, in
 execute
     return Database.Cursor.execute(self, query, params)
 django.db.utils.OperationalError: database is locked
 }}}

--

Comment:

 Created [https://github.com/django/django/pull/11678 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/30413#comment:4>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/065.e5789fd6af07ab425b2cb2533af2d074%40djangoproject.com.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #30413: admin_views.test_multidb fails with persistent test SQLite database.

Django
In reply to this post by Django
#30413: admin_views.test_multidb fails with persistent test SQLite database.
-------------------------------------+-------------------------------------
     Reporter:  Daniel Hahler        |                    Owner:  Ngalim
                                     |  Siregar
         Type:  Bug                  |                   Status:  assigned
    Component:  Testing framework    |                  Version:  master
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Description changed by felixxm:

Old description:

> I've tried using persistent SQLite databases for the tests (to make use
> of
> `--keepdb`), but at least some
> tsbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
> + export PATHest fails with:
>
> > sqlite3.OperationalError: database is locked
>
> This is not an issue when only using `TEST["NAME"]` with "default" (which
> is good enough in terms of performance).
>
> {{{
> diff --git i/tests/test_sqlite.py w/tests/test_sqlite.py
> index f1b65f7d01..9ce4e32e14 100644
> --- i/tests/test_sqlite.py
> +++ w/tests/test_sqlite.py
> @@ -15,9 +15,15 @@
>  DATABASES = {
>      'default': {
>          'ENGINE': 'django.db.backends.sqlite3',
> +        'TEST': {
> +            'NAME': 'test_default.sqlite3'
> +        },
>      },
>      'other': {
>          'ENGINE': 'django.db.backends.sqlite3',
> +        'TEST': {
> +            'NAME': 'test_other.sqlite3'
> +        },
>      }
>  }
> }}}
>
> {{{
> % tests/runtests.py admin_views.test_multidb -v 3 --keepdb --parallel 1
> …
> Operations to perform:
>   Synchronize unmigrated apps: admin_views, auth, contenttypes, messages,
> sessions, staticfiles
>   Apply all migrations: admin, sites
> Running pre-migrate handlers for application contenttypes
> Running pre-migrate handlers for application auth
> Running pre-migrate handlers for application sites
> Running pre-migrate handlers for application sessions
> Running pre-migrate handlers for application admin
> Running pre-migrate handlers for application admin_views
> Synchronizing apps without migrations:
>   Creating tables...
>     Running deferred SQL...
> Running migrations:
>   No migrations to apply.
> Running post-migrate handlers for application contenttypes
> Running post-migrate handlers for application auth
> Running post-migrate handlers for application sites
> Running post-migrate handlers for application sessions
> Running post-migrate handlers for application admin
> Running post-migrate handlers for application admin_views
> System check identified no issues (0 silenced).
> ERROR
>
> ======================================================================
> ERROR: setUpClass (admin_views.test_multidb.MultiDatabaseTests)
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>   File "…/Vcs/django/django/db/backends/utils.py", line 84, in _execute
>     return self.cursor.execute(sql, params)
>   File "…/Vcs/django/django/db/backends/sqlite3/base.py", line 391, in
> execute
>     return Database.Cursor.execute(self, query, params)
> sqlite3.OperationalError: database is locked
>
> The above exception was the direct cause of the following exception:
>
> Traceback (most recent call last):
>   File "…/Vcs/django/django/test/testcases.py", line 1137, in setUpClass
>     cls.setUpTestData()
>   File "…/Vcs/django/tests/admin_views/test_multidb.py", line 40, in
> setUpTestData
>     username='admin', password='something', email='[hidden email]',
>   File "…/Vcs/django/django/contrib/auth/models.py", line 158, in
> create_superuser
>     return self._create_user(username, email, password, **extra_fields)
>   File "…/Vcs/django/django/contrib/auth/models.py", line 141, in
> _create_user
>     user.save(using=self._db)
>   File "…/Vcs/django/django/contrib/auth/base_user.py", line 66, in save
>     super().save(*args, **kwargs)
>   File "…/Vcs/django/django/db/models/base.py", line 741, in save
>     force_update=force_update, update_fields=update_fields)
>   File "…/Vcs/django/django/db/models/base.py", line 779, in save_base
>     force_update, using, update_fields,
>   File "…/Vcs/django/django/db/models/base.py", line 870, in _save_table
>     result = self._do_insert(cls._base_manager, using, fields, update_pk,
> raw)
>   File "…/Vcs/django/django/db/models/base.py", line 908, in _do_insert
>     using=using, raw=raw)
>   File "…/Vcs/django/django/db/models/manager.py", line 82, in
> manager_method
>     return getattr(self.get_queryset(), name)(*args, **kwargs)
>   File "…/Vcs/django/django/db/models/query.py", line 1175, in _insert
>     return query.get_compiler(using=using).execute_sql(return_id)
>   File "…/Vcs/django/django/db/models/sql/compiler.py", line 1321, in
> execute_sql
>     cursor.execute(sql, params)
>   File "…/Vcs/django/django/db/backends/utils.py", line 67, in execute
>     return self._execute_with_wrappers(sql, params, many=False,
> executor=self._execute)
>   File "…/Vcs/django/django/db/backends/utils.py", line 76, in
> _execute_with_wrappers
>     return executor(sql, params, many, context)
>   File "…/Vcs/django/django/db/backends/utils.py", line 84, in _execute
>     return self.cursor.execute(sql, params)
>   File "…/Vcs/django/django/db/utils.py", line 89, in __exit__
>     raise dj_exc_value.with_traceback(traceback) from exc_value
>   File "…/Vcs/django/django/db/backends/utils.py", line 84, in _execute
>     return self.cursor.execute(sql, params)
>   File "…/Vcs/django/django/db/backends/sqlite3/base.py", line 391, in
> execute
>     return Database.Cursor.execute(self, query, params)
> django.db.utils.OperationalError: database is locked
> }}}
New description:

 I've tried using persistent SQLite databases for the tests (to make use of
 `--keepdb`), but at least some test fails with:

 > sqlite3.OperationalError: database is locked

 This is not an issue when only using `TEST["NAME"]` with "default" (which
 is good enough in terms of performance).

 {{{
 diff --git i/tests/test_sqlite.py w/tests/test_sqlite.py
 index f1b65f7d01..9ce4e32e14 100644
 --- i/tests/test_sqlite.py
 +++ w/tests/test_sqlite.py
 @@ -15,9 +15,15 @@
  DATABASES = {
      'default': {
          'ENGINE': 'django.db.backends.sqlite3',
 +        'TEST': {
 +            'NAME': 'test_default.sqlite3'
 +        },
      },
      'other': {
          'ENGINE': 'django.db.backends.sqlite3',
 +        'TEST': {
 +            'NAME': 'test_other.sqlite3'
 +        },
      }
  }
 }}}

 {{{
 % tests/runtests.py admin_views.test_multidb -v 3 --keepdb --parallel 1
 …
 Operations to perform:
   Synchronize unmigrated apps: admin_views, auth, contenttypes, messages,
 sessions, staticfiles
   Apply all migrations: admin, sites
 Running pre-migrate handlers for application contenttypes
 Running pre-migrate handlers for application auth
 Running pre-migrate handlers for application sites
 Running pre-migrate handlers for application sessions
 Running pre-migrate handlers for application admin
 Running pre-migrate handlers for application admin_views
 Synchronizing apps without migrations:
   Creating tables...
     Running deferred SQL...
 Running migrations:
   No migrations to apply.
 Running post-migrate handlers for application contenttypes
 Running post-migrate handlers for application auth
 Running post-migrate handlers for application sites
 Running post-migrate handlers for application sessions
 Running post-migrate handlers for application admin
 Running post-migrate handlers for application admin_views
 System check identified no issues (0 silenced).
 ERROR

 ======================================================================
 ERROR: setUpClass (admin_views.test_multidb.MultiDatabaseTests)
 ----------------------------------------------------------------------
 Traceback (most recent call last):
   File "…/Vcs/django/django/db/backends/utils.py", line 84, in _execute
     return self.cursor.execute(sql, params)
   File "…/Vcs/django/django/db/backends/sqlite3/base.py", line 391, in
 execute
     return Database.Cursor.execute(self, query, params)
 sqlite3.OperationalError: database is locked

 The above exception was the direct cause of the following exception:

 Traceback (most recent call last):
   File "…/Vcs/django/django/test/testcases.py", line 1137, in setUpClass
     cls.setUpTestData()
   File "…/Vcs/django/tests/admin_views/test_multidb.py", line 40, in
 setUpTestData
     username='admin', password='something', email='[hidden email]',
   File "…/Vcs/django/django/contrib/auth/models.py", line 158, in
 create_superuser
     return self._create_user(username, email, password, **extra_fields)
   File "…/Vcs/django/django/contrib/auth/models.py", line 141, in
 _create_user
     user.save(using=self._db)
   File "…/Vcs/django/django/contrib/auth/base_user.py", line 66, in save
     super().save(*args, **kwargs)
   File "…/Vcs/django/django/db/models/base.py", line 741, in save
     force_update=force_update, update_fields=update_fields)
   File "…/Vcs/django/django/db/models/base.py", line 779, in save_base
     force_update, using, update_fields,
   File "…/Vcs/django/django/db/models/base.py", line 870, in _save_table
     result = self._do_insert(cls._base_manager, using, fields, update_pk,
 raw)
   File "…/Vcs/django/django/db/models/base.py", line 908, in _do_insert
     using=using, raw=raw)
   File "…/Vcs/django/django/db/models/manager.py", line 82, in
 manager_method
     return getattr(self.get_queryset(), name)(*args, **kwargs)
   File "…/Vcs/django/django/db/models/query.py", line 1175, in _insert
     return query.get_compiler(using=using).execute_sql(return_id)
   File "…/Vcs/django/django/db/models/sql/compiler.py", line 1321, in
 execute_sql
     cursor.execute(sql, params)
   File "…/Vcs/django/django/db/backends/utils.py", line 67, in execute
     return self._execute_with_wrappers(sql, params, many=False,
 executor=self._execute)
   File "…/Vcs/django/django/db/backends/utils.py", line 76, in
 _execute_with_wrappers
     return executor(sql, params, many, context)
   File "…/Vcs/django/django/db/backends/utils.py", line 84, in _execute
     return self.cursor.execute(sql, params)
   File "…/Vcs/django/django/db/utils.py", line 89, in __exit__
     raise dj_exc_value.with_traceback(traceback) from exc_value
   File "…/Vcs/django/django/db/backends/utils.py", line 84, in _execute
     return self.cursor.execute(sql, params)
   File "…/Vcs/django/django/db/backends/sqlite3/base.py", line 391, in
 execute
     return Database.Cursor.execute(self, query, params)
 django.db.utils.OperationalError: database is locked
 }}}

--

--
Ticket URL: <https://code.djangoproject.com/ticket/30413#comment:5>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/065.26078804ecf8c1201787578bc3e335dc%40djangoproject.com.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #30413: admin_views.test_multidb fails with persistent test SQLite database.

Django
In reply to this post by Django
#30413: admin_views.test_multidb fails with persistent test SQLite database.
-------------------------------------+-------------------------------------
     Reporter:  Daniel Hahler        |                    Owner:  Ngalim
                                     |  Siregar
         Type:  Bug                  |                   Status:  assigned
    Component:  Testing framework    |                  Version:  master
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  1
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by felixxm):

 * needs_better_patch:  0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/30413#comment:6>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/065.106eb09084c217d4455043589251378f%40djangoproject.com.