zodb / relstorage

A backend for ZODB that stores pickles in a relational database.
Other
54 stars 46 forks source link

PostgreSQL wait callback #387

Closed tflorac closed 4 years ago

tflorac commented 4 years ago

Hi, I'm trying to migrate to RelStorage 3.0 on a Pyramid application using Python 3.5, psycopg2 driver and PostgreSQL database. On application startup, I can see an error message:

2019-12-04 10:57:31,835 DEBUG [relstorage.adapters.drivers][MainThread] Unable to import driver
Traceback (most recent call last):
  File "/var/local/env/pycharm/lib/python3.5/site-packages/relstorage/adapters/drivers.py", line 138, in __init__
    self.driver_module = mod = self.get_driver_module()
  File "/var/local/env/pycharm/lib/python3.5/site-packages/relstorage/adapters/postgresql/drivers/psycopg2.py", line 174, in get_driver_module
    return super(GeventPsycopg2Driver, self).get_driver_module()
  File "/var/local/env/pycharm/lib/python3.5/site-packages/relstorage/adapters/postgresql/drivers/psycopg2.py", line 86, in get_driver_module
    self._check_wait_callback()
  File "/var/local/env/pycharm/lib/python3.5/site-packages/relstorage/adapters/postgresql/drivers/psycopg2.py", line 179, in _check_wait_callback
    raise ImportError("No wait callback installed")
ImportError: No wait callback installed

Can you explain what this "wait callback" is?

Best regards, Thierry

jamadden commented 4 years ago

That DEBUG level logging is indicating that one particular driver is not available. In this case, it's the gevent psycopg2 driver. gevent is installed, and psycopg2 is installed, but the process has not been monkey-patched by gevent, nor has psycopg2's coroutine support been manually activated with a custom wait callback.

This occurs when RelStorage is asked to automatically select the best driver to use. It goes through the list of possibilities until it finds one that works. There's DEBUG logging for each one that doesn't work, which can be invaluable figuring out why the driver you expected isn't the driver that gets picked.

If you explicitly choose a driver (driver psycopg2) in your RelStorage configuration, there's no need to go through the list of possibilities so this shouldn't be logged.