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

SNOW-856569: Segmentation Fault in cache.py pickle dump #1627

Closed
benjy-canva opened this issue Jul 6, 2023 · 17 comments · Fixed by #1635
Closed

SNOW-856569: Segmentation Fault in cache.py pickle dump #1627

benjy-canva opened this issue Jul 6, 2023 · 17 comments · Fixed by #1635
Assignees

Comments

@benjy-canva
Copy link

benjy-canva commented Jul 6, 2023

Python version

Python 3.8.12 (default, Nov 17 2021, 08:36:07) [Clang 7.1.0 (tags/RELEASE_710/final)]

Operating system and processor architecture

Linux x86_64

Installed packages

dbt-core==1.5.2
dbt-snowflake==1.5.2
snowflake-connector-python[secure-local-storage] == 3.0.3

What did you do?

Running DBT on our linux machines with more than 1 thread triggers a segmentation fault in snowflake-connector-python for versions >= 3.x.x
We're not seeing this issue locally on MacOS.

What did you expect to see?

The offending line is here and the truncated stack trace:

Fatal Python error: Segmentation fault
Stack (most recent call first):
File "pypi_snowflake_connector_python/site-packages/snowflake/connector/cache.py", line 511 in _save
@github-actions github-actions bot changed the title Segmentation Fault in cache.py pickle dump SNOW-856569: Segmentation Fault in cache.py pickle dump Jul 6, 2023
@benjy-canva
Copy link
Author

Current workaround is to patch these two lines out to prevent the cache from read/writing to disk:

import inspect
import snowflake.connector.cache as cache

source = inspect.getsource(cache)
source = source.replace("other = pickle.load(r_file)", "return False")
source = source.replace("pickle.dump(self, w_file)", "return False")
exec(source, cache.__dict__)
sys.modules["snowflake.connector.cache"] = cache

@sfc-gh-yixie
Copy link
Collaborator

@Ben-A-Canva Do you have the code to reproduce the problem?
A connection isn't designed to be thread-safe. So I'm wondering if you were using multiple threads on one connection for "Running DBT on our linux machines with more than 1 thread".

@sfc-gh-yixie
Copy link
Collaborator

Plus, do you see the same problem on other OS if you happen to use other OS?

@verhey
Copy link

verhey commented Jul 7, 2023

At the request of our support agent (case 00555584), adding our repro steps here. We're experiencing the same thing as @Ben-A-Canva, and I'd add that this only started happening on 6/29AM Pacific - we have previously had 500+ successful runs with exactly the same dependencies and project configuration.

I understand you can't provide support for dbt-core, but since the error started occurring on a particular day, my suspicion is that it's originating from an infrastructure change on the Snowflake side rather than a code change in dbt or the connector library.

Python version

$ python3 -VV
Python 3.9.16 (main, May 23 2023, 14:24:31)
[GCC 8.3.0]

Operating system and processor architecture

$ lsb_release -a
No LSB modules are available.
Distributor ID:	Debian
Description:	Debian GNU/Linux 10 (buster)
Release:	10
Codename:	buster

$ arch
x86_64

I also cannot get it to repro on MacOS 13.4.1, i386 arch.

Installed packages

$ pip freeze | grep snowflake
dbt-snowflake==1.5.1
snowflake-connector-python==3.0.3 # also repros on 3.0.4 and commit hash 48aa932aeffd84da101928297dfb851f96342d98

What did you do?

Same as above, running our existing dbt project on any threads value > 1. On 8 threads we see ~10% failure rate. On 6, down to ~2%. On 20+, more like ~30%.

What did you expect to see?

No segfaults, which was the behavior prior to 2023-06-28

Abridged stack trace (from a single thread)

