Seams `_nodb_cursor` method didn't do yield when handling error.
--
Ticket URL: <https://code.djangoproject.com/ticket/32403>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* resolution: => needsinfo
Comment:
Thanks for the report, however the builtin `django.db.backends.postgresql`
backend (on Python `3.9.0+` and `3.8.5`) raises `Connection refused` for
me (as expected):
{{{
django.db.utils.OperationalError: could not connect to server: Connection
refused
Is the server running on host "localhost" (127.0.0.1) and
accepting
TCP/IP connections on port 5432?
}}}
Can you share more details or a database configuration?
--
Ticket URL: <https://code.djangoproject.com/ticket/32403#comment:1>
Comment (by Kazantcev Andrey):
Replying to [comment:1 Mariusz Felisiak]:
> Thanks for the report, however the builtin
`django.db.backends.postgresql` backend (on Python `3.9.0+` and `3.8.5`)
raises `Connection refused` for me (as expected):
> {{{
> django.db.utils.OperationalError: could not connect to server:
Connection refused
> Is the server running on host "localhost" (127.0.0.1) and
accepting
> TCP/IP connections on port 5432?
> }}}
>
> Can you share more details or a database configuration?
Configuration
```
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': os.getenv('POSTGRESQL_NAME', 'postgres'),
'USER': os.getenv('POSTGRESQL_USER', 'postgres'),
'PASSWORD': os.getenv('POSTGRESQL_PASSWORD', 'postgres'),
'HOST': os.getenv('POSTGRESQL_HOST', 'localhost'),
'PORT': os.getenv('POSTGRESQL_PORT', '5432'),
'OPTIONS': json.loads(os.getenv('POSTGRESQL_ENGINE_OPTIONS',
'{}'))
}
}
```
I found a problem. The problem is in [these
lines](https://github.com/django/django/blob/f9cfd346f0222d86bfbac26ef5455806965bae6b/django/db/backends/postgresql/base.py#L324-L325).
If I have one connection and test expression in if return false then
function just return without reraise exception. And `contextmanager`
raises error `RuntimeError: generator didn't yield`
--
Ticket URL: <https://code.djangoproject.com/ticket/32403#comment:2>
* status: closed => new
* resolution: needsinfo =>
* component: contrib.postgres => Database layer (models, ORM)
Comment:
I've [https://github.com/cockroachdb/django-cockroachdb/issues/182 also
seen this] with `django_cockroachdb` (which inherits the PostgreSQL
backend).
--
Ticket URL: <https://code.djangoproject.com/ticket/32403#comment:3>
* version: 3.2 => 3.1
* stage: Unreviewed => Accepted
Comment:
Seems like a regression in f48f671223a20b161ca819cf7d6298e43b8ba5fe which
is also part of 3.1.
--
Ticket URL: <https://code.djangoproject.com/ticket/32403#comment:4>
* severity: Normal => Release blocker
Comment:
Thanks for details, I can confirm that it's a regression in
f48f671223a20b161ca819cf7d6298e43b8ba5fe.
--
Ticket URL: <https://code.djangoproject.com/ticket/32403#comment:5>
* owner: (none) => Mariusz Felisiak
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/32403#comment:6>
* has_patch: 0 => 1
Comment:
[https://github.com/django/django/pull/13963 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/32403#comment:7>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/32403#comment:8>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"f131841c601b9d4884adcdb284b4213c2ad89231" f131841c]:
{{{
#!CommitTicketReference repository=""
revision="f131841c601b9d4884adcdb284b4213c2ad89231"
Fixed #32403 -- Fixed re-raising DatabaseErrors when using only 'postgres'
database.
Thanks Kazantcev Andrey for the report.
Regression in f48f671223a20b161ca819cf7d6298e43b8ba5fe.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/32403#comment:9>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"7d658893450eb999f828c53a8e4efa03dff65cf3" 7d658893]:
{{{
#!CommitTicketReference repository=""
revision="7d658893450eb999f828c53a8e4efa03dff65cf3"
[3.2.x] Fixed #32403 -- Fixed re-raising DatabaseErrors when using only
'postgres' database.
Thanks Kazantcev Andrey for the report.
Regression in f48f671223a20b161ca819cf7d6298e43b8ba5fe.
Backport of f131841c601b9d4884adcdb284b4213c2ad89231 from master
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/32403#comment:10>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"9efe832ee1e5da326e4ee5ed370db963b8fe6624" 9efe832e]:
{{{
#!CommitTicketReference repository=""
revision="9efe832ee1e5da326e4ee5ed370db963b8fe6624"
[3.1.x] Fixed #32403 -- Fixed re-raising DatabaseErrors when using only
'postgres' database.
Thanks Kazantcev Andrey for the report.
Regression in f48f671223a20b161ca819cf7d6298e43b8ba5fe.
Backport of f131841c601b9d4884adcdb284b4213c2ad89231 from master
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/32403#comment:11>