Re: [Django] #34486: SearchHeadline crashes without an active connection.

13 views
Skip to first unread message

Django

unread,
Apr 13, 2023, 4:00:09 AM4/13/23
to django-...@googlegroups.com
#34486: SearchHeadline crashes without an active connection.
----------------------------------+------------------------------------
Reporter: Scott Macpherson | Owner: (none)
Type: Bug | Status: new
Component: contrib.postgres | Version: 4.2
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+------------------------------------

Comment (by Scott Macpherson):

I'd be happy to. Are you able to give me some pointers on replicating the
behaviour we're seeing from inside `TestCase`?

I've been mucking about with `TransactionTestCase` rather than `TestCase`,
and I can get things into a state where `connection.connection` inside
`mogrify` returns an idle connection rather than one that's in a
transaction, but that's not far enough to replicate this.

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

Django

unread,
Apr 13, 2023, 6:05:07 AM4/13/23
to django-...@googlegroups.com
#34486: SearchHeadline crashes without an active connection.
----------------------------------+------------------------------------
Reporter: Scott Macpherson | Owner: (none)
Type: Bug | Status: new
Component: contrib.postgres | Version: 4.2
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+------------------------------------

Comment (by Mariusz Felisiak):

Replying to [comment:8 Scott Macpherson]:


> I'd be happy to. Are you able to give me some pointers on replicating
the behaviour we're seeing from inside `TestCase`?
>
> I've been mucking about with `TransactionTestCase` rather than
`TestCase`, and I can get things into a state where
`connection.connection` inside `mogrify` returns an idle connection rather
than one that's in a transaction, but that's not far enough to replicate
this.

Since the real issue is in `compose_sql()`, I'd add a backend-specific
test, e.g.
{{{#!diff
diff --git a/tests/backends/postgresql/tests.py
b/tests/backends/postgresql/tests.py
index 9c4512be24..82df344139 100644
--- a/tests/backends/postgresql/tests.py
+++ b/tests/backends/postgresql/tests.py
@@ -420,3 +420,11 @@ class Tests(TestCase):
with self.assertRaisesMessage(NotSupportedError, msg):
connection.check_database_version_supported()
self.assertTrue(mocked_get_database_version.called)
+
+ def test_compose_sql_no_connection(self):
+ new_connection = connection.copy()
+ # compose_sql() should open a new connection.
+ try:
+ self.assertEqual(new_connection.ops.compose_sql("SELECT %s",
["test"]), "SELECT 'test'")
+ finally:
+ new_connection.close()
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/34486#comment:9>

Django

unread,
Apr 13, 2023, 7:03:54 AM4/13/23
to django-...@googlegroups.com
#34486: SearchHeadline crashes without an active connection.
-------------------------------------+-------------------------------------
Reporter: Scott Macpherson | Owner: Scott
| Macpherson
Type: Bug | Status: assigned

Component: contrib.postgres | Version: 4.2
Severity: Release blocker | 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 Scott Macpherson):

* owner: (none) => Scott Macpherson
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/34486#comment:10>

Django

unread,
Apr 13, 2023, 7:28:32 AM4/13/23
to django-...@googlegroups.com
#34486: SearchHeadline crashes without an active connection.
-------------------------------------+-------------------------------------
Reporter: Scott Macpherson | Owner: Scott
| Macpherson
Type: Bug | Status: assigned
Component: contrib.postgres | Version: 4.2
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Scott Macpherson):

Thanks for your help - you made it too easy! Pull request 16760 created:
https://github.com/django/django/pull/16760.

`backends.postgres` has one new regression test - that suite had one skip
before and the same skip after this change. `tests.postgres_tests`
produces the same output before and after this change as well.

--
Ticket URL: <https://code.djangoproject.com/ticket/34486#comment:11>

Django

unread,
Apr 13, 2023, 7:32:26 AM4/13/23
to django-...@googlegroups.com
#34486: SearchHeadline crashes without an active connection.
-------------------------------------+-------------------------------------
Reporter: Scott Macpherson | Owner: Scott
| Macpherson
Type: Bug | Status: assigned
Component: contrib.postgres | Version: 4.2
Severity: Release blocker | 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 Scott Macpherson):

* has_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/34486#comment:12>

Django

unread,
Apr 14, 2023, 3:59:28 AM4/14/23
to django-...@googlegroups.com
#34486: SearchHeadline crashes without an active connection.
-------------------------------------+-------------------------------------
Reporter: Scott Macpherson | Owner: Scott
| Macpherson
Type: Bug | Status: assigned
Component: contrib.postgres | Version: 4.2
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Ready for
| checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/34486#comment:13>

Django

unread,
Apr 14, 2023, 5:03:08 AM4/14/23
to django-...@googlegroups.com
#34486: SearchHeadline crashes without an active connection.
-------------------------------------+-------------------------------------
Reporter: Scott Macpherson | Owner: Scott
| Macpherson
Type: Bug | Status: closed
Component: contrib.postgres | Version: 4.2
Severity: Release blocker | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"53aee470d5b35e2708864d5221d2b5655e10c091" 53aee470]:
{{{
#!CommitTicketReference repository=""
revision="53aee470d5b35e2708864d5221d2b5655e10c091"
Fixed #34486 -- Fixed DatabaseOperations.compose_sql() crash with no
existing database connection on PostgreSQL.

Regression in 09ffc5c1212d4ced58b708cbbf3dfbfb77b782ca.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/34486#comment:14>

Django

unread,
Apr 14, 2023, 5:03:14 AM4/14/23
to django-...@googlegroups.com
#34486: SearchHeadline crashes without an active connection.
-------------------------------------+-------------------------------------
Reporter: Scott Macpherson | Owner: Scott
| Macpherson
Type: Bug | Status: closed
Component: contrib.postgres | Version: 4.2
Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"090d5ccc6c59e4df491ec0599c569834bdcf1409" 090d5cc]:
{{{
#!CommitTicketReference repository=""
revision="090d5ccc6c59e4df491ec0599c569834bdcf1409"
[4.2.x] Fixed #34486 -- Fixed DatabaseOperations.compose_sql() crash with


no existing database connection on PostgreSQL.

Regression in 09ffc5c1212d4ced58b708cbbf3dfbfb77b782ca.

Backport of 53aee470d5b35e2708864d5221d2b5655e10c091 from main
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/34486#comment:15>

Reply all
Reply to author
Forward
0 new messages