<feed xmlns='http://www.w3.org/2005/Atom'>
<title>delta/python-packages/psycopg2.git/tests/test_cursor.py, branch separate-binary</title>
<subtitle>github.com: psycopg/psycopg2.git
</subtitle>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/python-packages/psycopg2.git/'/>
<entry>
<title>'cursor.mogrify()' can be called on closed cursors</title>
<updated>2018-01-10T23:26:11+00:00</updated>
<author>
<name>Daniele Varrazzo</name>
<email>daniele.varrazzo@gmail.com</email>
</author>
<published>2018-01-10T23:06:31+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/python-packages/psycopg2.git/commit/?id=9c5bf367917698c058c2bc16c9b447d5e0b7e8e1'/>
<id>9c5bf367917698c058c2bc16c9b447d5e0b7e8e1</id>
<content type='text'>
Fix #579.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Fix #579.
</pre>
</div>
</content>
</entry>
<entry>
<title>Collect rowcount in executemany even when discarding results</title>
<updated>2017-11-29T15:38:02+00:00</updated>
<author>
<name>Daniele Varrazzo</name>
<email>daniele.varrazzo@gmail.com</email>
</author>
<published>2017-11-29T15:28:10+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/python-packages/psycopg2.git/commit/?id=a5fd594ea428e3e8c11a632b1e3fd47df0cec2ab'/>
<id>a5fd594ea428e3e8c11a632b1e3fd47df0cec2ab</id>
<content type='text'>
Closes #633.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Closes #633.
</pre>
</div>
</content>
</entry>
<entry>
<title>Bunch of test tweaks to make the test grid green</title>
<updated>2017-03-14T14:15:52+00:00</updated>
<author>
<name>Daniele Varrazzo</name>
<email>daniele.varrazzo@gmail.com</email>
</author>
<published>2016-07-04T20:49:45+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/python-packages/psycopg2.git/commit/?id=8e28444897de74b9137f00c60a41f676058cc751'/>
<id>8e28444897de74b9137f00c60a41f676058cc751</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Always raise OperationalError when connection was closed externally.</title>
<updated>2017-03-14T12:14:00+00:00</updated>
<author>
<name>Greg Ward</name>
<email>gward@dyn.com</email>
</author>
<published>2016-06-28T22:03:05+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/python-packages/psycopg2.git/commit/?id=12317557da20d84baf12054d8dfce11ba8976cb6'/>
<id>12317557da20d84baf12054d8dfce11ba8976cb6</id>
<content type='text'>
From the DB-API (https://www.python.org/dev/peps/pep-0249/):

  OperationalError

  Exception raised for errors that are related to the database's
  operation and not necessarily under the control of the programmer,
  e.g. an unexpected disconnect occurs, [...]

Additionally, psycopg2 was inconsistent, at least in the async case:
depending on how the "connection closed" error was reported from the
kernel to libpq, it would sometimes raise OperationalError and
sometimes DatabaseError. Now it always raises OperationalError.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
From the DB-API (https://www.python.org/dev/peps/pep-0249/):

  OperationalError

  Exception raised for errors that are related to the database's
  operation and not necessarily under the control of the programmer,
  e.g. an unexpected disconnect occurs, [...]

Additionally, psycopg2 was inconsistent, at least in the async case:
depending on how the "connection closed" error was reported from the
kernel to libpq, it would sometimes raise OperationalError and
sometimes DatabaseError. Now it always raises OperationalError.
</pre>
</div>
</content>
</entry>
<entry>
<title>Always detect when a connection is closed behind psycopg2's back.</title>
<updated>2017-03-14T12:08:03+00:00</updated>
<author>
<name>Greg Ward</name>
<email>gward@dyn.com</email>
</author>
<published>2016-06-28T21:46:21+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/python-packages/psycopg2.git/commit/?id=b203a7c775c5f81f59c6b4205c3c33455ceeec3d'/>
<id>b203a7c775c5f81f59c6b4205c3c33455ceeec3d</id>
<content type='text'>
There's a race condition that only seems to happen over Unix-domain
sockets. Sometimes, the closed socket is reported by the kernel to
libpq like this (captured with strace):

  sendto(3, "Q\0\0\0\34select pg_backend_pid()\0", 29, MSG_NOSIGNAL, NULL, 0) = 29
  recvfrom(3, "E\0\0\0mSFATAL\0C57P01\0Mterminating "..., 16384, 0, NULL, NULL) = 110
  recvfrom(3, 0x12d0330, 16384, 0, 0, 0)  = -1 ECONNRESET (Connection reset by peer)

That is, psycopg2/libpq sees no error when sending the first query
after the connection is closed, but gets an error reading the result.
In that case, everything worked fine.

But sometimes, the error manifests like this:

  sendto(3, "Q\0\0\0\34select pg_backend_pid()\0", 29, MSG_NOSIGNAL, NULL, 0) = -1 EPIPE (Broken pipe)
  recvfrom(3, "E\0\0\0mSFATAL\0C57P01\0Mterminating "..., 16384, 0, NULL, NULL) = 110
  recvfrom(3, "", 16274, 0, NULL, NULL)   = 0
  recvfrom(3, "", 16274, 0, NULL, NULL)   = 0

i.e. libpq received an error when sending the query. This manifests as
a slightly different exception from a slightly different place. More
importantly, in this case connection.closed is left at 0 rather than
being set to 2, and that is the bug I'm fixing here.

Note that we see almost identical behaviour for sync and async
connections, and the fixes are the same. So I added extremely similar
test cases.

Finally, there is still a bug here: for async connections, we
sometimes raise DatabaseError (incorrect) and sometimes raise
OperationalError (correct). Will fix that next.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
There's a race condition that only seems to happen over Unix-domain
sockets. Sometimes, the closed socket is reported by the kernel to
libpq like this (captured with strace):

  sendto(3, "Q\0\0\0\34select pg_backend_pid()\0", 29, MSG_NOSIGNAL, NULL, 0) = 29
  recvfrom(3, "E\0\0\0mSFATAL\0C57P01\0Mterminating "..., 16384, 0, NULL, NULL) = 110
  recvfrom(3, 0x12d0330, 16384, 0, 0, 0)  = -1 ECONNRESET (Connection reset by peer)

That is, psycopg2/libpq sees no error when sending the first query
after the connection is closed, but gets an error reading the result.
In that case, everything worked fine.

But sometimes, the error manifests like this:

  sendto(3, "Q\0\0\0\34select pg_backend_pid()\0", 29, MSG_NOSIGNAL, NULL, 0) = -1 EPIPE (Broken pipe)
  recvfrom(3, "E\0\0\0mSFATAL\0C57P01\0Mterminating "..., 16384, 0, NULL, NULL) = 110
  recvfrom(3, "", 16274, 0, NULL, NULL)   = 0
  recvfrom(3, "", 16274, 0, NULL, NULL)   = 0

i.e. libpq received an error when sending the query. This manifests as
a slightly different exception from a slightly different place. More
importantly, in this case connection.closed is left at 0 rather than
being set to 2, and that is the bug I'm fixing here.

Note that we see almost identical behaviour for sync and async
connections, and the fixes are the same. So I added extremely similar
test cases.

Finally, there is still a bug here: for async connections, we
sometimes raise DatabaseError (incorrect) and sometimes raise
OperationalError (correct). Will fix that next.
</pre>
</div>
</content>
</entry>
<entry>
<title>Flake8 complaints</title>
<updated>2017-03-14T12:06:46+00:00</updated>
<author>
<name>Daniele Varrazzo</name>
<email>daniele.varrazzo@gmail.com</email>
</author>
<published>2017-03-14T12:06:46+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/python-packages/psycopg2.git/commit/?id=3c124a0b87a7bde51519cd0eb98980f04eed1595'/>
<id>3c124a0b87a7bde51519cd0eb98980f04eed1595</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Deal consistently with E'' quotes in tests</title>
<updated>2017-02-06T21:40:05+00:00</updated>
<author>
<name>Daniele Varrazzo</name>
<email>daniele.varrazzo@gmail.com</email>
</author>
<published>2017-02-06T18:43:39+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/python-packages/psycopg2.git/commit/?id=3873c6c09f133dd7793d8fcd1547341e22f1705b'/>
<id>3873c6c09f133dd7793d8fcd1547341e22f1705b</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Allow skipping the slow test</title>
<updated>2017-02-02T01:53:50+00:00</updated>
<author>
<name>Daniele Varrazzo</name>
<email>daniele.varrazzo@gmail.com</email>
</author>
<published>2017-02-02T01:53:50+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/python-packages/psycopg2.git/commit/?id=f24de0357ff4472aa8bb283980ea27b3ddd722e4'/>
<id>f24de0357ff4472aa8bb283980ea27b3ddd722e4</id>
<content type='text'>
It's not so much about tests being slow: some just get stuck and timeout
travis.

Skipped all tests taking about more than 0.2s to run on my laptop.
Fast testing takes about 8s instead of 24.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
It's not so much about tests being slow: some just get stuck and timeout
travis.

Skipped all tests taking about more than 0.2s to run on my laptop.
Fast testing takes about 8s instead of 24.
</pre>
</div>
</content>
</entry>
<entry>
<title>Merge branch 'master' into named-callproc</title>
<updated>2016-12-26T00:49:42+00:00</updated>
<author>
<name>Daniele Varrazzo</name>
<email>daniele.varrazzo@gmail.com</email>
</author>
<published>2016-12-26T00:49:42+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/python-packages/psycopg2.git/commit/?id=faaef61c276f62f5b16f75caf7297400e7fc0523'/>
<id>faaef61c276f62f5b16f75caf7297400e7fc0523</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix unicode mogrify test on python 2</title>
<updated>2016-10-10T23:22:23+00:00</updated>
<author>
<name>Daniele Varrazzo</name>
<email>daniele.varrazzo@gmail.com</email>
</author>
<published>2016-10-10T23:22:23+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/python-packages/psycopg2.git/commit/?id=05627ac0f9e519c52014185b48a782f8669e6843'/>
<id>05627ac0f9e519c52014185b48a782f8669e6843</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
</feed>