Expand
[2023-06-30 16:44:09,554] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.411000] free(): invalid pointer
[2023-06-30 16:44:09,574] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.411000] Fatal Python error: Aborted
[2023-06-30 16:44:09,583] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.411000] Thread 0x00007f61d75fe700 (most recent call first):
[2023-06-30 16:44:09,595] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.411000]   File "/usr/local/lib/python3.9/site-packages/snowflake/connector/ocsp_snowflake.py", line 610 in update_ocsp_response_cache_file
[2023-06-30 16:44:09,608] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.411000]   File "/usr/local/lib/python3.9/site-packages/snowflake/connector/ocsp_snowflake.py", line 591 in update_file
[2023-06-30 16:44:09,622] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.411000]   File "/usr/local/lib/python3.9/site-packages/snowflake/connector/ocsp_snowflake.py", line 1002 in _validate
[2023-06-30 16:44:09,634] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.411000]   File "/usr/local/lib/python3.9/site-packages/snowflake/connector/ocsp_snowflake.py", line 985 in validate
[2023-06-30 16:44:09,645] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.411000]   File "/usr/local/lib/python3.9/site-packages/snowflake/connector/ssl_wrap_socket.py", line 87 in ssl_wrap_socket_with_ocsp
[2023-06-30 16:44:09,660] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.411000]   File "/usr/local/lib/python3.9/site-packages/snowflake/connector/vendored/urllib3/connection.py", line 414 in connect
[2023-06-30 16:44:09,675] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.411000]   File "/usr/local/lib/python3.9/site-packages/snowflake/connector/vendored/urllib3/connectionpool.py", line 1042 in _validate_conn
[2023-06-30 16:44:09,686] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.411000]   File "/usr/local/lib/python3.9/site-packages/snowflake/connector/vendored/urllib3/connectionpool.py", line 386 in _make_request
[2023-06-30 16:44:09,697] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.411000]   File "/usr/local/lib/python3.9/site-packages/snowflake/connector/vendored/urllib3/connectionpool.py", line 703 in urlopen
[2023-06-30 16:44:09,708] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.411000]   File "/usr/local/lib/python3.9/site-packages/snowflake/connector/vendored/requests/adapters.py", line 489 in send
[2023-06-30 16:44:09,721] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.411000]   File "/usr/local/lib/python3.9/site-packages/snowflake/connector/vendored/requests/sessions.py", line 701 in send
[2023-06-30 16:44:09,734] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.411000]   File "/usr/local/lib/python3.9/site-packages/snowflake/connector/vendored/requests/sessions.py", line 587 in request
[2023-06-30 16:44:09,745] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.411000]   File "/usr/local/lib/python3.9/site-packages/snowflake/connector/network.py", line 1033 in _request_exec
[2023-06-30 16:44:09,756] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.411000]   File "/usr/local/lib/python3.9/site-packages/snowflake/connector/network.py", line 857 in _request_exec_wrapper
[2023-06-30 16:44:09,765] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.411000]   File "/usr/local/lib/python3.9/site-packages/snowflake/connector/network.py", line 814 in fetch
[2023-06-30 16:44:09,778] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.411000]   File "/usr/local/lib/python3.9/site-packages/snowflake/connector/network.py", line 716 in _post_request
[2023-06-30 16:44:09,788] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.411000]   File "/usr/local/lib/python3.9/site-packages/snowflake/connector/auth/_auth.py", line 250 in authenticate
[2023-06-30 16:44:09,797] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.411000]   File "/usr/local/lib/python3.9/site-packages/snowflake/connector/connection.py", line 1125 in _authenticate
[2023-06-30 16:44:09,809] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.411000]   File "/usr/local/lib/python3.9/site-packages/snowflake/connector/connection.py", line 1099 in authenticate_with_retry
[2023-06-30 16:44:09,822] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.411000]   File "/usr/local/lib/python3.9/site-packages/snowflake/connector/connection.py", line 839 in __open_connection
[2023-06-30 16:44:09,834] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.411000]   File "/usr/local/lib/python3.9/site-packages/snowflake/connector/connection.py", line 571 in connect
[2023-06-30 16:44:09,847] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.411000]   File "/usr/local/lib/python3.9/site-packages/snowflake/connector/connection.py", line 304 in __init__
[2023-06-30 16:44:09,857] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.411000]   File "/usr/local/lib/python3.9/site-packages/snowflake/connector/__init__.py", line 51 in Connect
[2023-06-30 16:44:09,868] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.411000]   File "/usr/local/lib/python3.9/site-packages/dbt/adapters/snowflake/connections.py", line 310 in connect
[2023-06-30 16:44:09,878] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.411000]   File "/usr/local/lib/python3.9/site-packages/dbt/adapters/base/connections.py", line 241 in retry_connection
[2023-06-30 16:44:09,889] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.411000]   File "/usr/local/lib/python3.9/site-packages/dbt/adapters/snowflake/connections.py", line 346 in open
[2023-06-30 16:44:09,898] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.411000]   File "/usr/local/lib/python3.9/site-packages/dbt/contracts/connection.py", line 118 in resolve
[2023-06-30 16:44:09,908] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.411000]   File "/usr/local/lib/python3.9/site-packages/dbt/contracts/connection.py", line 94 in handle
[2023-06-30 16:44:09,921] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.411000]   File "/usr/local/lib/python3.9/site-packages/dbt/adapters/sql/connections.py", line 80 in add_query
[2023-06-30 16:44:09,932] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.411000]   File "/usr/local/lib/python3.9/site-packages/dbt/adapters/snowflake/connections.py", line 446 in add_standard_query
[2023-06-30 16:44:09,942] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.411000]   File "/usr/local/lib/python3.9/site-packages/dbt/adapters/snowflake/connections.py", line 526 in _add_standard_queries
[2023-06-30 16:44:09,952] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.411000]   File "/usr/local/lib/python3.9/site-packages/dbt/adapters/snowflake/connections.py", line 470 in add_query
[2023-06-30 16:44:09,963] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.411000]   File "/usr/local/lib/python3.9/site-packages/dbt/adapters/snowflake/connections.py", line 435 in execute
[2023-06-30 16:44:09,973] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.411000]   File "/usr/local/lib/python3.9/site-packages/dbt/adapters/base/impl.py", line 289 in execute
[2023-06-30 16:44:10,013] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.411000]   File "/usr/local/lib/python3.9/site-packages/jinja2/runtime.py", line 298 in call
[2023-06-30 16:44:10,029] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.411000]   File "/usr/local/lib/python3.9/site-packages/jinja2/sandbox.py", line 393 in call
[2023-06-30 16:44:10,038] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.411000]   File "<template>", line 52 in macro
[2023-06-30 16:44:10,049] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.412000]   File "/usr/local/lib/python3.9/site-packages/jinja2/runtime.py", line 777 in _invoke
[2023-06-30 16:44:10,059] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.412000]   File "/usr/local/lib/python3.9/site-packages/jinja2/runtime.py", line 763 in __call__
[2023-06-30 16:44:10,069] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.412000]   File "/usr/local/lib/python3.9/site-packages/dbt/clients/jinja.py", line 257 in call_macro
[2023-06-30 16:44:10,078] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.412000]   File "/usr/local/lib/python3.9/site-packages/dbt/clients/jinja.py", line 330 in __call__
[2023-06-30 16:44:10,089] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.412000]   File "/usr/local/lib/python3.9/site-packages/jinja2/runtime.py", line 298 in call
[2023-06-30 16:44:10,097] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.412000]   File "/usr/local/lib/python3.9/site-packages/jinja2/sandbox.py", line 393 in call
[2023-06-30 16:44:10,116] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.412000]   File "<template>", line 33 in macro
[2023-06-30 16:44:10,128] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.412000]   File "/usr/local/lib/python3.9/site-packages/jinja2/runtime.py", line 777 in _invoke
[2023-06-30 16:44:10,138] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.412000]   File "/usr/local/lib/python3.9/site-packages/jinja2/runtime.py", line 763 in __call__
[2023-06-30 16:44:10,146] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.412000]   File "/usr/local/lib/python3.9/site-packages/dbt/clients/jinja.py", line 257 in call_macro
[2023-06-30 16:44:10,158] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.412000]   File "/usr/local/lib/python3.9/site-packages/dbt/clients/jinja.py", line 330 in __call__
[2023-06-30 16:44:10,169] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.412000]   File "/usr/local/lib/python3.9/site-packages/jinja2/runtime.py", line 298 in call
[2023-06-30 16:44:10,178] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.412000]   File "/usr/local/lib/python3.9/site-packages/jinja2/sandbox.py", line 393 in call
[2023-06-30 16:44:10,190] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.412000]   File "<template>", line 35 in macro
[2023-06-30 16:44:10,202] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.412000]   File "/usr/local/lib/python3.9/site-packages/jinja2/runtime.py", line 777 in _invoke
[2023-06-30 16:44:10,214] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.412000]   File "/usr/local/lib/python3.9/site-packages/jinja2/runtime.py", line 763 in __call__
[2023-06-30 16:44:10,225] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.412000]   File "/usr/local/lib/python3.9/site-packages/dbt/clients/jinja.py", line 257 in call_macro
[2023-06-30 16:44:10,240] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.412000]   File "/usr/local/lib/python3.9/site-packages/dbt/clients/jinja.py", line 330 in __call__
[2023-06-30 16:44:10,251] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.412000]   File "/usr/local/lib/python3.9/site-packages/jinja2/runtime.py", line 298 in call
[2023-06-30 16:44:10,261] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.412000]   File "/usr/local/lib/python3.9/site-packages/jinja2/sandbox.py", line 393 in call
[2023-06-30 16:44:10,273] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.412000]   File "<template>", line 21 in macro
[2023-06-30 16:44:10,287] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.412000]   File "/usr/local/lib/python3.9/site-packages/jinja2/runtime.py", line 777 in _invoke
[2023-06-30 16:44:10,298] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.412000]   File "/usr/local/lib/python3.9/site-packages/jinja2/runtime.py", line 763 in __call__
[2023-06-30 16:44:10,309] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.412000]   File "/usr/local/lib/python3.9/site-packages/dbt/clients/jinja.py", line 257 in call_macro
[2023-06-30 16:44:10,320] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.412000]   File "/usr/local/lib/python3.9/site-packages/dbt/clients/jinja.py", line 330 in __call__
[2023-06-30 16:44:10,332] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.412000]   File "/usr/local/lib/python3.9/site-packages/dbt/adapters/base/impl.py", line 1043 in execute_macro
[2023-06-30 16:44:10,341] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.412000]   File "/usr/local/lib/python3.9/site-packages/dbt/adapters/snowflake/impl.py", line 124 in list_relations_without_caching
[2023-06-30 16:44:10,351] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.412000]   File "/usr/local/lib/python3.9/site-packages/dbt/utils.py", line 464 in connected
[2023-06-30 16:44:10,363] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.412000]   File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 58 in run
[2023-06-30 16:44:10,373] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.412000]   File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 83 in _worker
[2023-06-30 16:44:10,382] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.412000]   File "/usr/local/lib/python3.9/threading.py", line 917 in run
[2023-06-30 16:44:10,394] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.412000]   File "/usr/local/lib/python3.9/threading.py", line 980 in _bootstrap_inner
[2023-06-30 16:44:10,405] {{ecs_operator.py:177}} INFO - [2023-06-30T16:43:41.412000]   File "/usr/local/lib/python3.9/threading.py", line 937 in _bootstrap

