googleapis / python-spanner

Apache License 2.0
134 stars 83 forks source link

Queries are getting blocked while running using multithreading against default session pool #1024

Open alkatrivedi opened 10 months ago

alkatrivedi commented 10 months ago

While running database queries using multiple threads, execution is getting blocked. Reason: When a transaction is initialised, in case of Bursty Session Pool a new session will get created. While creating a session spanner_api method will get called to get the object reference to the spanner api. When there will be parallel execution of the queries using multiple threads, all the threads will try to create the spanner api object at the same time which is causing thread race in our program. This is why our execution is not Thread Safe and is getting blocked.

alkatrivedi commented 10 months ago

Code snippet(which is getting blocked while executing) multithreading.py.zip

surbhigarg92 commented 10 months ago

@harshachinta Can you please triage this issue.

bhatt4982 commented 1 month ago

Issue is not reproducible with the attached snippet... @alkatrivedi also confirmed the same...