Opened 5 years ago

Closed 5 years ago

Last modified 5 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 Changed 5 years ago by karyon

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 Changed 5 years ago by Simon Charette

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 Changed 5 years ago by Asif Saifuddin Auvi

Has patch: set

comment:4 Changed 5 years ago by Asif Saifuddin Auvi

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

comment:5 Changed 5 years ago by Tim Graham

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 Changed 5 years ago by Simon Charette

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 Changed 5 years ago by Adam Johnson

Agree, didn't realize that.

comment:8 Changed 5 years ago by Asif Saifuddin Auvi

Is it fixed then? or this ticket is invalid?

comment:9 Changed 5 years ago by Claude Paroz

Debian stable has 2.5.4, by the way.

comment:10 Changed 5 years ago by Mariusz Felisiak

Owner: changed from nobody to Mariusz Felisiak
Status: newassigned

comment:11 Changed 5 years ago by Tim Graham

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 Changed 5 years ago by Aymeric Augustin

Debian stable also has Django 1.7 ;-)

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

comment:13 Changed 5 years ago by GitHub <noreply@…>

Resolution: fixed
Status: assignedclosed

In 43380e91:

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

Thanks Tim Graham for the review.

comment:14 Changed 5 years ago by Mariusz Felisiak <felisiak.mariusz@…>

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