SQLAlchemy concurrent DB access
It appears that database access via SQLAlchemy (PyMySQL engine) gets broken if using more than 1 worker:
sqlalchemy.exc.OperationalError: (OperationalError) (2006, 'MySQL server has gone away'),
sqlalchemy.exc.NoSuchColumnError: "Could not locate column in row for column 'table.id'",
etc...
Tried recommended multiprocessing guards: http://docs.sqlalchemy.org/en/rel_1_0/faq/connections.html#how-do-i-use-engines-connections-sessions-with-python-multiprocessing-or-os-fork
The standard multiprocessing implementation where each process calls a single task via luigi.build(…) works fine.
Any help would be greatly appreciated.
I routinely use SQLAlchemy with 24 workers.
I'm connecting to Oracle, though it's not clear to me why that should matter.
Are you using the luigi --workers=2 CLI to create your workers? or something else?
@K-Mike I'm dealing with the same problem. In our case I'm pretty sure is because we're sharing the Session object between the parent and the child processes and that don't work very well even calling the dispose method in Engine, re-creating the child processes session objects and so on.
Running into the same problem working with a postgres database: when I use luigi --workers=2 I get
sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) SSL SYSCALL error: EOF detected
but when I omit the --worker argument altogether things work fine. Any hints?
I am getting a similar error for psycopg2. However, it says my tasks were successfully run. Were you able to find useful workarounds?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If closed, you may revisit when your time allows and reopen! Thank you for your contributions.