Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#27966 closed Bug (fixed)

Bump required version of pyscopg2 to 2.5.4

Reported by: karyon Owned by: Mariusz Felisiak
Component: Database layer (models, ORM) Version: 1.11
Severity: Release blocker Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

this commit uses the cursor as context manager (line in question is marked), which were added in psycopg2 2.5 (release notes) (see third item)

but here django checks only for 2.4.5.

this commit here made 2.4.5 a requirement and documented that in a few places.

Change History (14)

comment:1 by karyon, 7 years ago

i tested with psycopg2 2.5.0 and after this i directly got the next crash, with 2.5.5 (the newest 2.5.x) that one was fixed too. so if you decide to update the requirements, i would suggest to require 2.5.5.

comment:2 by Simon Charette, 7 years ago

Severity: NormalRelease blocker
Triage Stage: UnreviewedAccepted

In all cases I think the code should be refactored to use self.cursor() instead of self.connection.cursor() which doesn't suffer from this issue and is appropriately wrapped.

comment:3 by Asif Saifuddin Auvi, 7 years ago

Has patch: set

comment:4 by Asif Saifuddin Auvi, 7 years ago

All suggested changes applied. Build are passing. just docs failure. does this worth a mention in release notes?

comment:5 by Tim Graham, 7 years ago

I think we must increases the minimum psycopg2 version to 2.5.4, due to the server-side cursors patch, f3b7c059367a4e82bbfc7e4f0d42b10975e79f0c. Running Django's test suite gives these errors:

psycopg2 < 2.5, e.g. 2.4.6

  File "/home/tim/code/django/django/db/backends/postgresql/base.py", line 213, in create_cursor
    cursor = self.connection.cursor(name, scrollable=False, withhold=self.connection.autocommit)
TypeError: 'scrollable' is an invalid keyword argument for this function

2.5 ≤ psycopg2 < 2.5.4

  File "/home/tim/code/django/django/db/models/query.py", line 50, in __iter__
    results = compiler.execute_sql(chunked_fetch=self.chunked_fetch)
  File "/home/tim/code/django/django/db/models/sql/compiler.py", line 876, in execute_sql
    cursor.close()
psycopg2.OperationalError: cursor "_django_curs_140304550061888_1" does not exist

Is there value in the cursor patch if that's the case?

comment:6 by Simon Charette, 7 years ago

If server side cursors require psycopg2 >= 2.5.4 we should just document that it's the minimum required version and avoid making this change.

comment:7 by Adam Johnson, 7 years ago

Agree, didn't realize that.

comment:8 by Asif Saifuddin Auvi, 7 years ago

Is it fixed then? or this ticket is invalid?

comment:9 by Claude Paroz, 7 years ago

Debian stable has 2.5.4, by the way.

comment:10 by Mariusz Felisiak, 7 years ago

Owner: changed from nobody to Mariusz Felisiak
Status: newassigned

comment:11 by Tim Graham, 7 years ago

Summary: db.backends.postgresql checks for psycopg2 2.4.5, but actually 2.5 is requiredBump required version of pyscopg2 to 2.5.4
Triage Stage: AcceptedReady for checkin

comment:12 by Aymeric Augustin, 7 years ago

Debian stable also has Django 1.7 ;-)

https://packages.debian.org/jessie/python-django

comment:13 by GitHub <noreply@…>, 7 years ago

Resolution: fixed
Status: assignedclosed

In 43380e91:

Fixed #27966 -- Bumped required psycopg2 version to 2.5.4.

Thanks Tim Graham for the review.

comment:14 by Mariusz Felisiak <felisiak.mariusz@…>, 7 years ago

In b06855fa:

[1.11.x] Fixed #27966 -- Bumped required psycopg2 version to 2.5.4.

Thanks Tim Graham for the review.

Backport of 43380e911073beab401a2fdeca0f25001e170dac from master

Note: See TracTickets for help on using tickets.
Back to Top