@verhey
Copy link

verhey commented Jul 7, 2023

I can't share our entire dbt project, but here's an example repo that I've been able to get the error to repro in.

@sfc-gh-yixie
Copy link
Collaborator

Thanks @verhey.

@peterallenwebb
Copy link
Contributor

I was able to avoid the segfault by replacing these lines:

https://github.com/snowflakedb/snowflake-connector-python/blob/v3.0.4/src/snowflake/connector/cache.py#L527-L528

with

                    with open(tmp_file, "wb") as w_file:
                        w_file.write(pickle.dumps(self))

I tried this after noting that the faulting thread reliably had the same native stack trace:

#3  PyDict_GetItemWithError (op=0xffffbb175d70, key=key@entry=0xdddddddddddddddd) at ../Objects/dictobject.c:1441
#4  0x00000000005b4e88 in save (self=self@entry=0xffff606027d0, obj=0xffffa4126770, pers_save=pers_save@entry=0) at ../Modules/_pickle.c:4385
#5  0x00000000005b5dbc in batch_dict_exact (self=self@entry=0xffff606027d0, obj=obj@entry=0xffffa41409b0) at ../Modules/_pickle.c:3281
#6  0x00000000005b6188 in save_dict (self=self@entry=0xffff606027d0, obj=obj@entry=0xffffa41409b0) at ../Modules/_pickle.c:3335
#7  0x00000000005b4cf8 in save (self=self@entry=0xffff606027d0, obj=0xffffa41409b0, pers_save=pers_save@entry=0) at ../Modules/_pickle.c:4323
#8  0x00000000005b5dbc in batch_dict_exact (self=self@entry=0xffff606027d0, obj=obj@entry=0xffff605fe350) at ../Modules/_pickle.c:3281
#9  0x00000000005b6188 in save_dict (self=self@entry=0xffff606027d0, obj=obj@entry=0xffff605fe350) at ../Modules/_pickle.c:3335
#10 0x00000000005b4cf8 in save (self=self@entry=0xffff606027d0, obj=0xffff605fe350, pers_save=pers_save@entry=0) at ../Modules/_pickle.c:4323
#11 0x00000000005b4094 in save_reduce (self=self@entry=0xffff606027d0, args=args@entry=0xffff60653ad0, obj=obj@entry=0xffffa413d960) at ../Modules/_pickle.c:4229
#12 0x00000000005b4b94 in save (self=self@entry=0xffff606027d0, obj=obj@entry=0xffffa413d960, pers_save=pers_save@entry=0) at ../Modules/_pickle.c:4472
#13 0x00000000005b5570 in dump (self=self@entry=0xffff606027d0, obj=obj@entry=0xffffa413d960) at ../Modules/_pickle.c:4519
#14 0x00000000005b5a74 in _pickle_dump_impl (module=module@entry=0xffffa411fbf0, obj=obj@entry=0xffffa413d960, file=file@entry=0xffff60602d10,

That suggested a problem with the CPython implementation of pickle.dump(). Perhaps part of the issue is that the object being pickled is modified by another thread during serialization?

I verified the fix using the repro project (https://github.com/verhey/snowflake-thread-repro) created by @verhey. I was able to trigger the segfault every few runs with that method, and found that with the change above there was no segfault in over 20 runs.

@benjy-canva
Copy link
Author

I was able to avoid the segfault by replacing these lines:

https://github.com/snowflakedb/snowflake-connector-python/blob/v3.0.4/src/snowflake/connector/cache.py#L527-L528

with

                    with open(tmp_file, "wb") as w_file:
                        w_file.write(pickle.dumps(self))

This seems to fix our segfaults. I'll need to do a few more test runs but so far it's been fine for the 2 runs i've tried (it would fail about 95% of the time without the patch)

@sfc-gh-yixie
Copy link
Collaborator

I couldn't reproduce it in my env yet. Could you try if removing the __del__ fix the problem? We previously also found a problem with the segfault caused by this destructor.

    def __del__(self) -> None:
        try:
            self._save()
        except Exception:
            # At tear-down time builtins module might be already gone, ignore every error
            pass

@peterallenwebb
Copy link
Contributor

peterallenwebb commented Jul 10, 2023

@sfc-gh-yixie My change is in the _save() function called in __del__, so I think there is a good chance it will mitigate your issue as well.

@sfc-gh-mkeller
Copy link
Collaborator

In PR #1635 I try to fix the underlying issue. I'd greatly appreciate it if you guys could help me test the code ❤️
I forked @verhey's repo (thanks a ton for the repro!) to verify that this works with my changes, but I'd like to get some more organic testing to be done as well!

@sfc-gh-mkeller
Copy link
Collaborator

sfc-gh-mkeller commented Jul 11, 2023

Please don't look too closely while I fix the failing tests/new bugs 😓

I should have resolved all the issues now!

@verhey
Copy link

verhey commented Jul 11, 2023

@sfc-gh-mkeller Glad the repro repo was useful.

I've tested with that repo against two commits - the fix from @peterallenwebb's PR on this branch and the (at the time of writing this) tip of your current PR on this one. Didn't get any segfaults in 20 runs for either of them via for run in {1..20}; do make test; done > results.txt.

I also did a quick test of 10 runs of dbt compile --threads 30 in our dbt project where we originally saw this error repro and also didn't get any segfaults there.

Wouldn't call my testing alone conclusive, but on previous builds that almost certainly would've triggered at least one segfault, so I'd be optimistic about the fixes at least.

@sfc-gh-mkeller sfc-gh-mkeller self-assigned this Jul 13, 2023
@A132770
Copy link

A132770 commented Jul 13, 2023

Appreciate all of your work on this! Just in case this is a helpful datapoint:

Exactly as @verhey had said, on 6/28 our logging revealed a sudden spike of segfaults across many internal workloads on our data platform, where we historically had none before. Our data workloads run on effectively static servers in static containers, so it does not feel like a sudden dependency update thing.

We are using thread based parallelism with Prefect, afaik we are creating a new connection object per-thread (which to be frank I am not sure is OK to do).

ul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]: Fatal Python error: Segmentation fault
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]: Thread 0x00007fa74573a700 (most recent call first):
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/Cryptodome/Math/_IntegerGMP.py", line 177 in __init__
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/Cryptodome/Math/_IntegerGMP.py", line 313 in _apply_and_return
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/Cryptodome/Math/_IntegerGMP.py", line 333 in __gt__
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/Cryptodome/PublicKey/RSA.py", line 179 in _encrypt
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/Cryptodome/Signature/pkcs1_15.py", line 115 in verify
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/Cryptodome/Signature/PKCS1_v1_5.py", line 43 in _pycrypto_verify
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/ocsp_asn1crypto.py", line 398 in verify_signature
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/ocsp_asn1crypto.py", line 338 in process_ocsp_response
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/ocsp_snowflake.py", line 1111 in validate_by_direct_connect
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/ocsp_snowflake.py", line 1188 in _validate_certificates_seq
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/ocsp_snowflake.py", line 998 in _validate
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/ocsp_snowflake.py", line 985 in validate
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/ssl_wrap_socket.py", line 87 in ssl_wrap_socket_with_ocsp
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/vendored/urllib3/connection.py", line 419 in connect
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/vendored/urllib3/connectionpool.py", line 1042 in _validate
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/vendored/urllib3/connectionpool.py", line 386 in _make_requ
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/vendored/urllib3/connectionpool.py", line 703 in urlopen
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/vendored/requests/adapters.py", line 487 in send
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/vendored/requests/sessions.py", line 701 in send
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/vendored/requests/sessions.py", line 587 in request
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/network.py", line 1037 in _request_exec
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/network.py", line 861 in _request_exec_wrapper
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/network.py", line 818 in fetch
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/network.py", line 720 in _post_request
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/auth/_auth.py", line 250 in authenticate
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/connection.py", line 1153 in _authenticate
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/connection.py", line 1127 in authenticate_with_retry
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/connection.py", line 860 in __open_connection
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/connection.py", line 590 in connect
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/connection.py", line 319 in __init__
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/__init__.py", line 51 in Connect
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/pgr_prefect/snowflake/connectors.py", line 174 in __init__
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/pgr_prefect/tasks/snowflake.py", line 60 in _set_conn
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/pgr_prefect/tasks/snowflake.py", line 72 in run
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/pgr_prefect/tasks/snowflake.py", line 124 in run
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/prefect/utilities/executors.py", line 468 in run_task_with_timeout
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/prefect/engine/task_runner.py", line 880 in get_task_run_state
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/prefect/engine/runner.py", line 48 in inner
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/prefect/engine/task_runner.py", line 297 in run
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/prefect/utilities/executors.py", line 570 in wrapper
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/prefect/engine/cloud/task_runner.py", line 344 in run
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/prefect/utilities/executors.py", line 570 in wrapper
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/prefect/engine/flow_runner.py", line 777 in run_task
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/dask/utils.py", line 73 in apply
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/dask/core.py", line 119 in _execute_task
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/dask/local.py", line 224 in execute_task
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/dask/local.py", line 238 in <listcomp>
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/dask/local.py", line 238 in batch_execute_tasks
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57 in run
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 80 in _worker
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/threading.py", line 870 in run
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/threading.py", line 932 in _bootstrap_inner
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/threading.py", line 890 in _bootstrap
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]: Thread 0x00007fa745f3b700 (most recent call first):
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/Cryptodome/Math/_IntegerGMP.py", line 203 in __int__
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/Cryptodome/PublicKey/RSA.py", line 181 in _encrypt
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/Cryptodome/Signature/pkcs1_15.py", line 115 in verify
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/Cryptodome/Signature/PKCS1_v1_5.py", line 43 in _pycrypto_verify
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/ocsp_asn1crypto.py", line 398 in verify_signature
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/ocsp_asn1crypto.py", line 338 in process_ocsp_response
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/ocsp_snowflake.py", line 1111 in validate_by_direct_connect
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/ocsp_snowflake.py", line 1188 in _validate_certificates_seq
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/ocsp_snowflake.py", line 998 in _validate
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/ocsp_snowflake.py", line 985 in validate
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/ssl_wrap_socket.py", line 87 in ssl_wrap_socket_with_ocsp
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/vendored/urllib3/connection.py", line 419 in connect
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/vendored/urllib3/connectionpool.py", line 1042 in _validate
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/vendored/urllib3/connectionpool.py", line 386 in _make_requ
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/vendored/urllib3/connectionpool.py", line 703 in urlopen
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/vendored/requests/adapters.py", line 487 in send
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/vendored/requests/sessions.py", line 701 in send
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/vendored/requests/sessions.py", line 587 in request
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/network.py", line 1037 in _request_exec
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/network.py", line 861 in _request_exec_wrapper
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/network.py", line 818 in fetch
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/network.py", line 720 in _post_request
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/auth/_auth.py", line 250 in authenticate
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/connection.py", line 1153 in _authenticate
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/connection.py", line 1127 in authenticate_with_retry
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/connection.py", line 860 in __open_connection
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/connection.py", line 590 in connect
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/connection.py", line 319 in __init__
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/__init__.py", line 51 in Connect
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/pgr_prefect/snowflake/connectors.py", line 174 in __init__
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/pgr_prefect/tasks/snowflake.py", line 60 in _set_conn
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/pgr_prefect/tasks/snowflake.py", line 72 in run
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/pgr_prefect/tasks/snowflake.py", line 124 in run
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/prefect/utilities/executors.py", line 468 in run_task_with_timeout
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/prefect/engine/task_runner.py", line 880 in get_task_run_state
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/prefect/engine/runner.py", line 48 in inner
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/prefect/engine/task_runner.py", line 297 in run
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/prefect/utilities/executors.py", line 570 in wrapper
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/prefect/engine/cloud/task_runner.py", line 344 in run
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/prefect/utilities/executors.py", line 570 in wrapper
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/prefect/engine/flow_runner.py", line 777 in run_task
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/dask/utils.py", line 73 in apply
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/dask/core.py", line 119 in _execute_task
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/dask/local.py", line 224 in execute_task
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/dask/local.py", line 238 in <listcomp>
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/dask/local.py", line 238 in batch_execute_tasks
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57 in run
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 80 in _worker
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/threading.py", line 870 in run
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/threading.py", line 932 in _bootstrap_inner
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/threading.py", line 890 in _bootstrap
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]: Current thread 0x00007fa74673c700 (most recent call first):
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/cache.py", line 528 in _save
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/ocsp_snowflake.py", line 590 in update_file
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/ocsp_snowflake.py", line 1002 in _validate
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/ocsp_snowflake.py", line 985 in validate
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/ssl_wrap_socket.py", line 87 in ssl_wrap_socket_with_ocsp
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/vendored/urllib3/connection.py", line 419 in connect
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/vendored/urllib3/connectionpool.py", line 1042 in _validate
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/vendored/urllib3/connectionpool.py", line 386 in _make_requ
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/vendored/urllib3/connectionpool.py", line 703 in urlopen
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/vendored/requests/adapters.py", line 487 in send
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/vendored/requests/sessions.py", line 701 in send
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/vendored/requests/sessions.py", line 587 in request
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/network.py", line 1037 in _request_exec
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/network.py", line 861 in _request_exec_wrapper
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/network.py", line 818 in fetch
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/network.py", line 720 in _post_request
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/auth/_auth.py", line 250 in authenticate
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/connection.py", line 1153 in _authenticate
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/connection.py", line 1127 in authenticate_with_retry
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/connection.py", line 860 in __open_connection
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/connection.py", line 590 in connect
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/connection.py", line 319 in __init__
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/snowflake/connector/__init__.py", line 51 in Connect
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/pgr_prefect/snowflake/connectors.py", line 174 in __init__
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/pgr_prefect/tasks/snowflake.py", line 60 in _set_conn
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/pgr_prefect/tasks/snowflake.py", line 72 in run
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/pgr_prefect/tasks/snowflake.py", line 124 in run
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/prefect/utilities/executors.py", line 468 in run_task_with_timeout
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/prefect/engine/task_runner.py", line 880 in get_task_run_state
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/prefect/engine/runner.py", line 48 in inner
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/prefect/engine/task_runner.py", line 297 in run
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/prefect/utilities/executors.py", line 570 in wrapper
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/prefect/engine/cloud/task_runner.py", line 344 in run
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/prefect/utilities/executors.py", line 570 in wrapper
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/prefect/engine/flow_runner.py", line 777 in run_task
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/dask/utils.py", line 73 in apply
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/dask/core.py", line 119 in _execute_task
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/dask/local.py", line 224 in execute_task
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/dask/local.py", line 238 in <listcomp>
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/site-packages/dask/local.py", line 238 in batch_execute_tasks
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57 in run
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 80 in _worker
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/threading.py", line 870 in run
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/threading.py", line 932 in _bootstrap_inner
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:   File "/usr/local/lib/python3.8/threading.py", line 890 in _bootstrap
Jul 13 20:20:49 ip-10-0-3-75 d5197543d3c0[1341]:
...

@peterallenwebb
Copy link
Contributor

I did re-run my testing with your latest code in #1635 , @sfc-gh-mkeller, and found that the segfaults were fixed.

@peterallenwebb
Copy link
Contributor

@A132770 This python stack trace, particularly with the thread stopped at line 528 in cache.py, fits the pattern exactly.

@A132770
Copy link

A132770 commented Jul 14, 2023

In our case we found it temporarily sufficient to roll back to before the cache change was implemented (2.7.9). Looking at some of our various containers looks like some slightly newer versions that include the cache change (e.g. 2.7.12) also did not manifest the segfaults -- so it's not quite clear to me at what version this issue started, and why it seemed to be 'activated' on 6/28. Hope this helps someone!

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

Successfully merging a pull request may close this issue.

7 participants