Restarting Postgress server during high load cases uncaught exception momoko #127

Closed
haizaar opened this Issue Oct 25, 2015 · 0 comments

Projects

None yet

1 participant

@haizaar
Collaborator
haizaar commented Oct 25, 2015

This is the spin-off of #126. When running the following code and restarting the server in the middle, the following exception was raised:

ERROR:tornado.application:Exception in callback (6, <function null_wrapper at 0x7ff9431391b8>)
Traceback (most recent call last):
  File ".../local/lib/python2.7/site-packages/tornado/ioloop.py", line 866, in start
    handler_func(fd_obj, events)
  File ".../local/lib/python2.7/site-packages/tornado/stack_context.py", line 275, in null_wrapper
    return fn(*args, **kwargs)
  File ".../momoko/connection.py", line 713, in _io_callback
    self.ioloop.update_handler(self.fileno, IOLoop.WRITE)
  File ".../local/lib/python2.7/site-packages/tornado/ioloop.py", line 708, in update_handler
    self._impl.modify(fd, events | self.ERROR)
IOError: [Errno 2] No such file or directory

The code that reproduces the issue:

from tornado.ioloop import IOLoop
import momoko
from tornado.gen import engine


if __name__ == '__main__':

    ioloop = IOLoop.instance()
    db = momoko.Pool(
        dsn='dbname=your_db user=your_user password=very_secret_password '
            'host=remote_host port=5432',
        size=1,
        ioloop=ioloop,
    )

    future = db.connect()
    ioloop.add_future(future, lambda f: ioloop.stop())
    ioloop.start()
    future.result()

    @engine
    def never_ending_db_query_loop(callback):
        while True:
            try:
                cursor = yield db.execute('SELECT 1')
                row  = cursor.fetchone()
                print 'db returned: {0}'.format(row[0])
            except Exception as e:
                print e
        callback()


    never_ending_db_query_loop(ioloop.stop)
    ioloop.start()
@haizaar haizaar added a commit that closed this issue Oct 26, 2015
@haizaar haizaar Catching IOError. Fixes #127
Under heavy load we get "No such file or directory"
error when updating callbacks.

I've failed to reproduce it with the tcpproxy setup,
so this bugfix is currently not covered with unittest.
de98f2f
@haizaar haizaar closed this in de98f2f Oct 26, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment