Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intermittent Invalid file object error #191

Closed
msornay opened this issue Oct 27, 2016 · 3 comments
Closed

Intermittent Invalid file object error #191

msornay opened this issue Oct 27, 2016 · 3 comments

Comments

@msornay
Copy link

msornay commented Oct 27, 2016

Hello,

I am not certain that it is an aiopg issue, but we are sometime encountering the following error :

File "/usr/local/lib/python3.5/dist-packages/aiopg/cursor.py", line 113, in execute
    yield from self._conn._poll(waiter, timeout)
File "/usr/local/lib/python3.5/dist-packages/aiopg/connection.py", line 193, in _poll
    self._ready(self._weakref)
File "/usr/local/lib/python3.5/dist-packages/aiopg/connection.py", line 162, in _ready
    self._loop.add_writer(self._fileno, self._ready, weak_self)
File "/usr/lib/python3.5/asyncio/selector_events.py", line 272, in add_writer
    key = self._selector.get_key(fd)
File "/usr/lib/python3.5/selectors.py", line 189, in get_key
    return mapping[fileobj]
File "/usr/lib/python3.5/selectors.py", line 70, in __getitem__
    fd = self._selector._fileobj_lookup(fileobj)
File "/usr/lib/python3.5/selectors.py", line 224, in _fileobj_lookup
    return _fileobj_to_fd(fileobj)
File "/usr/lib/python3.5/selectors.py", line 39, in _fileobj_to_fd
    "{!r}".format(fileobj)) from None
ValueError: Invalid file object: None

It happens rarely, during the execution of the UPDATE step of a transaction with the following queries :

  1. BEGIN ;
  2. SELECT column FROM table WHERE condition FOR UPDATE ;
  3. UPDATE table SET column = value WHERE condition ;
  4. COMMIT ; (Which is never executed when the error occurs, never releasing the SELECT FOR UPDATE lock)

Environment :

  • PostgreSQL 9.5.3
  • Ubuntu 16.04 (dockerized)
  • Python 3.5.2
  • aiopg 0.11
@asvetlov
Copy link
Member

Looks like you have flaky network connection.
The only case when self._fileno becomes None is https://github.com/aio-libs/aiopg/blob/master/aiopg/connection.py#L146
This line is called only if postgres client was silently disconnected from server.

Sure, the error message should be more informative, I'll fix it.

@msornay
Copy link
Author

msornay commented Oct 28, 2016

I just noticed there probably were more case where that happened in 0.11
Thank you, I will update.

@asvetlov
Copy link
Member

Fixed by 1ce153c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants