Bug #91951 | SQLCancel and SQLFetchScroll are not thread-safe | ||
---|---|---|---|
Submitted: | 9 Aug 2018 12:41 | Modified: | 1 Jun 2022 17:17 |
Reporter: | Zhang Garriot | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | Connector / ODBC | Severity: | S1 (Critical) |
Version: | 8.0.12 | OS: | Any |
Assigned to: | CPU Architecture: | Any | |
Tags: | driver, ODBC |
[9 Aug 2018 12:41]
Zhang Garriot
[10 Aug 2018 8:12]
Bogdan Degtyariov
Hi Zhang, Thank you for the detailed description of the problem. This behavior is expected. On the statement level the driver is not thread-safe. The HSTMT handle is not supposed to be shared between threads for simultaneous access to the database. You will not get any advantage of concurrent threads because the MySQL Server won't execute concurrent statements in the same connection. That is why there is not much sense in slowing down the code by adding extra mutexes to protect HSTMT. The MySQL database server is just not designed for that. Therefore, I would suggest you to create a separate connection (HDBC) for each thread and use a separate HSTMT statement in each one of them. Closing, not a bug. Please feel free to reopen it if there are new details or the crash is happening with the concurrent connections instead of statements.
[16 Nov 2021 21:32]
Pierre le Riche
I don't agree with the previous comment. If you refer to the documentation for SQLCancel (https://docs.microsoft.com/en-us/sql/odbc/reference/syntax/sqlcancel-function?view=sql-ser...) it states that SQLCancel can ne used to cancel "A function running on the statement on another thread.". That means that SQLCancel should be thread safe. In an application migrated from Microsoft SQL Server we're seeing intermittent crashes in the MySQL ODBC driver when SQLCancel is called from another thread.
[1 Jun 2022 17:17]
Philip Olson
Note: a related issue was fixed via MySQL Bug #105606 -- here's the suggested 8.0.30 release note for it: SQLCancel() was not thread safe; it and other ODBC API functions are now thread safe. Thank you for the bug report.