ClickHouse / ClickHouse/clickhouse-odbc

Multithreading: got code SQL_INVALID_HANDLE when SQLGetData called

Open
#426 1 comment 0 reactions 0 assignees View on GitHub
Multithreading
Dominant language
C
Stars
285
Forks
105
Avg merge
3h 56m
Merged PRs (30d)
3

Description

As the title suggests, I encountered the SQL_INVALID_HANDLE error from SQLGetData function. It appears that the Driver::call function is not thread safe.

To address this issue, I attempted to add a return code in order to obtain the error code -99:
![image](https://github.com/ClickHouse/clickhouse-odbc/assets/8033252/ca6d3a80-8e83-44cd-b2ee-7da6d5072817)

In my program, multiple threads call ODBC functions simultaneously. Therefore, I suspect that when one thread is executing SQLGetData, and another thread is creating a new session, the 'descendants' variable is not protected by thread safety measures.

Contributor guide

Open the contributing guide

Research direction

Start by inspecting the Driver::call function and how the descendants variable is accessed during SQLGetData and new-session creation. Reproduce concurrent ODBC calls from multiple threads, then verify that simultaneous SQLGetData and session creation no longer produce SQL_INVALID_HANDLE or error code -99.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, clickhouse, sql
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.