dbt-osmosis icon indicating copy to clipboard operation
dbt-osmosis copied to clipboard

InvalidConnectionException

Open pixie79 opened this issue 2 years ago • 1 comments

I keep getting the following error when trying to hit the "Test compiled query"

Any ideas what causes it?

Using DBT 1.3.0 with the dbt-glue adapter.

InvalidConnectionException: Runtime Error connection never acquired for thread (94394, 10798264320), have [(94394, 6157971456)]

File "/Users/USER1/Library/Caches/pypoetry/virtualenvs/scripts-KQs5TViC-py3.10/lib/python3.10/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 556, in _run_script exec(code, module.dict) File "/Users/USER1/Library/Caches/pypoetry/virtualenvs/scripts-KQs5TViC-py3.10/lib/python3.10/site-packages/dbt_osmosis/app.py", line 328, in if compile_sql(state[RAW_SQL]) != state[COMPILED_SQL]: File "/Users/USER1/Library/Caches/pypoetry/virtualenvs/scripts-KQs5TViC-py3.10/lib/python3.10/site-packages/dbt_osmosis/app.py", line 198, in compile_sql return ctx.compile_sql(sql).compiled_sql File "/Users/USER1/Library/Caches/pypoetry/virtualenvs/scripts-KQs5TViC-py3.10/lib/python3.10/site-packages/dbt_osmosis/core/osmosis.py", line 543, in compile_sql return self.compile_sql(raw_sql, retry - 1) File "/Users/USER1/Library/Caches/pypoetry/virtualenvs/scripts-KQs5TViC-py3.10/lib/python3.10/site-packages/dbt_osmosis/core/osmosis.py", line 543, in compile_sql return self.compile_sql(raw_sql, retry - 1) File "/Users/USER1/Library/Caches/pypoetry/virtualenvs/scripts-KQs5TViC-py3.10/lib/python3.10/site-packages/dbt_osmosis/core/osmosis.py", line 543, in compile_sql return self.compile_sql(raw_sql, retry - 1) File "/Users/USER1/Library/Caches/pypoetry/virtualenvs/scripts-KQs5TViC-py3.10/lib/python3.10/site-packages/dbt_osmosis/core/osmosis.py", line 544, in compile_sql raise exc File "/Users/USER1/Library/Caches/pypoetry/virtualenvs/scripts-KQs5TViC-py3.10/lib/python3.10/site-packages/dbt_osmosis/core/osmosis.py", line 540, in compile_sql node = self.compile_node(self.get_server_node(raw_sql, temp_node_id)) File "/Users/USER1/Library/Caches/pypoetry/virtualenvs/scripts-KQs5TViC-py3.10/lib/python3.10/site-packages/dbt_osmosis/core/osmosis.py", line 554, in compile_node compiled_node = self.sql_compiler.compile(self.dbt) File "/Users/USER1/Library/Caches/pypoetry/virtualenvs/scripts-KQs5TViC-py3.10/lib/python3.10/site-packages/dbt/task/sql.py", line 39, in compile return compiler.compile_node(self.node, manifest, {}, write=False) File "/Users/USER1/Library/Caches/pypoetry/virtualenvs/scripts-KQs5TViC-py3.10/lib/python3.10/site-packages/dbt/compilation.py", line 535, in compile_node node = self._compile_node(node, manifest, extra_context) File "/Users/USER1/Library/Caches/pypoetry/virtualenvs/scripts-KQs5TViC-py3.10/lib/python3.10/site-packages/dbt/compilation.py", line 394, in _compile_node compiled_node.compiled_code = jinja.get_rendered( File "/Users/USER1/Library/Caches/pypoetry/virtualenvs/scripts-KQs5TViC-py3.10/lib/python3.10/site-packages/dbt/clients/jinja.py", line 587, in get_rendered return render_template(template, ctx, node) File "/Users/USER1/Library/Caches/pypoetry/virtualenvs/scripts-KQs5TViC-py3.10/lib/python3.10/site-packages/dbt/clients/jinja.py", line 542, in render_template return template.render(ctx) File "/Users/USER1/Library/Caches/pypoetry/virtualenvs/scripts-KQs5TViC-py3.10/lib/python3.10/site-packages/jinja2/environment.py", line 1301, in render self.environment.handle_exception() File "/Users/USER1/Library/Caches/pypoetry/virtualenvs/scripts-KQs5TViC-py3.10/lib/python3.10/site-packages/jinja2/environment.py", line 936, in handle_exception raise rewrite_traceback_stack(source=source) File "

pixie79 avatar Oct 21 '22 09:10 pixie79

It appears this may be an error handling issue,

If I logged out my AWS session on the console where I started Osmosis and then created a full new session restarting dbt-osmosis all is ok

pixie79 avatar Oct 21 '22 10:10 pixie79

Thanks, this is likely due to how streamlit manages threads. I can add a fix for this in the next release by guaranteeing thread connections are available on every compile/run call.

z3z1ma avatar Oct 27 '22 05:10 z3z1ma

Is there any fix for this in the works? Running into the same issue, but with Snowflake.

ananya77041 avatar Jan 24 '23 15:01 ananya77041

This should be resolved as all calls in streamlit now manage connection explicitly via dbt's context manager. 👍

z3z1ma avatar Mar 26 '23 08:03 z3z1ma